Blue Green Releases with Argo Rollouts
Взято в курсе “[Udemy] Ultimate Argo Bootcamp by School of Devops [ENG, 2024]”
Делаю:
2024.12.21
$ mkdir -p ~/tmp/labs/
$ cd ~/tmp/labs/
$ git clone https://github.com/sfd226/argo-labs
$ kubectl create ns staging
$ kubectl config set-context --current --namespace=staging
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* kind-kind kind-kind kind-kind staging
$ cd argo-labs/
$ kustomize build base
$ kustomize build staging
// Deploy vote service to staging
$ kubectl apply -k staging
Create a Preview Service
$ cat << EOF > base/preview-service.yaml
apiVersion: v1
kind: Service
metadata:
name: vote-preview
labels:
role: vote
spec:
selector:
app: vote
ports:
- port: 80
targetPort: 80
protocol: TCP
nodePort: 30100
type: NodePort
EOF
$ cat << EOF > base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- preview-service.yaml
EOF
$ kubectl apply -k staging
$ kubectl describe svc vote
$ kubectl describe svc vote-preview
http://localhost:30000/
http://localhost:30100/
Migrate Deployment to Argo Rollout
$ cat << EOF > base/deployment.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
labels:
app: vote
tier: front
name: vote
spec:
replicas: 4
selector:
matchLabels:
app: vote
strategy:
blueGreen:
autoPromotionEnabled: true
autoPromotionSeconds: 30
activeService: vote
previewService: vote-preview
template:
metadata:
labels:
app: vote
tier: front
spec:
containers:
- image: schoolofdevops/vote:v1
name: vote
imagePullPolicy: Always
resources:
requests:
cpu: "50m"
memory: "64Mi"
limits:
cpu: "250m"
memory: "128Mi"
EOF
$ mv base/deployment.yaml base/rollout.yaml
$ cat << EOF > base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- rollout.yaml
- service.yaml
- preview-service.yaml
EOF
$ cat << EOF > staging/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base
namespace: staging
commonAnnotations:
supported-by: [email protected]
labels:
- includeSelectors: false
pairs:
project: instavote
patches:
- path: service.yaml
EOF
$ kubectl delete deploy vote
$ kubectl apply -k staging
$ kubectl get ro
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
vote 4 4 4 4 93s
$ kubectl describe ro vote
http://localhost:30000/
http://localhost:30100/
Deploy a Blue/Green Release
Можно в UI посмотреть. Для этого:
$ kubectl argo rollouts dashboard -p 3100
http://localhost:3100/rollouts
$ vi base/rollout.yaml
update
spec:
containers:
- image: schoolofdevops/vote:v2
$ kubectl apply -k staging
$ kubectl argo rollouts status vote
Healthy