We have below chart structure in helm which can deploy 'a microservice' to our k8s cluster
service-chart
|_templates
|_deployment.yaml
|_Ingress.yaml
|_service.yaml
|_Chart.yaml
|_valueBase.yaml
|_valueForService1.yaml
|_valueForService2.yaml
..
..
|_valueForService{n}.yaml
valueBase.yaml
contains default values for a service (for eg. limits, replicas etc)
global:
namespace: teamname
environment: staging
limits:
memory: "500Mi"
cpu: "300m"
deployments:
replicas: 1
probes:
path: "/"
and valueForService1.yaml
file contains values overridden for a specific service
app:
name: "service1"
image:
name: "service1"
version: "2021.11.xxx"
port: 50001
deployments:
replicas: 3
All of above services follow exactly same structure and create similar resources i.e. a service, a pod and an ingress. we deploy an individual service as
helm upgrade --install -f valueBase.yaml -f valueForService1.yaml service1 .
But problem is we have 50 of these services. and we would want to install all of them together instead of running 50 commands back to back. Also would like to have some release co-ordination in between releasing multiple services. for eg. release service1 before releasing service2.
I know we can do this in one command with 50 -f
parameters in it but that's not the kind of solution I am here for.
How can we package them properly so we can
All suggestions welcomed. Feel free to ask for more details.
Note: We tried using sub-chart but it doesn't appear to be solved by using sub-charts. We just have lots of services with similar structure. but I might have used sub charts completely wrong.
What you're looking for is helmfile
Store your base chart and services values in the same folder.
Create helmfile.yml
.
releases:
- name: service1
labels:
app: service1
group: group1
chart: charts/baseChart
values:
- valueBase.yaml
- valueForService1.yaml
- fullnameOverride: service1
- name: service2
labels:
app: service2
group: group1
chart: charts/baseChart
values:
- valueBase.yaml
- valueForService2.yaml
- fullnameOverride: service2
needs:
- service1
Each release in the releases list is a helm release definition. You can control installation order with the needs
keyword.
Now your folder looks something like this
.
├── charts/
│ └── baseChart/
├── helmfile.yml
├── valueBase.yml
├── valueForService1.yml
└── valueForService2.yml
and you're ready to run helmfile commands
helmfile -n <namespace> apply
will release all services at once
helmfile -n <namespace> -l app=service1 apply
will release an individual service with the app: service label
helmfile -n <namespace> -l group=group1 apply
will release all services with the group: group1 label