Canary Deployment to Kubernetes # 2: Argo Rollouts

We will use the k8s native Argo Rollouts deployment controller and GitlabCI to run Canary deployments on Kubernetes.





https://unsplash.com/photos/V41PulGL1z0



Articles in this cycle



  1. Canary Deployment to Kubernetes # 1: Gitlab CI
  2. (This article)
  3. Canary Deployment using Istio
  4. Canary Deployment Jenkins-X, Istio Flagger


Canary Deployment



, , Canary Deployments. Kubernetes.



Argo Rollouts



Argo Rollouts β€” Kubernetes- . CRD (Custom Resource Definition) Kubernetes. , : Rollout, blue-green anary deployments .



Argo Rollouts, Rollout, , blue-green anary Kubernetes. Rollout Deployment, .

Deployments : RollingUpdate Recreate. , , , blue-green canary, Deployment . Kubernetes, Deployments. Argo Rollouts .

https://argoproj.github.io/argo-rollouts

Argo CI, - Rollouts, .



Argo Rollouts





kubectl create namespace argo-rolloutskubectl apply -n argo-rollouts -f https://raw.githubusercontent.com/argoproj/argo-rollouts/stable/manifests/install.yaml



(. ) install.yaml i/k8s/argo-rollouts/install.yaml. GitlabCI .



(kubectl plugin)



https://argoproj.github.io/argo-rollouts/features/kubectl-plugin





.





Kim Wuestkamp / k8s-deployment-example-app



API Python+Flask, JSON. , GitlabCI Gitlab Registry. :



  • wuestkamp/k8s-deployment-example-app:v1
  • wuestkamp/k8s-deployment-example-app:v2


JSON-. , .





GitlabCI Kubernetes, .gitlab-ci.yml :



image: traherom/kustomize-dockerbefore_script:
   - printenv
   - kubectl versionstages:
 - deploydeploy test:
   stage: deploy
   before_script:
     - echo $KUBECONFIG
   script:
     - kubectl get all
     - kubectl apply -f i/k8s    only:
     - master


, Gcloud:



gcloud container clusters create canary --num-nodes 3 --zone europe-west3-b
gcloud compute firewall-rules create incoming-80 --allow tcp:80


https://gitlab.com/wuestkamp/k8s-deployment-example-canary-infrastructure KUBECONFIG GitlabCI, kubectl .



, (Gcloud).



Yaml



service:



apiVersion: v1
kind: Service
metadata:
 labels:
   id: rollout-canary
 name: app
spec:
 ports:
 - port: 80
   protocol: TCP
   targetPort: 5000
 selector:
   id: app
 type: LoadBalancer


rollout.yaml :



apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
 name: rollout-canary
spec:
 replicas: 10
 revisionHistoryLimit: 2
 selector:
   matchLabels:
     id: rollout-canary
 template:
   metadata:
     labels:
       id: rollout-canary
   spec:
     containers:
     - name: rollouts-demo
       image: registry.gitlab.com/wuestkamp/k8s-deployment-example-app:v1
       imagePullPolicy: Always
 strategy:
   canary:
     steps:
     - setWeight: 10
     # Rollouts can be manually resumed by running `kubectl argo rollouts promote ROLLOUT`
     - pause: {}
     - setWeight: 50
     - pause: { duration: 120 } # two minutes


Rollout Deployment. ( canary ) rolling-update Deployment.



yaml canary deployment:



  1. 10% canary (wait for manual OK)
  2. 50% canary (wait 2 minutes then continue to 100%)




:








:








Canary Deployment



1: 10%



canary , , :



apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
 name: rollout-canary
spec:
...
 template:
   metadata:
     labels:
       id: rollout-canary
   spec:
     containers:
     - name: rollouts-demo
       image: registry.gitlab.com/wuestkamp/k8s-deployment-example-app:v2
...


, Gitlab CI deploy :








:








! canary deployment. , :



kubectl argo rollouts get rollout rollout-canary








2: 50% :



: 50% . , :



kubectl argo rollouts promote rollout-canary # continue to step 2








50% :








rollout:








.



3: 100% :



, 2 50% 100%:








:








rollout:








Canary .



Argo Rollouts



, , , canary:



https://github.com/argoproj/argo-rollouts/tree/master/examples



Argo Rollouts Argo CI



, Argo Rollouts Argo CI :







CRDs, deployments replicasets, . . Argo CI.



, , Argo CI Flux CI, , : Argo Flux.



Argo Rollouts Argo CI?



:






All Articles