Helm
The package manager for Kubernetes, e.g.
helm install wpdemo stable/wordpress
helm status wpdemo
NAME: wpdemo
LAST DEPLOYED: May 25 15:06:44 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
This Helm chart is deprecated
Charts
A scaffold of K8s resources that will be installed in a specific sequence along its dependencies.
Create a Chart
A typical chart contains:
mychart/
├── Chart.yml # info about the chart: version, dependencies
├── LICENSE
├── README.md
├── charts # dependencies are kept here
├── crds # custom resource definitions
├── templates # manifest templates to be passed into the template engine, mixed with values.yaml
│ └── NOTES.txt # for the message shown after install
├── values.schema.json # optional
└── values.yaml # predefined values to use with templates, override with command line flag values
or create via helm create mydemo
which is an minimal chart for nginx with default values. Install via `helm install mydemo ./mydemo/
tip: Use --dry-run to generate and review the manifest
Changing values in charts
- Inline using the flag
--set
: Useful for testing and development - Passing a file with
--f
: Overrides the values.yml file - Unpack the chart and make changes permanent, make sure to bump versions
tip: Use helm show values
to check what can be changed and structure
example 1:
helm install mydemo ./mydemo/ --set image.tag=latest --dry-run
example 2:
helm install mydemo ./mydemo/ -f newvalues.yaml
cat newvalues.yaml
image:
tag: latest
Creating charts
- Create a regular K8s resource files: deploy, svc
- Create a Helm chart, and substitute values with placeholders such as
{{.Values.deploy.name}}
- Verify with
helm show values
andhelm create __ __ --dry-run
- Compare dry-run output and initial resource file
e.g.,
helm show values
Service:
type: LoadBalancer
port: 80
targetPort: 2368
nodePort: 30080
Blog:
name: blog
labels: blog
replicas: 1
image: ghost:2.6-alpine
imagePullPolicy: Always
containerPort: 2368
helm install demo ghost --set Service.type=NodePort --dry-run
# manifest with service NodePort
helm install demo ghost --set Service.type=NodePort
NAME: demo
LAST DEPLOYED: Sat Jul 26 00:54:20 2019
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
Subcharts
Are standalone charts on their own:
- Can't access main chart or other chart values
- Parent chart can override it's values
global
values can be accessed by all charts
Chart Repositories
A collection of charts with an index, it could be any repository (e.g., a GitHub repo). Manage chart repo via commands:
helm repo add bitnami https://charts.bitnami.com/bitnami
: add a repo to your local installationshelm repo list
: See all your local repo sourceshelm repo update
: Get latest updates for local reposhelm repo delete bitnami
: Remove the repo from local sources
Install from a chart repo
helm install my-nginx bitnami/nginx
: Install a specific chart from a repo
helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-nginx default 1 2020-02-25 14:53:56.584043 +0800 CST deployed nginx-9.4.1 1.21.1
Find a chart in a repo
helm search repo nginx
: Will search across all repos in your environment
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/nginx 9.4.1 1.21.1 Chart for the nginx server
bitnami/nginx-ingress-controller 7.6.17 0.48.1 Chart for the nginx Ingress controller
stable/nginx-ingress 1.41.3 v0.34.1 DEPRECATED! An nginx Ingress controller that us...
stable/nginx-ldapauth-proxy 0.1.6 1.13.5 DEPRECATED - nginx proxy with ldapauth
stable/nginx-lego 0.3.1 Chart for nginx-ingress-controller and kube-lego
bitnami/kong 3.7.9 2.5.0 Kong is a scalable, open source API layer (aka ...
stable/gcloud-endpoints 0.1.2 1 DEPRECATED Develop, deploy, protect and monitor...
Create your own repo
- Make a public GitHub repository
- In your local repo, place some charts as tar.gz files and generate an index:
cd my-repo
helm fetch stable/jenkins
helm fetch binami/nginx
cd ..
helm repo index ./my-repo/
3. Publish your repo as a a GitHub page and add it to your local repos
helm repo add my-repo https://myusername.github.io/my-repo
Updating a chart
Update running release (to test a change in your chart):
helm upgrade my-demo custom/nginx --set image.tag='latest'
- check new revision via
helm status nginx-1625655615
to make this change permanent, update the chart, push to repo and helm update