patternkubernetesModerate
Use one Helm chart for ALL microservices?
Viewed 0 times
allchartoneforhelmmicroservicesuse
Problem
This is a follow up question to my post Parameterized Kubernetes manifest files?.
I understand more about Helm now, after lots of reading, including the Learn Helm book (which I recommend). I still have this understanding that each microservice will have its OWN Helm chart? This defeats the purpose of what I wanted, where I just have ONE helm chart, and every time I want to use it, I just update the
I come from a CloudFoormation background, where I just have ONE parameterized CloudFormation template, and I just pass it parameters pertinent to each microservice.
UPDATE: I'm aware of Helm library charts, and I don't think they can provide the functionality I want?
I understand more about Helm now, after lots of reading, including the Learn Helm book (which I recommend). I still have this understanding that each microservice will have its OWN Helm chart? This defeats the purpose of what I wanted, where I just have ONE helm chart, and every time I want to use it, I just update the
Chart.yml and values.yml files for each microservice, everything else is the same. For example, the microservice name, versions, and repo will change of course per microservice. Seems like I'm looking for a "template" for Chart.yaml and values.yaml. Is this possible to do? I don't know if it's recommended or not (I may not care).I come from a CloudFoormation background, where I just have ONE parameterized CloudFormation template, and I just pass it parameters pertinent to each microservice.
UPDATE: I'm aware of Helm library charts, and I don't think they can provide the functionality I want?
Solution
Subcharts are the way to go.
I've done a very similar thing as follows:
You could put everything in one git repo e.g.:
Then, your overall application chart (here
The key thing here is
Finally, in
When it comes to deploying
You must always run
I recommend git ignoring .tgz files, so you don't end up with .tgz files created by
I've done a very similar thing as follows:
- Create one or more base charts which cover microservices that have similar configuration (e.g. one for backend microservices, another for frontend servers).
- Create an overall chart for your application. This may be a bare bones chart without any resource configurations, but just a
Chart.yamlandvalues.yaml. Or, you may also include some resources specific to your application overall and not a particular microservice (e.g. networkpolicy or ingress).
You could put everything in one git repo e.g.:
my-deployment-repo/
|- base-microservice/
|- templates/
|- deployment.yml
|- service.yml
|- Chart.yaml
|- values.yaml
|- base-ui/
|- templates/
|- deployment.yml
|- service.yml
|- Chart.yaml
|- values.yaml
|- myapp/
|- Chart.yaml
|- values.yamlThen, your overall application chart (here
myapp) can include the base charts multiple times as a dependency in its Chart.yaml. If you are putting all these charts in one git repo, you can use relative paths to point to them. E.g.# Chart.yaml
dependencies:
- alias: my-microservice-1
name: base-microservice
version: "0.1.0"
repository: file://../base-microservice
- alias: my-microservice-2
name: base-microservice
version: "0.1.0"
repository: file://../base-microservice
- alias: my-ui-1
name: base-ui
version: "0.1.0"
repository: file://../base-ui
- alias: my-ui-2
name: base-ui
version: "0.1.0"
repository: file://../base-uiThe key thing here is
alias. This allows charts to be depended on multiple times. It sets the name of the chart to the alias, so within the subcharts you can use {{.Chart.Name}}.Finally, in
myapp's values.yaml, you can pass different values to the subcharts under their alias key, e.g. if you have used {{.Values.image}} in base-microservice, you can do the following in myapp's values.yaml:# values.yaml
my-microservice-1:
image: foo
my-microservice-2:
image: barWhen it comes to deploying
myapp, run the following commands from within the myapp directory:helm dependency update
helm install myapp .You must always run
helm dependency update before installing/upgrading a chart if any of the subcharts have changed.I recommend git ignoring .tgz files, so you don't end up with .tgz files created by
helm dependency update getting committed to your repo.Code Snippets
my-deployment-repo/
|- base-microservice/
|- templates/
|- deployment.yml
|- service.yml
|- Chart.yaml
|- values.yaml
|- base-ui/
|- templates/
|- deployment.yml
|- service.yml
|- Chart.yaml
|- values.yaml
|- myapp/
|- Chart.yaml
|- values.yaml# Chart.yaml
dependencies:
- alias: my-microservice-1
name: base-microservice
version: "0.1.0"
repository: file://../base-microservice
- alias: my-microservice-2
name: base-microservice
version: "0.1.0"
repository: file://../base-microservice
- alias: my-ui-1
name: base-ui
version: "0.1.0"
repository: file://../base-ui
- alias: my-ui-2
name: base-ui
version: "0.1.0"
repository: file://../base-ui# values.yaml
my-microservice-1:
image: foo
my-microservice-2:
image: barhelm dependency update
helm install myapp .Context
StackExchange DevOps Q#13379, answer score: 15
Revisions (0)
No revisions yet.