rollout更新策略bluegreen
部署一个示例
[root@master 08-argo-rollouts]# kubectl apply -f 05-argo-rollouts-bluegreen-demo.yaml
rollout.argoproj.io/rollout-helloworld-bluegreen configured
service/spring-boot-helloworld unchanged
service/spring-boot-helloworld-preview unchanged
[root@master 08-argo-rollouts]# cat 05-argo-rollouts-bluegreen-demo.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollout-helloworld-bluegreen
spec:
replicas: 3
revisionHistoryLimit: 5
selector:
matchLabels:
app: rollout-helloworld-bluegreen
template:
metadata:
labels:
app: rollout-helloworld-bluegreen
spec:
containers:
- name: spring-boot-helloworld
image: ikubernetes/spring-boot-helloworld:v0.9.2
ports:
- containerPort: 80
strategy:
blueGreen:
activeService: spring-boot-helloworld
previewService: spring-boot-helloworld-preview
autoPromotionEnabled: false
---
kind: Service
apiVersion: v1
metadata:
name: spring-boot-helloworld
spec:
selector:
app: rollout-helloworld-bluegreen
ports:
- protocol: TCP
port: 80
targetPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: spring-boot-helloworld-preview
spec:
selector:
app: rollout-helloworld-bluegreen
ports:
- protocol: TCP
port: 80
targetPort: 80


更新一下镜像版本
[root@master 08-argo-rollouts]# vim 05-argo-rollouts-bluegreen-demo.yaml
spec:
containers:
- name: spring-boot-helloworld
image: ikubernetes/spring-boot-helloworld:v0.9.3
ports:
- containerPort: 80
[root@master 08-argo-rollouts]# kubectl apply -f 05-argo-rollouts-bluegreen-demo.yaml
重新应用之后 测试访问的还是继续访问的 0.9.2 需要手动切换,还会访问到新的版本,点击 Promote 切换




也可以回滚

版本又变成了0.9.2

在Blue-Green部署上使用analysis
root@k8s-master:~/tekton-and-argocd-in-practise/08-argo-rollouts# kubectl apply -f 06-argo-rollouts-bluegreen-with-analysis.yaml
root@k8s-master:~/tekton-and-argocd-in-practise/08-argo-rollouts# cat 06-argocd-applicatio-and-argo-rollouts.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: spring-boot-helloworld
namespace: argocd
spec:
project: default
source:
repoURL: https://gitee.com/zyyangct/spring-boot-helloworld-deployment.git
targetRevision: HEAD
path: rollouts/helloworld-bluegreen-with-analysis
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
syncOptions:
- Validate=false
- CreateNamespace=true
- PrunePropagationPolicy=foreground
- PruneLast=true
- ApplyOutOfSyncOnly=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m
ignoreDifferences:
- group: networking.istio.io
kind: VirtualService
jsonPointers:
- /spec/http/0
登录 argocd 的页面查看 applications
可以看到已经部署成功了


我把 gitee 上的镜像修改为 0.9.4 模仿上传修改代码

argocd 已经在自动部署了

可以看到 argo-rollouts 更新到了 0.9.4


浙公网安备 33010602011771号