Six tools to Simplify Kubernetes Journey — Day 4 — Helm Package Manager for Kubernetes

$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
$ chmod 700 get_helm.sh
$ ./get_helm.sh
helm versionversion.BuildInfo{Version:"v3.7.1", GitCommit:"1d11fcb5d3f3bf00dbe6fe31b8412839a96b3dc4", GitTreeState:"clean", GoVersion:"go1.17.2"}
helm envHELM_BIN="helm"HELM_CACHE_HOME="/Users/plakhera/Library/Caches/helm"HELM_CONFIG_HOME="/Users/plakhera/Library/Preferences/helm"HELM_DATA_HOME="/Users/plakhera/Library/helm"HELM_DEBUG="false"HELM_KUBEAPISERVER=""HELM_KUBEASGROUPS=""HELM_KUBEASUSER=""HELM_KUBECAFILE=""HELM_KUBECONTEXT=""HELM_KUBETOKEN=""HELM_MAX_HISTORY="10"HELM_NAMESPACE="default"HELM_PLUGINS="/Users/plakhera/Library/helm/plugins"HELM_REGISTRY_CONFIG="/Users/plakhera/Library/Preferences/helm/registry.json"HELM_REPOSITORY_CACHE="/Users/plakhera/Library/Caches/helm/repository"HELM_REPOSITORY_CONFIG="/Users/plakhera/Library/Preferences/helm/repositories.yaml"
~/.kube/config
helm repo lisNAME   	URL                     gremlin	https://helm.gremlin.comt
helm repo add <repo> url
helm repo add stable https://charts.helm.sh/stable
"stable" has been added to your repositories
$ helm search repo mysql
NAME CHART VERSION APP VERSION DESCRIPTION
stable/mysql 1.6.7 5.7.30 Fast, reliable, scalable, and easy to use open-...
stable/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL...
stable/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql ex...
stable/percona 1.2.1 5.7.26 free, fully compatible, enhanced, open source d...
stable/percona-xtradb-cluster 1.0.6 5.7.19 free, fully compatible, enhanced, open source d...
stable/phpmyadmin 4.3.5 5.0.1 DEPRECATED phpMyAdmin is an mysql administratio...
stable/gcloud-sqlproxy 0.6.1 1.11 DEPRECATED Google Cloud SQL Proxy
stable/mariadb 7.3.14 10.3.22 DEPRECATED Fast, reliable, scalable, and easy t...
$ helm search hub |head
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/gabibbo97/389ds 0.1.0 fedora-32 389 Directory Server
https://hub.helm.sh/charts/arhatdev/abbot 0.1.0 latest Network Manager Living at Edge
https://hub.helm.sh/charts/restorecommerce/acce... 0.1.2 0.1.6 A Helm chart for restorecommerce access-control...
https://hub.helm.sh/charts/ckotzbauer/access-ma... 0.4.1 0.4.1 Kubernetes-Operator to simplify RBAC configurat...
https://hub.helm.sh/charts/a10-prometheus-expor... 0.1.0 1.0 A Helm chart of A10 acos prometheus exporter fo...
https://hub.helm.sh/charts/k8s-at-home/adguard-... 2.2.0 v0.102.0 DNS proxy as ad-blocker for local network
https://hub.helm.sh/charts/mogaal/adminer 0.1.0 4.7.3 A Helm chart for Adminer
https://hub.helm.sh/charts/cetic/adminer 0.1.6 4.7.7 Adminer is a full-featured database management ...
https://hub.helm.sh/charts/graviteeio/ae 1.1.11 1.2.13 Official Gravitee.io Helm chart for Alert Engine

Creating your first chart

helm create myhelmchartCreating myhelmchart
tree myhelmcharmyhelmchart├── Chart.yaml├── charts├── templates│   ├── NOTES.txt│   ├── _helpers.tpl│   ├── deployment.yaml│   ├── hpa.yaml│   ├── ingress.yaml│   ├── service.yaml│   ├── serviceaccount.yaml│   └── tests│       └── test-connection.yaml└── values.yaml
3 directories, 10 filest
rm -rf myhelmchart/templates/zsh: sure you want to delete all 8 files in /Users/plakhera/Documents/kind/myhelmchart/templates [yn]? y*
kubectl create deployment nginx --image=nginx --dry-run=client -o yaml >>myhelmchart/templates/nginx.yaml
kubectl expose deploy nginx --port 80 --type NodePort --dry-run=client -o yaml >> myhelmchart/templates/service.yamError from server (NotFound): deployments.apps "nginx" not foundl
kubectl create deployment nginx --image=ngindeployment.apps/nginx createdx
kubectl expose deploy nginx --port 80 --type NodePort --dry-run=client -o yaml >> myhelmchart/templates/service.yaml
cat Chart.yaml               
apiVersion: v2
name: myhelmchart
description: A Helm chart for Kubernetes
version: 0.1.0
echo "This is first helm chart and it will deploy nginx application" >>templates/NOTES.txt
rm -rf values.yaml charts
kubectl delete deployment ngindeployment.apps "nginx" deletedx

Deploying your first chart

helm lint ./myhelmchar
==> Linting ./myhelmchart[INFO] Chart.yaml: icon is recommended[INFO] values.yaml: file does not exist
1 chart(s) linted, 0 chart(s) failedt
helm install demochart ./myhelmchart --dry-ruNAME: demochartLAST DEPLOYED: Thu Oct 21 17:49:56 2021NAMESPACE: defaultSTATUS: pending-installREVISION: 1TEST SUITE: NoneHOOKS:MANIFEST:---# Source: myhelmchart/templates/service.yamlapiVersion: v1kind: Servicemetadata:  creationTimestamp: null  labels:    app: nginx  name: nginxspec:  ports:  - port: 80    protocol: TCP    targetPort: 80  selector:    app: nginx  type: NodePortstatus:  loadBalancer: {}---# Source: myhelmchart/templates/nginx.yamlapiVersion: apps/v1kind: Deploymentmetadata:  creationTimestamp: null  labels:    app: nginx  name: nginxspec:  replicas: 1  selector:    matchLabels:      app: nginx  strategy: {}  template:    metadata:      creationTimestamp: null      labels:        app: nginx    spec:      containers:      - image: nginx        name: nginx        resources: {}status: {}
NOTES:This is first helm chart and it will deploy nginx applicationn
helm install demochart ./myhelmcharNAME: demochartLAST DEPLOYED: Thu Oct 21 17:50:13 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneNOTES:This is first helm chart and it will deploy nginx applicationt
helm lisNAME     	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART            	APP VERSIONdemochart	default  	1       	2021-10-21 17:50:13.253624 -0700 PDT	deployed	myhelmchart-0.1.0t
apiVersion: apps/v1kind: Deploymentmetadata:  creationTimestamp: null  labels:    app: nginx  name: nginxspec:  replicas: 1  selector:    matchLabels:      app: nginx  strategy: {}  template:    metadata:      creationTimestamp: null      labels:        app: nginx    spec:      containers:      - image: nginx        name: nginx        resources: {}status: {}
helm uninstall democharrelease "demochart" uninstalledt
helm listNAME	NAMESPACE	REVISION	UPDATED	STATUS	CHART	APP VERSION
cat values.yamimagename: nginxl
cat  myhelmchart/templates/nginx.yamapiVersion: apps/v1kind: Deploymentmetadata:  creationTimestamp: null  labels:    app: nginx  name: nginxspec:  replicas: 1  selector:    matchLabels:      app: nginx  strategy: {}  template:    metadata:      creationTimestamp: null      labels:        app: nginx    spec:      containers:      - image: {{ .Values.imagename }}        name: nginx        resources: {}status: {}l
cat myhelmchart/Chart.yaml   
apiVersion: v2
name: myhelmchart
description: A Helm chart for Kubernetes
version: 0.2.0
helm install demochart ./myhelmchartNAME: demochartLAST DEPLOYED: Thu Oct 21 18:02:55 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneNOTES:This is first helm chart and it will deploy nginx application

Packaging Chart

helm package ./myhelmchart      
Successfully packaged chart and saved it to: /home/prashant/Documents/helm/myhelmchart-0.2.0.tgz
helm install mychart myhelmchart-0.2.0.tgz

Wrapping Up

--

--

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