Automating with Helm in CI/CD

1. Installing Helm in Pipeline

Example: GitHub Actions

- uses: azure/setup-helm@v4
  with:
    version: v3.16.2
- run: helm version
PlatformMethod
GitHub Actionsazure/setup-helm@v4
GitLab CIImage alpine/helm:3.16.2
CircleCIcircleci/helm@3 orb
Tektonhelm-upgrade-from-source task

2. Authenticating to Kubernetes

ClusterAuth method
EKSaws eks update-kubeconfig + IRSA / OIDC federation
GKEgcloud container clusters get-credentials + Workload Identity
AKSaz aks get-credentials + federated identity
Self-managedShort-lived ServiceAccount token via OIDC

3. Running Helm Lint

Example: Lint with strict mode

helm lint ./chart --strict --values values-prod.yaml
helm dependency update ./chart
helm lint ./chart --values values-staging.yaml

4. Performing Dry Run

Example: Server-side dry-run

helm upgrade --install api ./chart \
  -f values-prod.yaml \
  --dry-run=server \
  --debug

5. Deploying Charts

Example: Atomic deploy with timeout

helm upgrade --install api ./chart \
  -f values-prod.yaml \
  --namespace api --create-namespace \
  --atomic --timeout 10m \
  --wait \
  --version "$CHART_VERSION"

6. Running Chart Tests

Example: Post-deploy validation

helm test api --timeout 5m --logs
# Fail pipeline on test failure
[ $? -eq 0 ] || exit 1

7. Rolling Back on Failure

MechanismBehavior
--atomicAuto-rollback on upgrade failure
Explicithelm rollback api $PREVIOUS_REV
Wait + verifyCustom step checks SLO before marking success

8. Publishing Charts

Example: Chart-releaser action

- name: Release charts
  uses: helm/chart-releaser-action@v1.6.0
  env:
    CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    charts_dir: charts

9. Versioning with CI Variables

Example: Inject build metadata

yq -i ".version = \"$CI_VERSION\"" Chart.yaml
yq -i ".appVersion = \"$IMAGE_TAG\"" Chart.yaml
helm package ./chart --version "$CI_VERSION" --app-version "$IMAGE_TAG"

10. Using GitOps Workflows

PatternFlow
Pull-basedCI commits new chart version → Argo CD / Flux reconciles
Image updaterArgo CD Image Updater bumps tag on new image push
PR-drivenRenovate / Dependabot opens PRs for version bumps

11. Implementing Blue-Green Deployments

Example: Pipeline blue-green

NEW_COLOR=$([ "$ACTIVE" = "blue" ] && echo green || echo blue)
helm upgrade --install api-$NEW_COLOR ./chart \
  -f values-prod.yaml --set color=$NEW_COLOR --atomic --wait
# Run smoke tests against api-$NEW_COLOR.api.svc
./smoke-test.sh api-$NEW_COLOR
# Switch traffic
kubectl patch svc api -p "{\"spec\":{\"selector\":{\"color\":\"$NEW_COLOR\"}}}"
# Decommission old after soak period
helm uninstall api-$ACTIVE