Argo Rollouts

参考 https://argoproj.github.io/argo-rollouts/getting-started/

安装

kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml

安装dashboard

参考 https://argoproj.github.io/argo-rollouts/dashboard/

argo rollouts 提供了一个 kubectl plugin,先安装这个plugin

brew install argoproj/tap/kubectl-argo-rollouts
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-darwin-amd64

插件是一个独立的可执行文件,名称以 kubectl- 开头。 要安装插件,将其可执行文件移动到 PATH 中的任何位置。

lizhe@ubuntu:~$ curl -LO https://github.com/argoproj/argo-rollouts/releases/download/v1.0.2/kubectl-argo-rollouts-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   641  100   641    0     0    679      0 --:--:-- --:--:-- --:--:--   679
100 61.3M  100 61.3M    0     0   115k      0  0:09:05  0:09:05 --:--:-- 87576
lizhe@ubuntu:~$ chmod +x ./kubectl-argo-rollouts-linux-amd64 
lizhe@ubuntu:~$ sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
lizhe@ubuntu:~$ kubectl argo rollouts version
kubectl-argo-rollouts: v1.0.2+7a23fe5
  BuildDate: 2021-06-15T19:36:00Z
  GitCommit: 7a23fe5dbf78181248c48af8e5224246434e7f99
  GitTreeState: clean
  GoVersion: go1.16.3
  Compiler: gc
  Platform: linux/amd64
lizhe@ubuntu:~$ 

使用plugin启动dashboard

下面是两个官方例子

kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/rollout.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/service.yaml

rollout.yaml

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-demo
spec:
  replicas: 5
  strategy:
    canary:
      steps:
      - setWeight: 20
      - pause: {}
      - setWeight: 40
      - pause: {duration: 10}
      - setWeight: 60
      - pause: {duration: 10}
      - setWeight: 80
      - pause: {duration: 10}
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: rollouts-demo
  template:
    metadata:
      labels:
        app: rollouts-demo
    spec:
      containers:
      - name: rollouts-demo
        image: argoproj/rollouts-demo:blue
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        resources:
          requests:
            memory: 32Mi
            cpu: 5m

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: rollouts-demo
spec:
  ports:
  - port: 80
    targetPort: http
    protocol: TCP
    name: http
  selector:
    app: rollouts-demo

根据官方文档的说法

Initial creations of any Rollout will immediately scale up the replicas to 100% (skipping any canary upgrade steps, analysis, etc…) since there was no upgrade that occurred.

在初次安装时,所有部署都会直接 100%,因为不需要 upgrade

进行更新 blue -> yellow

kubectl argo rollouts set image rollouts-demo \
  rollouts-demo=argoproj/rollouts-demo:yellow

在更新过程中,根据规则

更新20% 之后,它会暂停,直到用户进行unpause/promote

以下命令可以让你切换到其他 namespace

kubectl argo rollouts dashboard -n lizhe
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/rollout.yaml -n lizhe
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/service.yaml -n lizhe

不过上面的过程中会留下 replica = 0 的一些垃圾 ReplicaSet

如果你手动删除它们,会造成 argo rollouts 丢失历史记录

完整的配置文件请参考

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

这里提供了 revisionHistoryLimit: 3 , 我们的配置文件里这里是 revisionHistoryLimit: 3

也就是说,1 正在运行的记录,2 replica = 0 的历史记录一共3个,我们试着增加几次部署

可以看到最早创建的 purple 版本被移除了

Send a Message