The Real-World Problem: The Multi-Cluster Helm Sprawl
Managing a single Helm chart is easy. Run helm install my-app ./charts/my-app -f values.yaml, and your pods are running. But when our team scaled from 3 services to 22 microservices across 3 clusters (dev, staging, and production), that simplicity vanished.
Every cluster required custom tweaks: 2 replicas in dev versus 10 in production, distinct ingress domains, and separate database endpoints. Within six months, our deployment repository turned into a brittle collection of Bash wrappers:
#!/usr/bin/env bash
# deploy-staging.sh
helm upgrade --install redis oci://registry-1.docker.io/bitnamicharts/redis -f env/staging/redis-values.yaml
helm upgrade --install backend ./charts/backend -f env/staging/backend-values.yaml --set secrets.dbPassword=$STAGING_DB_PASS
helm upgrade --install frontend ./charts/frontend -f env/staging/frontend-values.yaml
helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx -f env/staging/ingress-values.yaml
Four major problems hit us almost immediately:
- Ordering failures: The backend pod crashed immediately because Redis took 45 seconds to initialize. The app threw
ECONNREFUSEDand entered a CrashLoopBackOff. - Secret leaks: Passing credentials through shell variables printed raw database passwords directly into our Jenkins console output.
- Silent configuration drift: Engineers hot-fixed staging using quick
--set replicaCount=4flags during outages. Nobody committed those changes back to Git. - Copy-paste burnout: Launching a fourth cluster meant cloning 300 lines of fragile shell code and hoping no paths were missed.
Root Cause Analysis: Where Plain Helm Falls Short in GitOps
Helm excels at packaging individual Kubernetes applications. It was never built to coordinate multi-tier distributed architectures. When teams push Helm beyond packaging into environment orchestration, three core problems emerge:
1. Imperative Execution vs. Declarative State
Helm works imperatively from the CLI. Your chart templates declare desired Kubernetes resources, but sequencing fifteen separate charts still requires external scripts. Helm evaluates each command in total isolation. If chart #8 fails midway through your script, Helm leaves the first seven deployed and halts without a rollback plan.
2. The Multi-Environment Value Duplication Trap
Standard Helm workflows usually copy an entire 200-line values.yaml file for each environment. Say an upstream chart introduces a new mandatory field like securityContext.runAsNonRoot. You must manually patch every single copy across all environments. Miss one, and your deployment fails on release day.
3. Lack of Native Secret Encryption at Rest
GitOps requires keeping your entire system configuration in version control. Storing plaintext passwords or TLS private keys in Git is an immediate compliance failure. Plain Helm has no built-in decryption engine for tools like Mozilla SOPS or age. Teams end up building insecure CI workarounds or managing complex out-of-band injectors.
Solutions Compared: Plain Helm Scripts vs. Kustomize vs. Helmfile
Platform engineers typically evaluate three paths to tackle this friction:
| Feature / Requirement | Plain Helm + Bash Scripts | Kustomize Helm Integration | Helmfile Declarative Orchestration |
|---|---|---|---|
| Multi-Release Orchestration | Manual shell loops; fragile exit-code handling | Limited; treats charts as simple manifest generators | Native; manages dozens of releases as a single target state |
| Dependency Ordering (DAG) | Arbitrary sleep 30 lines in Bash; race-condition prone |
None; delegates entirely to Kubernetes reconciliation | Explicit via needs:; builds a reliable dependency graph |
| Configuration Layering | Chaining multiple -f flags by hand |
Strong for raw YAML, but awkward with chart values | Hierarchical inheritance (base values → env overrides → secrets) |
| Secret Management | Plaintext CI/CD env vars or separate external operators | SecretGenerator plugins (requires customized tooling) | Native integration with helm-secrets and SOPS/age |
| GitOps Readiness | Poor; fragile automation and manual intervention | Good; natively supported by ArgoCD and Flux | Excellent; one helmfile.yaml represents the entire cluster |
Kustomize handles raw manifests well. However, its helmCharts feature inflates charts on the client side, stripping Helm release hooks and revision histories. Helmfile takes the better route: it wraps standard Helm, preserves chart lifecycles, and adds declarative multi-chart management on top.
The Best Approach: Declarative GitOps with Helmfile
Helmfile groups your releases into a single manifest: helmfile.yaml. It tracks environment overrides, defines release order, and decrypts secrets in memory right before applying updates to the cluster.
We switched our production stack to Helmfile eighteen months ago. Deployment failures dropped from a couple of incidents each week to zero drift-related bugs.
Step 1: Set Up Prerequisites and Directory Structure
Begin by installing Helmfile alongside the Helm Diff and Helm Secrets plugins:
# Install Helm plugins
helm plugin install https://github.com/databus23/helm-diff
helm plugin install https://github.com/jkroepke/helm-secrets
# Install Helmfile binary (v0.169.2)
curl -fsSL https://github.com/helmfile/helmfile/releases/download/v0.169.2/helmfile_0.169.2_linux_amd64.tar.gz | tar -xz
sudo mv helmfile /usr/local/bin/
helmfile version
Set up a clean repository layout. Keep base configurations, environment overrides, and encrypted secrets in clearly separated folders:
deployments/
├── helmfile.yaml
├── environments/
│ ├── dev.yaml
│ ├── staging.yaml
│ └── production.yaml
├── values/
│ ├── common-labels.yaml.gotmpl
│ ├── backend/
│ │ ├── values.yaml
│ │ ├── values-dev.yaml
│ │ └── values-production.yaml
│ └── redis/
│ └── values.yaml
└── secrets/
├── backend.dev.secrets.yaml
└── backend.production.secrets.yaml
Step 2: Encrypting Sensitive Data with SOPS and Age
Generate an age key pair. This gives you a fast, modern public-key encryption setup without the headache of GPG subkeys:
# Generate an encryption key pair
age-keygen -o key.txt
# Example output:
# public key: age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
# Encrypt your staging database password
sops --encrypt --age age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p \
--encrypted-regex '^(data|stringData)$' \
secrets/backend.dev.secrets.yaml > secrets/backend.dev.secrets.enc.yaml
Check the encrypted output in secrets/backend.dev.secrets.enc.yaml. The keys stay human-readable, but values are safely encrypted:
stringData:
DB_PASSWORD: ENC[AES256_GCM,data:0bVv7k4=,iv:m1k...]
sops:
age:
- recipient: age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
enc: ...
Because the secret payload is encrypted, you can commit this file straight into Git.
Step 3: Building the Declarative helmfile.yaml
Next, assemble your environment definitions and releases in helmfile.yaml. The needs block guarantees that Redis comes up healthy before the backend chart installs:
environments:
dev:
values:
- environments/dev.yaml
production:
values:
- environments/production.yaml
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
releases:
- name: cache-service
namespace: default
chart: bitnami/redis
version: 19.6.4
values:
- values/redis/values.yaml
- architecture: {{ .Values.redis.architecture }}
- name: backend-api
namespace: default
chart: ./charts/backend
# Enforce deployment order using DAG dependencies
needs:
- default/cache-service
values:
# 1. Base shared defaults
- values/backend/values.yaml
# 2. Environment-specific override
- values/backend/values-{{ .Environment.Name }}.yaml
# 3. Dynamic Go template evaluation
- values/common-labels.yaml.gotmpl
secrets:
# 4. In-memory decryption at deploy time
- secrets/backend.{{ .Environment.Name }}.secrets.enc.yaml
Step 4: Dry-Run and Synchronization Workflow
Avoid blind deployments. Use Helmfile’s diff engine to catch misconfigurations before making live changes:
# Provide your private age key for on-the-fly decryption
export SOPS_AGE_KEY_FILE=$(pwd)/key.txt
# Run a dry-run against the dev environment
helmfile --environment dev diff
Helmfile parses the dependency order, decrypts secrets in memory, and compares your manifests against live cluster objects. Once the diff looks correct, apply all releases together:
# Sync all charts in DAG sequence
helmfile --environment dev apply
Helmfile starts by rolling out cache-service. It checks readiness probes, confirms Redis is healthy, and only then triggers the backend-api rollout.
Step 5: Incorporating into CI/CD Pipelines
Wiring Helmfile into GitHub Actions takes fewer than ten lines of shell code. Decrypt credentials securely without leaking them into logs:
# .github/workflows/deploy.yaml snippet
- name: Deploy to Kubernetes via Helmfile
env:
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
KUBECONFIG: ${{ steps.auth.outputs.kubeconfig }}
run: |
echo "$SOPS_AGE_KEY" > key.txt
export SOPS_AGE_KEY_FILE=$(pwd)/key.txt
helmfile --environment production apply --suppress-secrets
The --suppress-secrets flag strips out sensitive parameters from pipeline summaries. Decrypted passwords never show up in your build history.
Replacing fragile custom Bash scripts with Helmfile eliminates drift across clusters. Your platform team gains versioned rollouts, deterministic dependency ordering, and zero-trust secret management out of the box.

