I am trying to implement blue/green deployment using Istio virtual services and destination rules. Seems like I can make it work when calling from outside the cluster, but when a pod calls another pod the requests are balanced on both blue and green instances. All the pods involved have the Envoy sidecar.
Istio ingress gateway has been installed with the default istioctl install
.
The other relevant manifests are the following:
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
name: bg-gateway
namespace: bluegreen-playground
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 8080
name: http
protocol: HTTP
hosts:
- bluegreen.myexample.com
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: bg-route
namespace: bluegreen-playground
spec:
gateways:
- bg-gateway
hosts:
- bluegreen.myexample.com
- core-svc.bluegreen-playground.svc.cluster.local
- front-svc.bluegreen-playground.svc.cluster.local
http:
- name: core
match:
- uri:
prefix: "/core"
route:
- destination:
host: core-svc.bluegreen-playground.svc.cluster.local
subset: blue
- name: front
match:
- uri:
prefix: "/"
route:
- destination:
host: front-svc.bluegreen-playground.svc.cluster.local
subset: blue
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: core-destination
namespace: bluegreen-playground
spec:
host: core-svc.bluegreen-playground.svc.cluster.local
subsets:
- name: blue
labels:
version: v1
- name: green
labels:
version: v2
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: front-destination
namespace: bluegreen-playground
spec:
host: front-svc.bluegreen-playground.svc.cluster.local
subsets:
- name: blue
labels:
version: v1
- name: green
labels:
version: v2
All the pods are correctly labeled with version: v1
or version: v2
. The microservices call each other by using the standard Kubernetes service FQDN (e.g. front-svc.bluegreen-playground.svc.cluster.local).
Am I missing anything?
1