Part 5: Production Best Practices and Security

Series Navigation: ← Part 4: Chart Dependencies and Repositories | Back to Series Overview

Introduction

Throughout this series, we've built Helm Charts from basic to advanced. But getting Charts production-ready requires additional considerations: security, secrets management, testing, CI/CD integration, and operational best practices.

This final part shares the lessons I've learned deploying Charts to production. These patterns have prevented outages, security incidents, and countless debugging sessions.

Secrets Management

Hardcoding secrets in values files is dangerous. Here are secure approaches I use.

Kubernetes Secrets

Generate secrets during installation:

templates/secret.yaml:

{{- if .Values.secrets.create }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "typescript-api.fullname" . }}-secrets
  labels:
    {{- include "typescript-api.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Values.secrets.databasePassword }}
  database-password: {{ .Values.secrets.databasePassword | b64enc | quote }}
  {{- else }}
  # Generate random password if not provided
  database-password: {{ randAlphaNum 32 | b64enc | quote }}
  {{- end }}
  
  {{- if .Values.secrets.apiKey }}
  api-key: {{ .Values.secrets.apiKey | b64enc | quote }}
  {{- else }}
  api-key: {{ randAlphaNum 64 | b64enc | quote }}
  {{- end }}
  
  {{- if .Values.secrets.jwtSecret }}
  jwt-secret: {{ .Values.secrets.jwtSecret | b64enc | quote }}
  {{- else }}
  jwt-secret: {{ randAlphaNum 128 | b64enc | quote }}
  {{- end }}
{{- end }}

Deployment using secrets:

Install without exposing secrets:

Helm Secrets Plugin

For encrypted secrets in Git, I use the helm-secrets plugin:

Install plugin:

Create encrypted secrets file:

Install with encrypted secrets:

External Secrets Operator

For production, I use External Secrets Operator to sync from AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault:

templates/externalsecret.yaml:

values.yaml:

Security Best Practices

Security configurations I enforce in all Charts:

Pod Security Context

values.yaml:

Network Policies

templates/networkpolicy.yaml:

Service Account with RBAC

templates/rbac.yaml:

Testing Charts

Testing prevents broken deployments.

Helm Lint

Template Validation

Chart Testing (ct)

I use chart-testing tool in CI/CD:

ct.yaml:

Unit Testing with Helm-unittest

tests/deployment_test.yaml:

Run tests:

Rollback Strategies

Helm makes rollbacks simple, but planning is important.

Release History

Rollback Operations

Pre-Upgrade Hooks

Automate backups before upgrades:

templates/pre-upgrade-job.yaml:

CI/CD Integration

Automate Chart deployments with CI/CD.

GitHub Actions Workflow

.github/workflows/helm-deploy.yaml:

GitLab CI/CD

.gitlab-ci.yml:

Performance Optimization

Optimize Charts for efficiency.

Resource Management

Horizontal Pod Autoscaling

Pod Disruption Budgets

values.yaml:

Troubleshooting

Common issues and solutions:

Release Stuck

Failed Upgrades

Debug Template Issues

Production Checklist

Before deploying to production:

  • ✅ Security contexts configured (non-root, read-only filesystem)

  • ✅ Resource limits and requests defined

  • ✅ Health probes configured (liveness and readiness)

  • ✅ Secrets managed securely (not in values files)

  • ✅ Network policies implemented

  • ✅ RBAC configured with least privilege

  • ✅ Pod disruption budgets set

  • ✅ Horizontal pod autoscaling configured

  • ✅ Monitoring and logging enabled

  • ✅ Backup and rollback procedures tested

  • ✅ Chart versioned and documented

  • ✅ CI/CD pipeline tested

  • ✅ Values files for each environment

  • ✅ Dependencies pinned to specific versions

  • ✅ Chart linted and unit tested

Conclusion

We've completed the Helm 101 series! From basics to production-ready patterns, you now have the knowledge to:

  • Install and configure Helm

  • Create Charts for TypeScript applications

  • Use advanced templating techniques

  • Manage dependencies and repositories

  • Deploy securely to production

  • Integrate with CI/CD pipelines

  • Troubleshoot and optimize deployments

Helm has transformed how I manage Kubernetes deployments. What used to require dozens of YAML files and manual coordination now happens with a single command. The power of templating, combined with version control and rollback capabilities, makes Helm indispensable for production Kubernetes workloads.

Additional Resources


Series Navigation: ← Part 4: Chart Dependencies and Repositories | Back to Series Overview

Key Takeaways

  • ✅ Never hardcode secrets—use Kubernetes Secrets, helm-secrets, or External Secrets

  • ✅ Enforce security contexts, network policies, and RBAC

  • ✅ Test charts with lint, unittest, and integration tests

  • ✅ Automate deployments with CI/CD pipelines

  • ✅ Always set resource limits and configure autoscaling

  • ✅ Use pod disruption budgets for high availability

  • ✅ Plan rollback strategies before production deployment

  • ✅ Follow the production checklist for every release

Last updated