We are trying to do a weighted traffic routing for our application using Istio. But for some reason, the traffic split is not working as intended. When we say we want 100% traffic to reach v2 of our app, it still sends requests to the v1 as well. Am I missing anything here?
We have the outside traffic routed via an Nginx pod to the backend svc.
java-backend-svc.yaml
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"java-backend","service":"java-backend"},"name":"java-backend","namespace":"eve"},"spec":{"ports":[{"name":"http-javabackend","port":8080,"protocol":"TCP","targetPort":8080}],"selector":{"io.kompose.service":"java-backend"}}}
creationTimestamp: "2020-11-28T08:22:22Z"
labels:
app: java-backend
service: java-backend
name: java-backend
namespace: eve
resourceVersion: "1770680"
selfLink: /api/v1/namespaces/eve/services/java-backend
uid: bd4ca848-827b-4901-858d-bda57133ff8a
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: java-backend
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
java-backend-v1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kompose.cmd: kompose convert
kompose.version: 1.1.0 (36652f6)
creationTimestamp: "2020-12-01T18:22:14Z"
generation: 1
labels:
app: java-backend
version: v1
name: java-backend
namespace: eve
resourceVersion: "1766086"
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: java-backend
version: v1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
app: java-backend
version: v1
spec:
containers:
- args:
- catalina.sh
- run
image: backend:eve-v1
imagePullPolicy: Always
name: java-backend
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "1"
memory: 4000Mi
requests:
cpu: "1"
memory: 4000Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/local/logs/
name: java-backend-volume
dnsConfig:
options:
- name: ndots
value: "1"
- name: timeout
value: "2"
- name: attempts
value: "5"
- name: single-request-reopen
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /usr/local/konotor/logs/eve/java-backend/
type: DirectoryOrCreate
name: java-backend-volume
java-backend-v2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kompose.cmd: kompose convert
kompose.version: 1.1.0 (36652f6)
creationTimestamp: "2020-12-01T18:40:01Z"
generation: 1
labels:
app: java-backend
version: v2
name: java-backend-new
namespace: eve
resourceVersion: "1769437"
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: java-backend
version: v2
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
app: java-backend
version: v2
spec:
containers:
- args:
- catalina.sh
- run
image: backend:eve-dev
imagePullPolicy: Always
name: java-backend
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "1"
memory: 4000Mi
requests:
cpu: "1"
memory: 4000Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/local/logs/
name: java-backend-volume
dnsConfig:
options:
- name: ndots
value: "1"
- name: timeout
value: "2"
- name: attempts
value: "5"
- name: single-request-reopen
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /usr/local/logs/eve/java-backend/
type: DirectoryOrCreate
name: java-backend-volume
Virtualservice
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: java-backend
spec:
hosts:
- java-backend
http:
- route:
- destination:
host: java-backend
subset: v1
weight: 0
- destination:
host: java-backend
subset: v2
weight: 100
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: java-backend
spec:
host: java-backend
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2