Preparing for Developing Helm Charts (SC104) - a credential by LinuxFoundation
helm get all
helm get manifest
helm get notes
helm get values
# Get all values used by a release (Including defaults)
helm get values --all
helm get hooks
helm show all # Show all chart information
helm show chart # Display Chart definition
helm show readme
helm show values
helm create <chart-name>
In the dependencies map in Chart.yaml
many fields are supported
- The mandatory ones are name, repository and version
condition
: Boolean value that determines whether the dependency should be included or notTags
: A list of Boolean values that determine whether the chart should be included or notimport-values
: Mapping of source values to parent valuesAlias
: alternative name given to the dependency (Used when working with multiple versions of same dependency)
# Conditionally install redis dependency
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.0.0
condition: redis.enabled
# By default if not specified in values, the condition will be ignored meaning dependency will be installed anyway unless explicitly specified as false
helm install . --generate-name # redis dependency is included
# Here redis dependency won't be installed
helm upgrade <release-name> <chart-location> --set redis.enabled=false
dependencies:
- name: mariadb
repository: https://charts.bitnami.com/bitnami
version: 13.1.1
tags:
- backend
- database
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.0.0
tags:
- backend
- cache
# Both dependencies will be installed
helm upgrade --install jaxon .
# backend tag is disabled so that all dependencies aren't installed
# Then only redis is picked for installation by enabling the cache tag
helm upgrade --install jaxon . --set tags.backend=false --set tags.cache=true
- Both conditions and tags can be combined, however conditions always overrides tags
- Used to get
helm release
metadata .Release.Name
and.Release.Namespace
are commonly used.Release.IsUpgrade
and.Release.IsInstall
The first boolean is for whehter there's an upgrade or rollback, the second one is for installation
- Conditional blocks for resource creation
{{- if .Values.configmap.enabled }}
data:
{{- $configmap := printf "configs/%s/%s/config.yaml" .Values.name .Release.Namespace }}
{{ (.Files.Glob $configmap ).AsConfig | indent 2 }}
{{- end }}
- Modifies the scope of the resources being generated
{{- with .Values.jaxon }}
username: {{ .username }}
password: {{ .password }}
{{- end }}
- Used for iterating over list of items and also changes the scope just like with
rhel:
- name: RHCSA
exam: EX200
- name: RHCE
exam: EX294
{{- range .Values.rhel }}
name: {{ .name }}
exam: {{ .exam }}
{{- end }}
- Allow chart developers to intervene at certain points in a release's life cycle
- For each of (install, delete, upgrade and rollback) there's
pre
andpost
hook - There's also a
test
hook that executes whenhelm test
command is invoked helm.sh/weight
annotation can be used when a specific hook type exists multiple times and we need to prioritize one over the other- Multiple hooks can be specified using a comma separated list
helm.sh/hook: pre-rollback,post-rollback
- Charts can be tested with client-side rendering via
helm template
command - In order to have server side validation one can add --validate to the above command or can try running
helm install --dry-run
Can be broken into 2 ways
- Readiness probes with
helm install --wait
which makes return success status only once readiness probe passes - Test hooks and
helm test
command (Test hooks are just pods that do some specific task afterhelm install
is executed)
- You specify that it's a test hook via helm.sh/hook: test annotation