Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices for managing multiple environments with Helm

It is unclear to me what the best practices are for managing an application with multiple environments, that shares templated files but has different variables per environment. For example, we deploy a develop, staging and production environment. They use the same helm templates, but I have different variables for each environment.

Current File Structure:

helm/
  ├── templates/
  │   ├── _helpers.tpl
  │   ├── deploy.yaml
  │   └── ingress.yaml
  │   └── service.yaml
  │   └── managed-certs.yaml
  │   └── NOTES.txt
  ├── Chart.yaml
  ├── values-production.yaml
  ├── values-staging.yaml
  ├── values-develop.yaml

Right now I have two different value files for each environment, and I pass the following to helm helm install . --values=values-production.yaml

However we are unable to correctly manage versioning with the above.

I cannot find any solid documentation on what best practices are for managing multiple environments for an application. I came across helmfile which seems to tack this, but their documentation is unclear. The ecosystem for managing kubernetes is perplexing, any help appreciated.

like image 556
theartofbeing Avatar asked Jun 14 '19 17:06

theartofbeing


People also ask

How do you use Helm for multiple environments?

Usually a Helm upgrade or install requires the release_name, chart_folder and other necessary flags. You'll need to run your Helm commands with explicit flag -f or --values, with the value as the path to your environment specific values file. And make sure you add your application specific other Helm flags if required.

Why You Should not Use Helm?

Helm only adds value when you install community components. Otherwise you need to write yaml anyway. Leads to too much logic in the templates (not good for inexperienced k8s users) GitOps/Infrastructure as Code best practices are violated, because you version control before it has been templated.


1 Answers

Weave Flux is a great way to handle versioning of both your image and charts. It uses a gitops based approach where everything is managed through updates to your code repository (for chart versioning) or image repository (for application versioning).

Weave Flux: https://github.com/weaveworks/flux

Gitops discussion on Weaveworks site: https://www.weave.works/technologies/gitops/

Example implementation using helm and multiple environments: https://github.com/stefanprodan/gitops-helm/blob/master/README.md

like image 101
frankd Avatar answered Oct 22 '22 23:10

frankd