kubernetes helm - ghdrako/doc_snipets GitHub Wiki

Helm Chart Repository

$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm install stable/prometheus

The basic configuration item in Helm is the chart. A template that consists of a Kubernetes application that is used by Helm, is called a chart. The chart has a standard file and directory structure, shown next. You can use the $ helm create command to create this structure:

mychartname/
|
|- .helmignore
|
|- Chart.yaml
|
|- values.yaml
|
|- charts/
|
|- templates/
  • The .helmignore file works like a .gitignore file and specifies files or directories to be ignored by the Helm command.
  • The Chart.yaml file holds metadata about the chart you are packaging, such as your version of the chart itself.
  • The values.yaml file stores any values used for the deployment. You will normally see one file, the default values, but multiple value files can be used for different environments.
  • The charts directory is used to store other charts that your chart may depend on.
  • The templates directory holds the actual manifest you have created to support the deployment of your application. This may consist of multiple YAML files to deploy pods, config maps, secrets, and so on.

Values are transposed into the chart using the {{ define }} directive, which means the templates are significantly more flexible than standard Kubernetes manifests. What follows is an example of Helm manifest that shows a resource, in this case, a ConfigMap can be modified:

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
myvalue: "Hello World"

In this example, the name of the ConfigMap will be a combination of Release.Name and the -configmap string. For example, if your chart name is CM1, the resulting ConfigMap will be named CM1-configmap.

Install binnary

$ curl -L https://git.io/get_helm.sh | bash -s -- --version v3.8.2

Install helm Nginx ingress

$ helm repo add nginx-stable
$ helm repo update
$ helm search repo nginx-stable
$ helm install my-release nginx-stable/nginx-ingress
$ helm list
$ helm history my-release
kubectl api-resources --verbs=list -o name | xargs -n 1 kubectl get --show-kind -l

Creating own chart

$ helm create myhelmchart
$ helm install example ./myhelmchart --set service.type=NodePort
$ kubectl api-resources --verbs=list -o name | xargs -n 1 kubectl get --show-kind -l

Manage own chart

  • modify values.yaml
  • modify Chart.yaml - update version
  • validate chane: $ helm lint
  • roll out the changes $ helm upgrade example ./myhelmchart
  • validate the deployment: $ helm history example
  • show history helm history example
  • rollback to previous revision helm rollback example 1
  • show all the revisions in the cluster helm list
  • helm uninstall example