hisamounaのブログ

アウトプットを習慣化するためのブログ

kindでArgo Rolloutを試す

kindでクラスタ構築

└─> kind version
kind v0.6.1 go1.13.4 darwin/amd64

└─> kind create cluster --name kinda --image kindest/node:v1.18.15 --kubeconfig $HOME/.kube/kind_config
Creating cluster "kinda" ...
.
.
.
Thanks for using kind! 😊

毎回--kubeconfig指定するのが面倒なので、aliasをセット

└─> alias kindctl='kubectl --kubeconfig=$HOME/.kube/kind_config'

└─> kindctl get nodes
NAME                  STATUS   ROLES    AGE     VERSION
kinda-control-plane   Ready    master   8m17s   v1.18.15

Argo Rolloutsのデプロイ

Argo Rolloutsインストール

└─> kindctl create namespace argo-rollouts
namespace/argo-rollouts created

└─> kindctl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml

Rollout デプロイ

└─> cat rollout.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollout-canary
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rollout-canary
  template:
    metadata:
      labels:
        app: rollout-canary
    spec:
      containers:
      - name: nginx
        image: nginx:1.20
        ports:
        - containerPort: 80
  strategy:
    canary:
      steps:
      - setWeight: 20
      - pause: {duration: 5s}
      - setWeight: 40
      - pause: {duration: 5s}
      - setWeight: 60
      - pause: {duration: 5s}
      - setWeight: 80
      - pause: {duration: 10s}

└─> kindctl apply -f rollout.yaml

└─> kindctl get rollout
NAME             DESIRED   CURRENT   UP-TO-DATE   AVAILABLE
rollout-canary   1         1         1            1

アップデート

└─> kubectl argo rollouts --kubeconfig=$HOME/.kube/kind_config set image rollout-canary nginx=nginx:1.21

└─> kubectl argo rollouts get rollout --kubeconfig=$HOME/.kube/kind_config rollout-canary -w
Name:            rollout-canary
Namespace:       default
Status:          ॥ Paused
Message:         CanaryPauseStep
Strategy:        Canary
  Step:          1/8
  SetWeight:     20
  ActualWeight:  50
Images:          nginx:1.20 (stable)
                 nginx:1.21 (canary)
Replicas:
  Desired:       1
  Current:       2
  Updated:       1
  Ready:         2
  Available:     2

NAME                                        KIND        STATUS     AGE    INFO
⟳ rollout-canary                            Rollout     ॥ Paused   3m8s
├──# revision:4
│  └──⧉ rollout-canary-7698477559           ReplicaSet  ✔ Healthy  2m56s  canary
│     └──□ rollout-canary-7698477559-j8wn5  Pod         ✔ Running  3s     ready:1/1
└──# revision:3
   └──⧉ rollout-canary-6dbf69d976           ReplicaSet  ✔ Healthy  3m8s   stable
      └──□ rollout-canary-6dbf69d976-6fk5m  Pod         ✔ Running  2m8s   ready:1/1
.
.
.
Name:            rollout-canary
Namespace:       default
Status:          ✔ Healthy
Strategy:        Canary
  Step:          8/8
  SetWeight:     100
  ActualWeight:  100
Images:          nginx:1.21 (stable)
Replicas:
  Desired:       1
  Current:       1
  Updated:       1
  Ready:         1
  Available:     1

NAME                                        KIND        STATUS        AGE    INFO
⟳ rollout-canary                            Rollout     ✔ Healthy     3m50s
├──# revision:4
│  └──⧉ rollout-canary-7698477559           ReplicaSet  ✔ Healthy     3m38s  stable
│     └──□ rollout-canary-7698477559-j8wn5  Pod         ✔ Running     45s    ready:1/1
└──# revision:3
   └──⧉ rollout-canary-6dbf69d976           ReplicaSet  • ScaledDown  3m50s

クリーンアップ

└─> kindctl delete -f rollout.yaml
rollout.argoproj.io "rollout-canary" deleted

└─> kind delete cluster --name kinda
Deleting cluster "kinda" ...