Helm Integration
Kubernetes Cluster: Helm Integration
Find Helm Charts
Helm can search both the public Artifact Hub and repositories configured locally on the Helm client.
1Search Artifact Hub
Use helm search hub to find publicly available charts across community repositories.
helm search hub wordpress
Use helm search repo to search only repositories already added to the local Helm client.
Manage Helm Repositories
Helm 3, which the source notes is used starting with Kubernetes 1.18.10, does not include a default chart repository. Add the repositories you need manually.
helm repo add bitnami https://charts.bitnami.com/bitnami
List the configured repositories:
helm repo list
Refresh local repository metadata before searching or installing charts:
helm repo update
Install a Helm Package
The basic helm install command requires a release name and the chart to install. Chart values can be customized during the installation.
helm install --set wordpressBlogName='My Blog!' mywordpress bitnami/wordpress
- Release name — in this example,
mywordpress. - Chart — in this example,
bitnami/wordpress. - Custom value —
--set wordpressBlogName='My Blog!'.
--generate-name option.
Verify the WordPress Example
The WordPress chart also requires persistent storage. If storage was not enabled during cluster installation, it can be added through the Kubernetes Cluster Configuration add-on.
Retrieve the WordPress service URL and administrator password from Kubernetes:
export SERVICE_IP=$(kubectl get svc --namespace default mywordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
printf "WordPress URL: http://$SERVICE_IP/\nWordPress Admin URL: http://$SERVICE_IP/admin\nUsername: user\nPassword: $(kubectl get secret --namespace default mywordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)\n"
Manage Helm Applications
Helm provides commands for checking release status and configuration, changing values, upgrading releases, restoring previous revisions, and removing applications.
View general Helm help or help for a specific command:
helm help
helm {command} --help
Check the current state and deployment information for a release:
helm status mywordpress
Configuration can be supplied with --set or in a YAML file with --values / -f. When several overrides conflict, later values take priority, and --set has higher precedence.
Review a chart’s default values:
helm show values bitnami/wordpress | less
Upgrade a Release
Use helm upgrade to move a release to a newer chart version or modify its configuration. Helm attempts to change only the resources affected by the new configuration.
--reset-values flag can reset custom values and return to the values built into the chart.
For the WordPress chart used in the source example, the existing WordPress and MariaDB passwords must be supplied during upgrade. First retrieve them from Kubernetes secrets:
export WORDPRESS_PASSWORD=$(kubectl get secret --namespace "default" mywordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)
export MARIADB_ROOT_PASSWORD=$(kubectl get secret --namespace "default" mywordpress-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 --decode)
export MARIADB_PASSWORD=$(kubectl get secret --namespace "default" mywordpress-mariadb -o jsonpath="{.data.mariadb-password}" | base64 --decode)
Then upgrade the release while preserving the current passwords:
helm upgrade --set wordpressPassword=$WORDPRESS_PASSWORD,mariadb.auth.rootPassword=$MARIADB_ROOT_PASSWORD,mariadb.auth.password=$MARIADB_PASSWORD mywordpress bitnami/wordpress
For many custom parameters, a values file is easier to maintain:
wordpressPassword: %WP_PASS%
mariadb:
auth:
rootPassword: %DB_ROOT_PWD%
password: %DB_PWD%
cat values-template.yaml | sed "s/%WP_PASS%/$WORDPRESS_PASSWORD/g" | sed "s/%DB_ROOT_PWD%/$MARIADB_ROOT_PASSWORD/g" | sed "s/%DB_PWD%/$MARIADB_PASSWORD/g" > values.yaml helm upgrade -f values.yaml mywordpress bitnami/wordpress
Check the custom values currently stored with a release:
helm get values mywordpress
History and Rollback
Each installation, upgrade, or rollback creates a revision. Use Helm history to identify revision numbers:
helm history mywordpress
Rollback to a selected revision when an upgrade or configuration change does not work as expected:
helm rollback mywordpress 1
Uninstall a Release
Remove a release from the Kubernetes cluster with:
helm uninstall mywordpress
Use --keep-history if the deletion record should remain in Helm history. List currently deployed releases with helm list.
