How to create and work with helm charts in kubernetes

Helm is a package manager for kubernetes. It provides the same features that rpm or apt provides to linux for Kubernetes.

Installing

Helm is porovided as a single binary

Grab the latest release here https://github.com/helm/helm/releases.

I am using v3.13.0 for this guide. You can confirm which version you have using this command:

1
2
3
$ helm version

version.BuildInfo{Version:"v3.13.0", GitCommit:"825e86f6a7a38cef1112bfa606e4127a706749b1", GitTreeState:"clean", GoVersion:"go1.21.1"}

Creating a new chart

To create a new chart, use the helm create command. In this example, we are creating a chart named app. We can also create a chart in a directory by providing a path.

1
2
3
4
5
# Create new chart in called app
helm create app

# Create new chart in sources directory
helm create sources/app

The created helm chart will come with default

Edit the values in the yml file to reflect your requirements.

To package the charts, use this command:

1
2
helm package app
helm package sources/app

To add an existing helm repository, use this command:

1
helm repo add stable https://kubernetes-charts.storage.googleapis.com/

And update to pull the latest helm updates

1
helm repo update

To add an existing helm repository that is protected by a password:

1
2
# with password
helm repo add --username admin --password secret citizix http://museum.dev.citizix.com

Useful chart commands

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# List available repos
helm repo list

# Varify helm chart with this
helm lint app/

# Create index file
helm repo index .

# index the repo
helm repo index --url https://etowett.github.io/helm-charts/ .

# Do git housekeeping
git add . && git commit -m "Added helm chart - jobs " && git push origin master

# Validate things are working as expected
helm upgrade -i --debug --dry-run nginx
helm upgrade -i --debug --dry-run postgres ./app -f ../provision/data/postgres.yaml -n data

# List charts
helm search repo -l
helm search repo jenkins -l
helm search repo jenkins

helm fetch citizix/app

Pushing helm charts to a repo

1
2
3
# Install the plugin
helm plugin install https://github.com/chartmuseum/helm-push.git
helm push app/ citizix

Deleting helm repo:

1
helm repo remove citizix

Resolving https://kubernetes-charts.storage.googleapis.com is not a valid chart repository in helm 2

Helm versions prior to 2.17.0 have the deprecated https://kubernetes-charts.storage.googleapis.com/index.yaml as the default stable repository, which no longer resolves. The new repo is https://charts.helm.sh/stable. You can choose to:

  • Use the --stable-repo-url argument to specify the new repository:
1
helm init --stable-repo-url https://charts.helm.sh/stable --service-account tiller
  • Use the --skip-refresh argument and replace the stable repo:
1
2
3
helm init --client-only --skip-refresh
helm repo rm stable
helm repo add stable https://charts.helm.sh/stable<
  • Upgrade helm to 2.17.0 or later.
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy