1.安装argo-rollout
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/download/v1.5.0/install.yaml
官网:https://argoproj.github.io/argo-rollouts/
2.蓝绿部署
部署application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argo-rollouts
namespace: argocd
spec:
destination:
namespace: argo-rollouts
server: https://11.0.1.134:6443
project: default
source:
path: argo/argo-rollout/tests
repoURL: https://gitee.com/arionyu/k8syaml.git
targetRevision: HEAD
syncPolicy:
automated: {}
syncOptions:
- CreateNamespace=true
上传git部署yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollout-bluegreen
spec:
replicas: 2
revisionHistoryLimit: 2
selector:
matchLabels:
app: rollout-bluegreen
template:
metadata:
labels:
app: rollout-bluegreen
spec:
containers:
- name: rollouts-demo
image: registry.cn-hangzhou.aliyuncs.com/yushihao/nginx:latest
imagePullPolicy: Always
ports:
- containerPort: 80
imagePullSecrets:
- name: aliharbor
strategy:
blueGreen:
# activeService specifies the service to update with the new template hash at time of promotion.
# This field is mandatory for the blueGreen update strategy.
activeService: rollout-bluegreen-active
# previewService specifies the service to update with the new template hash before promotion.
# This allows the preview stack to be reachable without serving production traffic.
# This field is optional.
previewService: rollout-bluegreen-preview
# autoPromotionEnabled disables automated promotion of the new stack by pausing the rollout
# immediately before the promotion. If omitted, the default behavior is to promote the new
# stack as soon as the ReplicaSet are completely ready/available.
# Rollouts can be resumed using: `kubectl argo rollouts promote ROLLOUT`
autoPromotionEnabled: false
---
apiVersion: v1
kind: Service
metadata:
name: rollout-bluegreen-active
namespace: argo-rollouts
spec:
ports:
- nodePort: 30131
port: 80
protocol: TCP
targetPort: 80
selector:
app: rollout-bluegreen
sessionAffinity: None
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
name: rollout-bluegreen-preview
namespace: argo-rollouts
spec:
ports:
- nodePort: 30132
port: 80
protocol: TCP
targetPort: 80
selector:
app: rollout-bluegreen
sessionAffinity: None
type: NodePort
执行sync