Helm is a popular tool for Kubernetes package manager. This article introduces what is Helm and how to host private helm repositories.
The package manager for Kubernetes
Helm is a popular tool for Kubernetes package manager. Helm contains 3 main concepts.
A "Repo" is a charts registry. You can add your own registry.
The official Helm stable repo is popular. You can add repos with following commands.
$ helm repo add stable https://kubernetes-charts.storage.googleapis.com/
$ helm repo update
$ helm search repo stable
NAME CHART VERSION APP VERSION DESCRIPTION
stable/acs-engine-autoscaler 2.2.2 2.1.1 DEPRECATED Scales worker nodes within agent pools
stable/aerospike 0.2.8 v4.5.0.5 A Helm chart for Aerospike in Kubernetes
stable/airflow 4.1.0 1.10.4 Airflow is a platform to programmatically autho...
stable/ambassador 4.1.0 0.81.0 A Helm chart for Datawire Ambassador
...
A "Chart" is the term used for a package. A "Chart" is a collection of files that describe a related set of Kubernetes resources.
$ helm show chart stable/aerospike
apiVersion: v1
appVersion: v4.5.0.5
description: A Helm chart for Aerospike in Kubernetes
home: http://aerospike.com
icon: https://s3-us-west-1.amazonaws.com/aerospike-fd/wp-content/uploads/2016/06/Aerospike_square_logo.png
keywords:
- aerospike
- big-data
maintainers:
- email: kavehmz@gmail.com
name: kavehmz
- email: okgolove@markeloff.net
name: okgolove
name: aerospike
sources:
- https://github.com/aerospike/aerospike-server
version: 0.3.2
When a chart is installed, the Helm library creates a release to track that installation. A single chart may be installed many times into the same cluster, and create many different releases.
Release names always changed when we install charts.
We can set release name with a parameter.
$ helm install [RELEASE_NAME] stable/aerospike
Or we can use generated values.
$ helm install --generate-name stable/aerospike
Values provide a way to override template defaults with your own information.
We can check templates with values.
$ helm template stable/aerospike -f test_values.yml
And we can install with values.
$ helm install --generate-name stable/aerospike -f test_values.yml
helm v3.0.3
We can use GitLab Pages in a Public Repository. We need running GitLab runner to publish GitLab Pages.
# .gitlab-ci.yml
pages:
image:
name: linkyard/docker-helm
entrypoint: ["/bin/sh", "-c"]
stage: deploy
script:
- helm init --client-only
- mkdir -p ../public
- "echo \"User-Agent: *\nDisallow: /\" > ../public/robots.txt"
- helm package * --destination ../public
- echo https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME}
- helm repo index --url https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME} .
- mv index.yaml ../public
- mv ../public .
artifacts:
paths:
- public
only:
- master
After that
helm repo add mygitlab https://t-amachi.gitlab.io/helm-catalogs/
If you use index.yaml we need to build a new server which hosts index.yaml.
But helm v3 can evaluate OCI format, so we can use GitLab Packages.
At first, we create a new chart.
# OCI format is experimental feature
export HELM_EXPERIMENTAL_OCI=1
helm registry login -u tomoyamachi --password <token> https://registry.gitlab.com/
helm chart save map-collector gitlab.com/tomoyamachi/catalog:v0.0.1
helm chart list
#>
#
helm chart push gitlab.com/tomoyamachi/catalog:v0.0.1
Then we try to fetch the target chart in another environment.
helm registry login -u tomoyamachi --password <token> https://registry.gitlab.com/
export HELM_EXPERIMENTAL_OCI=1
helm chart pull gitlab.com/tomoyamachi/catalog:v0.0.1
helm chart list
Now we can use the catalog chart in this environment.
When using GitHub, we use https://raw.githubusercontent.com.
You only need to set the index.yaml to the root path of the target repository.
helm repo add my-public-github https://raw.githubusercontent.com/tomoyamachi/helm-catalogs/master
You can provide a username and password(token) with parameters.
helm repo add --username tomoyamachi --password $TOKEN my-private-github https://raw.githubusercontent.com/tomoyamachi/helm-catalogs/master