helm

Helm - the package manager for Kubernetes

# you can install with snap
sudo snap install helm --classic
# Fetch the binary from https://github.com/helm/helm/releases; check for the latest release!
tar xvf helm-xxxx.tar.gz
sudo mv linux-amd64/helm /usr/local/bin
helm version

helm search <keyword>

# Add the Kubernetes Dashboard repo, then install it
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard

# Add the Bitnami repo and search its charts
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo list
helm search repo bitnami
helm search repo file
helm search repo nginx --versions

# Install a chart with a generated name, then inspect and manage it
helm install bitnami/mysql --generate-name
kubectl get all
helm show chart bitnami/mysql
helm show all bitnami/mysql
helm list [--all-namespaces]
helm status mysql-xxxx

Creating a template from a Helm Chart

# Add the Argo repo, then render Argo CD to a YAML template without deploying
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm search repo argo/argo-cd
helm template my-argo-cd argo/argo-cd --version 7.7.14 > argo-cd-template.yaml

# Export default values, customize them, then render and apply
helm show values argo/argo-cd > values.yaml
# search for server.service.type: ClusterIP (line 2120) and change to NodePort
vim values.yaml
helm template my-argocd argo/argo-cd -f values.yaml > argo-cd-template.yaml
kubectl apply -f argo-cd-template.yaml
kubectl get all
kubectl delete -f argo-cd-template.yaml

Managing application with helm

Customizing Helm Applications

Overriding Values

# Add the repo, inspect specific values, customize them, then install and verify
helm repo add bitnami https://charts.bitnami.com/bitnami
helm show values bitnami/nginx
helm show values bitnami/nginx | grep commonLabels
helm show values bitnami/nginx | grep replicaCount
# Edit values.yaml and set:
#   commonLabels: "type: helmapp"
#   replicaCount: 3
vim values.yaml
helm install bitnami/nginx --generate-name --values values.yaml
helm list
helm get values nginx-xxxx
helm get values --all nginx-xxxx

Helm Upgrades

# Install nginx without ingress, then enable ingress to expose it
helm install bitginx bitnami/nginx --set ingress.enabled=false
helm update bitginx bitnami/nginx --set ingress.enabled=true
# Refresh repo metadata, then upgrade the release to the latest chart version
helm repo update
helm upgrade bitginx bitnami/nginx

Understanding Kustomize

# sample kustomization.yaml
resources:
- deployment.yaml
- service.yaml
namePrefix: test-
namespace: testing
commonLabels:
  environment: testing

Using Kustomization Overlays

- base
  - deployment.yaml
  - service.yaml
  - kustomization.yaml
- overlays
  - dev
    - kustomization.yaml
  - staging
    - kustomization.yaml
  - prod
    - kustomization.yaml
# overlays/dev/kustomization.yaml
resources:
- ../../base
namePrefix: dev-
namespace: development
commonLabels:
  environment: development

Page Source