'Istio virtual service doesn't work as expected
i novice in istio and here is my problem. I've try'd to deploy my sample application which provide hostname of pod in minikube with istio. But something goes wrong and virtual service not working.According instructions on https://istio.io/latest/docs/setup/getting-started/ i successfully deployed my app, and when i try to apply traffic rule (90% for v1 and 10% for v2) or give all traffic for version 2, doesn't metter. It still working (50% v1 for and 50% for v2). Where i made a mistake. Here is my configuration.
app conf
apiVersion: v1
kind: Service
metadata:
name: http-server
labels:
app: http-server
spec:
selector:
app: http-server
ports:
- port: 8000
name: tcp
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: name-reviews
labels:
account: http-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-server-v1
labels:
app: http-server
version: v1
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: http-server
version: v1
template:
metadata:
labels:
app: http-server
version: v1
spec:
serviceAccountName: name-reviews
containers:
- name: http-server
image: someimg-v:1.0
ports:
- containerPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-server-v2
labels:
app: http-server
version: v2
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: http-server
version: v2
template:
metadata:
labels:
app: http-server
version: v2
spec:
serviceAccountName: name-reviews
containers:
- name: http-server
image: someimg-v:2.0
ports:
- containerPort: 8000
gtway conf
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: namepodinfo-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: nameinfo
spec:
hosts:
- "*"
gateways:
- namepodinfo-gateway
http:
- match:
- uri:
exact: /
route:
- destination:
host: http-server
port:
number: 8000
dstn rule
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: http-server
spec:
host: http-server
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
Virtual Service conf
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: review
spec:
hosts:
- http-server
http:
- route:
- destination:
host: http-server
subset: v1
weight: 90
- destination:
host: http-server
subset: v2
weight: 10
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
