Helm Charts
Prerequisites
Eligible images
|
The typical CI/CD task when working with a Helm chart is publishing it to a registry. With Space Automation, you can publish charts to Space Packages or to any external registry.
Publish Helm charts to Space Packages
Automation does not provide any special API for working with Helm, you should directly use the helm
command-line tool.
If you want to automatically generate a chart version based on the job run number, remove the version from
Chart.yaml
. The version line should look like:version:Edit the
.space.kts
file. The following example publisheshello-helm
located in thehelm-chart/hello-helm
directory to thecontainers
registry. The version of the Helm chart is adjusted with the script run number:0.1.$JB_SPACE_EXECUTION_NUMBER
.job("Publish Helm chart") { container("alpine/helm") { shellScript { content = """ export HELM_EXPERIMENTAL_OCI=1 sed -i.bak "s/^version:/version: 0.1.${'$'}JB_SPACE_EXECUTION_NUMBER/" ./helm_charts/hello-helm/Chart.yaml helm registry login mycompany.registry.jetbrains.space -u ${'$'}JB_SPACE_CLIENT_ID -p ${'$'}JB_SPACE_CLIENT_SECRET helm package ./helm_charts/hello-helm helm push hello-helm-0.1.${'$'}JB_SPACE_EXECUTION_NUMBER.tgz oci://mycompany.registry.jetbrains.space/p/project-key/containers """ } } }
Publish Helm charts to external registries
Publishing charts to external registries is almost the same as publishing to a Space Packages registry. The only difference is that you should store credentials to the repository in the Secrets&Parameters storage.
Create a parameter and a secret for storing the username and password that the script must use to access the external repository.
If you want to automatically generate chart version based on the job run number, remove the version from
Chart.yaml
. The version line should look like:version:Edit the
.space.kts
file:job("Publish Helm chart") { container("alpine/helm") { env["PSWRD"] = Secrets("repo-password") env["ID"] = Params("repo-user") shellScript { content = """ export HELM_EXPERIMENTAL_OCI=1 sed -i.bak "s/^version:/version: 1.1.${'$'}JB_SPACE_EXECUTION_NUMBER/" ./helm_charts/hello-helm/Chart.yaml helm registry login externalrepo.url -u ${'$'}ID -p ${'$'}PSWRD helm package ./helm_charts/hello-helm helm push hello-helm-1.1.${'$'}JB_SPACE_EXECUTION_NUMBER.tgz oci://externalrepo.url/repo-name """ } } }