Recently I was working on a release pipeline where the helm chart of 30+ environments need to be updated in git with the new chart versions from Jenkins input.
Here the helm chart was in yaml format and it was a umbrella chart and individual service chart was needed to be updated from Jenkins.
The umbrella chart file looks like this. https://raw.githubusercontent.com/divyaimca/my_projects/main/update_helm_chart/chart.yaml
apiVersion: v2
description: Helm chart to deploy application NG
name:app-main
version: 0.0.1
dependencies:
- name: service-a
version: 0.1.014bf574
repository: '@helm-repo'
tags:
- application
enabled: true
- name: service-b
version: 0.1.014bf575
repository: '@helm-repo'
tags:
- application
enabled: true
- name: service-c
version: 0.1.014bf475
repository: '@helm-repo'
tags:
- application
enabled: true
- name: service-d
version: 0.1.024bf575
repository: '@helm-repo'
tags:
- application
enabled: true
- name: service-e
version: 0.1.014bf559
repository: '@helm-repo'
tags:
- application
enabled: true
Here you can see there are 5 dependent services and each version needs to be updated from
I used python module pyyaml.
Here is the code that is used in one stage to achieve this task.
https://raw.githubusercontent.com/divyaimca/my_projects/main/update_helm_chart/helmchart_parser.py
The function takes the input as chart.yaml file path and the subchart and versions in keyword arguments format. Refer the full code from the above link.
e.g.
update_helm_chart("./chart.yaml",service-b="0.2.574",service-d="0.2.585",service-e="0.2.576")