Cloud / HELM Interview Questions
How do you implement Blue-Green and Canary deployments with Helm?
Advanced deployment patterns with Helm require careful release management and service routing.
Blue-Green deployment pattern: # values.yaml blue: enabled: true replicaCount: 3 image: tag: blue-1.0 green: enabled: false replicaCount: 3 image: tag: green-2.0 service: selectorVersion: blue # templates/deployment-blue.yaml {{- if .Values.blue.enabled }} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "myapp.fullname" . }}-blue labels: version: blue spec: replicas: {{ .Values.blue.replicaCount }} selector: matchLabels: app: {{ include "myapp.name" . }} version: blue template: metadata: labels: version: blue spec: containers: - name: app image: {{ .Values.image.repository }}:{{ .Values.blue.image.tag }} {{- end }} # Same for deployment-green.yaml # Service toggles between versions apiVersion: v1 kind: Service metadata: name: {{ include "myapp.fullname" . }} spec: selector: version: {{ .Values.service.selectorVersion }}
Blue-Green deployment procedure: # Deploy blue (current) helm upgrade --install myapp ./chart \\ --set blue.enabled=true,green.enabled=false,service.selectorVersion=blue # Deploy green alongside helm upgrade --install myapp ./chart \\ --set blue.enabled=true,green.enabled=true,service.selectorVersion=blue # Test green kubectl port-forward deployment/myapp-green 8080:80 # Switch traffic to green helm upgrade --install myapp ./chart \\ --set blue.enabled=true,green.enabled=true,service.selectorVersion=green # Remove blue after verification helm upgrade --install myapp ./chart \\ --set blue.enabled=false,green.enabled=true,service.selectorVersion=green
Canary deployment with Istio weights: # templates/virtualservice.yaml apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: {{ include "myapp.fullname" . }} spec: hosts: - {{ include "myapp.fullname" . }} http: - route: - destination: host: {{ include "myapp.fullname" . }} subset: stable weight: {{ sub 100 .Values.canary.weight }} - destination: host: {{ include "myapp.fullname" . }} subset: canary weight: {{ .Values.canary.weight }}
Automated canary deployment script: #!/bin/bash WEIGHT=10 STEP=10 MAX_WEIGHT=100 while [ $WEIGHT -le $MAX_WEIGHT ]; do helm upgrade myapp ./chart --set canary.weight=$WEIGHT # Monitor metrics ERROR_RATE=$(curl -s prometheus:9090/api/v1/query?query=error_rate) if [ $(echo "$ERROR_RATE > 0.01" | bc) -eq 1 ]; then echo "Error rate too high, rolling back" helm rollback myapp break fi sleep 300 # Wait 5 minutes WEIGHT=$((WEIGHT + STEP)) done
Argo Rollouts with Helm: apiVersion: argoproj.io/v1alpha1 kind: Rollout metadata: name: myapp spec: strategy: canary: steps: - setWeight: 20 - pause: {duration: 1m} - setWeight: 40 - pause: {duration: 1m} - setWeight: 60 - pause: {duration: 1m} - setWeight: 80 - pause: {duration: 1m} - setWeight: 100 template: metadata: labels: app: myapp spec: containers: - name: app image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
