Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Ka whakamahi matou i te k8s-taketake Argo Rollouts kaiwhakahaere tuku me GitlabCI hei whakahaere i nga tukunga Canary ki Kubernetes

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

https://unsplash.com/photos/V41PulGL1z0

Tuhinga o tenei raupapa

Te Tukunga Canary

Ko te tumanako ka panui koe waahanga tuatahi, i whakamaarama pototia e matou he aha nga Canary Deployments. I whakaatu ano matou me pehea te whakatinana ma te whakamahi i nga rauemi Kubernetes paerewa.

Argo Rollouts

Ko Argo Rollouts he kaiwhakahaere tuku taketake a Kubernetes. Ka whakaratohia he CRD (Whakamaramatanga Rauemi Ritenga) mo nga Kubernetes. He mihi ki tenei, ka taea e tatou te whakamahi i tetahi hinonga hou: Rollout, e whakahaere ana i nga whakatakotoranga puru-matomato me te canary me nga momo whiringa whirihoranga.

Argo Rollouts pūmana whakamahia e te rauemi ritenga Rollout, Whakaaetia mo etahi atu rautaki whakatakotoranga penei i te puru-matomato me te canary mo Kubernetes. Rauemi Rollout whakarato taumahinga rite Deployment, me etahi atu rautaki whakaurunga anake.
rauemi Deployments e rua nga rautaki mo te tuku: RollingUpdate и Recreate. Ahakoa e pai ana enei rautaki mo te nuinga o nga keehi, mo te tuku ki nga kaitoro i runga i te waahanga nui rawa atu, ka whakamahia etahi atu rautaki, penei i te puru-matomato, canary ranei, kaore i te waatea i roto i te Kaiwhakahaere Whakamahinga. Hei whakamahi i enei rautaki i roto i nga Kubernetes, me tuhi nga kaiwhakamahi i nga tuhinga tuhi ki runga ake o a raatau Whakamahinga. Ko te Kaiwhakahaere Argo Rollouts e whakaatu ana i enei rautaki he ngawari, he korero, he tawhā taea te whirihora.
https://argoproj.github.io/argo-rollouts

Kei reira ano hoki a Argo CI, e whakarato ana i te atanga paetukutuku pai mo te whakamahi me te Rollouts, ka tirohia e maatau i te tuhinga e whai ake nei.

Te whakauru i nga Argo Rollouts

Te taha tūmau

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

I roto i to maatau hanganga kemu (tirohia i raro) kua taapirihia e matou te install.yaml hei i/k8s/argo-rollouts/install.yaml. Ma tenei ka whakauruhia e GitlabCI ki roto i te kohinga.

taha Kiritaki (kubectl monomai)

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

Tauira Tono

He pai te mahi ki te whai waahi motuhake mo te waehere tono me nga hanganga.

He putunga mo te tono

Kim Wuestkamp/k8s-deployment-example-app

He Python+Flask API tino ngawari tenei e whakahoki mai ana i te urupare hei JSON. Ka hangaia e matou te kete ma te whakamahi i te GitlabCI ka pana te hua ki te Rehita Gitlab. I roto i te rehita e rua nga putanga tuku rereke:

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

Ko te rereketanga anake i waenga i a raatau ko te konae JSON i whakahokia mai. Ka whakamahia e matou tenei tono ki te tiro ngawari ki te ahua o te putanga e korero ana matou.

Pupuri hangahanga

I roto i tenei putunga ka whakamahia e matou a GitlabCI mo te tuku ki nga Kubernetes, .gitlab-ci.yml te ahua penei:

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

Hei whakahaere i a koe ake ka hiahia koe ki te tautau, ka taea e koe te whakamahi Gcloud:

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

Me marau koe https://gitlab.com/wuestkamp/k8s-deployment-example-canary-infrastructure me te hanga taurangi KUBECONFIG i GitlabCI, kei roto te whirihora mo te uru kubectl ki to tautau.

ko te reira Ka taea e koe te panui me pehea te tiki tohu mo te tautau (Gcloud).

Hanganga Yaml

I roto i te rehitatanga hanganga kei a maatau ratonga:

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

me te 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 he rite tonu te mahi ki te Whakamahinga. Ki te kore matou e whakatakoto rautaki whakahōu (penei i te kanari i konei) ka rite te ahua o te Whakanoho-whakahoutanga taunoa.

Ka tautuhia e matou nga waahanga e rua i roto i te yaml mo te tuku canary:

  1. 10% o nga waka ki te canary (tatari mo te pukapuka OK)
  2. 50% te hokohoko ki te canary (tatari 2 meneti ka haere tonu ki te 100%)

Te mahi tukunga tuatahi

Whai muri i te tukunga tuatahi, ka penei te ahua o a maatau rauemi:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Na ka whiwhi whakautu mai i te putanga tuatahi o te tono:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Te mahi i te Canary Deployment

Hipanga 1: 10% hokohoko

Hei tiimata i te tukunga kanari, me whakarereke noa te ahua o te ahua penei i te nuinga o te waa ki te tuku:

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
...

Na ka peia e matou nga huringa, na reira ka tukuna e Gitlab CI ka kite matou i nga huringa:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Inaianei ka uru tatou ki te ratonga:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Rawe! Kei waenganui tatou i to tatou tukunga kanari. Ka kite tatou i te ahunga whakamua ma te rere:

kubectl argo rollouts get rollout rollout-canary

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Hipanga 2: 50% hokohoko:

Inaianei me neke atu ki te mahi e whai ake nei: te whakatika i te 50% o nga waka. I whirihorahia e matou tenei taahiraa kia whakahaere a-ringa:

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

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Na ta matou tono i whakahoki 50% o nga whakautu mai i nga putanga hou:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Me te arotake i te putanga:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Whakamiharo.

Hipanga 3: 100% hokohoko:

I whakaritea e matou kia whai muri i te 2 meneti ka mutu aunoa te taahiraa 50% ka timata te taahiraa 100%:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Na te putanga tono:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Me te arotake i te putanga:

Te Tukunga Canary ki Kubernetes #2: Argo Rollouts

Kua oti te tuku Canary.

Ētahi atu tauira me Argo Rollouts

He maha atu nga tauira i konei, penei me pehea te whakarite i nga tirohanga taiao me nga whakataurite i runga i te canary:

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

Ataata mo Argo Rollouts me Argo CI

Ka tino taunaki ahau i tenei ataata, e whakaatu ana me pehea te mahi tahi a Argo Rollouts me Argo CI:

Ko te hua

He pai ki ahau te whakaaro ki te whakamahi i nga CRD e whakahaere ana i te hanga o etahi atu momo whakaurunga, tauira taapiri ranei, whakahuri i nga waka, aha atu. He pai te mahi tahi me ratou. I muri mai ka hiahia ahau ki te whakamatautau i te whakauru ki a Argo CI.

Heoi, te ahua nei he whakakotahitanga nui o Argo CI me Flux CI e haere mai ana, na ka tatari ahau kia puta mai te tukunga hou: Argo Flux.

Kua whai wheako koe mo Argo Rollouts Argo CI ranei?

Panuihia etahi atu tuhinga i runga i ta maatau blog:

Source: will.com

Tāpiri i te kōrero