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
在Blue-Green部署上使用analysis
[root@master 08-argo-rollouts]# kubectl apply -f 06-argo-rollouts-bluegreen-with-analysis.yaml
[root@master 08-argo-rollouts]# cat 06-argo-rollouts-bluegreen-with-analysis.yaml
# CopyRight: MageEdu <http://www.magedu.com>
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
successCondition: result[0] >= 0.95
interval: 20s
count: 5
failureLimit: 5
provider:
prometheus:
address: http://prometheus.istio-system.svc.cluster.local:9090
query: |
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[1m]
)) /
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[1m]
))
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollout-helloworld-bluegreen-with-analysis
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.5
ports:
- containerPort: 80
strategy:
blueGreen:
activeService: spring-boot-helloworld
previewService: spring-boot-helloworld-preview
prePromotionAnalysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: spring-boot-helloworld.default.svc.cluster.local
postPromotionAnalysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: spring-boot-helloworld.default.svc.cluster.local
autoPromotionEnabled: true
---
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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)