Adfolks LLC has formally joined the ZainTECH family Learn more
Blogs How to create a Helm chart for your application deployment in Kubernetes
banner adfolks
blog adfolks
Adfolks
Cloud, Kubernetes,

How to create a Helm chart for your application deployment in Kubernetes

Posted:

Helm is the popular package manager for Kubernetes deployments. In this article, I will describe step by step, how to package your Kubernetes deployment and create a Helm chart.

Here is the recipe πŸ₯˜

Before you begin to create a Helm chart for your application deployment, you should test the application deployment and docker image.

You can try deploying your application by writing the deployment, service, config-map and secret manifests and execute it against the test Kubernetes cluster. Once you have done that follow the below steps to create the Helm chart,

Run below command to create sample helm chart structure

helm create package-name

Here package-name can be your application name, which you want to write a helm chart.

  • Once the chart template is created, change below keys in values.yaml:
  1. repository: Your container image repo URL
  2. imagePullSecrets: Image pull secret if image repository is a private one
  3. service: You may have to change target port, protocol and name in ports specification
  • Make sure ingress enabled is false in values.yaml
  • Now open deployment.yaml file from templates folder and see whether there is any additional or missing field in your actual deployment file.
  • Tweak the deployment file in templates folder with missing pieces of information from the actual deployment file
  • Now do the same with configmap, services, secrets files in the templates folder
  • Test the chart by running below command

helm install --dry-run --debug ./component-name --generate-name

Once the dry run is a success, package the chart using below command

helm package component-name

Run Chart museum locally to serve charts

Now we can use Chart museum to serve our charts, run below command to start Chart museum locally in docker

Now run below command to push the chart which you just created

docker run --rm -it -p 8080:8080 -v $(pwd)/charts:/charts -e DEBUG=true -e STORAGE=local -e STORAGE_LOCAL_ROOTDIR=/charts chartmuseum/chartmuseum:latest

curl --data-binary "@componentname-0.1.0.tgz" http://localhost:8080/api/charts

Once you run the above command add the repo to the list by running below command,

helm repo add repo-name http://192.168.0.109:8080/

Once the repo is added run the below command to update the repo,

helm repo update

Now you can deploy the application by running helm install command as below,

helm install release-name repo-name/component-name

Great, now you completed learning how to create a basic helm chart, deploy chart museum locally for serving your charts and using that chart museum for helm chart installations. Happy helming!! 🍾😎