Kubernetes - Helm
Helm - The Kubernetes Package Manager.
Use Helm to:
- Find and use popular software packaged as Helm charts to run in Kubernetes
- Share your own applications as Helm charts
- Create reproducible builds of your Kubernetes applications
- Intelligently manage your Kubernetes manifest files
- Manage releases of Helm packages
Helm is similar to maven, npm and apt except it manages Kubernetes resources.
Key Concepts
Tiller Server and Helm Client
Tiller Server: Tiller is the in-cluster component of Helm. It interacts directly with the Kubernetes API server to install, upgrade, query, and remove Kubernetes resources. It also stores the objects that represent releases.
Helm Client: CLI tool for users to work with Helm Charts.
Chart
Charts are packages of pre-configured Kubernetes resources.
Release
When a chart is installed, Tiller (the Helm server) creates a release to track that installation. Release is an running instance of Chart. You can think of it as an application.
Install Helm
Helm is composed of two parts: Helm (the client) and Tiller (the server)
Install Helm Client
run kubectl config current-context
or kubectl cluster-info
to see the current cluster. Make sure it is currently running.
Install Helm
1 | curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh |
Use helm version
to check Helm version. Output should look like this
1 | $ helm version |
Install Tiller Server
Initialize the local CLI and also install Tiller into your Kubernetes cluster in one step using helm init
command.
1 | $ helm init |
It may take a minute for tiller to install. Use helm ls
to verify tiller is installed.
If tiller is not ready, error will be return.
1 | $ helm ls |
Helm Install Default Charts
get latest list of charts
1 | helm repo update |
Install a chart. Mysql in this case. The notes from the output should tell you what resources are installed and how to interact with the release. In this case MySQL.
1 | helm install stable/mysql --name my-release |
add service account if helm install fail because of permission issue
1 | kubectl create serviceaccount --namespace kube-system tiller |
Delete Tiller and reinstall if Tiller is not working
1 | kubectl delete deployment tiller-deploy -n kube-system |
To see what is release
1 | helm ls |
To delete a release
1 | helm delete my-release |
Create and Install Customized Chart
Let’s learn to create a customized chart for httpd
To create a chart for httpd
1 | helm create httpdchart |
The default chart created use nginx. Modify values.yaml to use httpd
1 | image: |
use helm lint httpchart
to check errors.
1 | helm lint httpchart |
Dry run to get the yaml to be generate
1 | helm install --dry-run httpdchart --debug |
Use helm install
to install the chart. This will create deployment, pod and service.
1 | $ helm install httpdchart --name myhttpd |
Test the service just created.
1 | $ curl $(minikube ip):$(kubectl get service/myhttpd-httpdchart -o jsonpath="{.spec.ports[*].nodePort}") |