helm create portail-web
This will generate a helm chart structured like:
portail-web/
Chart.yaml
values.yaml
charts/
templates/
...
- templates/ contains the templated kubernetes objetcs
- values.yaml contains the default values of the chart
- Chart.yaml contains a description of the chart
- charts/ directory is used to define sub-charts
- .helmignore to list the files not included in the helm chart package
helm install test ./portail-web -n test-namespace --dry-run --values=values.yml --wait
# <name> <helm chart> [namespace] [test debug] [new values] [synchronous]
helm list
helm get manifest test
helm upgrade test ./portail-web -n test-namespace --values=new-values.yml
helm delete test
helm repo add helm_demo https://my.artifactory.priv:443/artifactory/helm_demo --insecure-skip-tls-verify
# <repo_dir> <repo_url> [skipt tls verification]
$ helm search repo helm_demo
NAME CHART VERSION APP VERSION DESCRIPTION
helm_demo/default_chart 0.0.2 1.16.0 A Helm chart for Kubernetes
helm_demo/my-nginx 0.0.2 1.16.0 A Helm chart for Kubernetes
# Using repo name
helm install test-name helm_demo/my-nginx --version 0.0.2
# Using a full .tgz url
helm install test-name https://my.artifactory.priv:443/artifactory/helm_demo/my-nginx-0.0.2.tgz --insecure-skip-tls-verify
helm package ./portail-web --destination /tmp
# Successfully packaged chart and saved it to: /tmp/portail-web-0.1.0.tgz
curl -u${ARTIFACTORY_USER}:${ARTIFACTORY_PASSWORD} -k \
-T /tmp/${chart_name}-${chart_version}.tgz \
"${repo_url}/${chart_name}-${chart_version}.tgz" # If api_key, use -H "X-JFrog-Art-Api:${ARTIFACTORY_API_KEY}"
helm repo remove helm_demo
- Leverage automatic rolling updates by defining deployments.
- If you change the values and execute
helm upgrade
, it won't update the pods unless there is a change in the image or a variable in the spec of the pod definition of the deployment. - If you want the pod to automatically redeploy when a configMap or secret is updated, you need to add an annotation in the
.spec.template.metadata
section of the deployment
withchecksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
configmap.yaml
existing in the templates of the helm chart - If you always want rolling update, you can use this annotation in the deployment
rollme: {{ randAlphaNum 5 | quote }}
# values.yaml
COUCHBASE_CLUSTER_IP: "couchbase://couchbase-mock.{{ .Release.Namespace }}.svc.cluster.local"
# templates/configmap.yaml.tpl
{...}
pepit_server_api_couchbase_cluster_ip: {{ tpl .Values.COUCHBASE_CLUSTER_IP . }}
# This will evaluate `.Release.Namespace` and generate this:
{...}
pepit_server_api_couchbase_cluster_ip: couchbase://couchbase-mock.my-namespace.svc.cluster.local
- simple if
data:
food: {{ .Values.favorite.food | upper | quote }}
{{ if eq .Values.favorite.drink "coffee" }}
mug: true
{{ end }}
generates
data:
food: "PIZZA"
**
mug: true
with the '*' character representing a space
- if with - prefix
data:
food: {{ .Values.favorite.food | upper | quote }}
{{- if eq .Values.favorite.drink "coffee" }}
mug: true
{{- end }}
The - prefix will remove all the space on the left side, it generates
data:
food: "PIZZA"
mug: true
This is very useful to have a clean yaml file without extra lines
Instal or update in one command
helm upgrade --install <release name> --values <values file> <chart directory>
- templating and variables:
- conditions and loops:
- Best practices: