Canary Deployment in Kubernetes # 3: Istio

Using Istio + Kiali to Run and Render a Canary Deploy








Articles in this cycle



  1. Canary Deployment to Kubernetes # 1: Gitlab CI
  2. Canary Deployment to Kubernetes # 2: Argo Rollouts
  3. (this article)
  4. Canary Deployment with Jenkins-X, Istio and Flagger


Canary deployment



, , Canary deployments Kubernetes.



Istio



, , Istio. , .







: istio-proxy.



frontend-nginx backend python. nginx backend . yamls:







, . readme .



Deployment



Deployment , 2 , Istio sidecar :








Istio Gateway Loadbalancer namespace istio-system:







IP, , frontend backend :



while true; do curl -s --resolve 'frontend.istio-test:80:35.242.202.152' frontend.istio-test; sleep 0.1; done



frontend.istio-test hosts .



Mesh Kiali



Istio Tracing, Grafana, Prometheus Kiali ( . readme ). , Kiali :



istioctl dashboard kiali # admin:admin





Kiali Mesh



, 100% frontend service, label v1, nginx-, backend service, backend label v1.



Kiali Istio Mesh. .



Canary Deployment



k8s deployments, v1 v2. Istio v2.



1: 10%



VirtualService istio.yaml:



apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: default
spec:
  gateways: []
  hosts:
  - "backend.default.svc.cluster.local"
  http:
  - match:
    - {}
    route:
    - destination:
        host: backend.default.svc.cluster.local
        subset: v1
        port:
          number: 80
      weight: 90
    - destination:
        host: backend.default.svc.cluster.local
        subset: v2
        port:
          number: 80
      weight: 10







, 10% v2.



2: 50%



50%:



apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: default
spec:
...
    - destination:
        host: backend.default.svc.cluster.local
        subset: v1
        port:
          number: 80
      weight: 50
    - destination:
        host: backend.default.svc.cluster.local
        subset: v2
        port:
          number: 80
      weight: 50







3: 100%



Canary deployment v2:








Canary



, v2 10% . , v2, , ?



, HTTP :



apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: default
spec:
  gateways: []
  hosts:
  - "backend.default.svc.cluster.local"
  http:
  - match:
    - headers:
        canary:
          exact: "canary-tester"
    route:
    - destination:
        host: backend.default.svc.cluster.local
        subset: v2
        port:
          number: 80
      weight: 100
  - match:
    - {}
    route:
    - destination:
        host: backend.default.svc.cluster.local
        subset: v1
        port:
          number: 80
      weight: 90
    - destination:
        host: backend.default.svc.cluster.local
        subset: v2
        port:
          number: 80
      weight: 10


curl v2 :








1/10:








Canary



, v2 frontend backend. , 10% v2:








, frontend v1 v2 1/10 backend v1 v2.



frontend-v2 backend-v2, v1? 1/10 frontend, backend-v2 sourceLabels :



apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: default
spec:
  gateways: []
  hosts:
  - "backend.default.svc.cluster.local"
  http:
...
  - match:
    - sourceLabels:
        app: frontend
        version: v2
    route:
    - destination:
        host: backend.default.svc.cluster.local
        subset: v2
        port:
          number: 80
      weight: 100


, :








Canary



Canary deployment , k8s deployments. , . , .



Istio . , , HPAs (Horizontal Pod Autoscalers — ) Canary .





Istio Kiali . Spinnaker Istio Canary-.




All Articles