How to add dependency in Helm

In this blog, we will be deploying this guestbook application using helm and add the Redis as a dependency.


Setup a helm project

helm create guestbook
rm -rf guestbook/templates/tests

Adding a Redis Chart dependency

Chart dependencies are used to install other charts’ resources that a Helm chart may depend on.

In this example, we are using Redis as a database so we to need add this as a dependency.

First we can search the charts for redis

helm search hub redis

Now we will add the dependency section in the Charts.yaml file

- name: redis
version: 12.7.x

How to download this dependency?

When downloading a dependency for the first time, you should use the helm dependency update command.

This command will download your dependency to the charts/ directory and will generate the Chart.lock file, which specifies metadata about the chart that was downloaded.

helm dependency update guestbook

Now you should see that it has downloaded the dependency and also updated the Chart.lock file


You can override the default values of Redis chart using values.yaml file

Modify frontend application

By default it has created these templates

In the values.yaml file you can change the default image to the one which you want to use for your application

Now we will update this image as per our requirement

Also, change the NodePort so that we can browse the application

Install the chart

kubectl create ns gb( Create the namespace first)helm install my-gb guestbook -n gb
kubectl get pods -n gb

It has created PVC also as shown below

export NODE_PORT=$(kubectl get --namespace helm1 -o jsonpath="{.spec.ports[0].nodePort}" services frontend-demo-helm)export NODE_IP=$(kubectl get nodes --namespace helm1 -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT

Uninstall the chart

helm uninstall my-gb -n gb
kubectl delete pvc -l app=redis -n gb

Devops Automation Enginneer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store