Using Helm
Deploying Applications with Public Charts
As explained earlier, Helm deploys applications based on configuration files called Charts. Charts can be prepared on the local machine where the helm command is executed, and Charts published in a repository can also be downloaded and used directly. As a first example of application deployment with Helm, let’s look at how to use a Chart published in a repository.
As mentioned earlier, public Charts can be searched on a site called Artifact Hub. In Artifact Hub, Charts are displayed in the format <repository name>/<Chart name>/. Charts whose repository name is “stable” or “incubator” are provided by Helm’s official repositories, while Charts with other repository names are provided by third parties. Charts with the same name may be published in different repositories, but be careful because their sources are different.
To install a Chart through a repository, first register the repository that provides the Chart on your local computer. Immediately after installing Helm, no repositories are registered, so even when using Charts provided by an official repository, you need to add the repository.
You can add a repository with the helm repo add <repository name> <URL> command. For example, to add the official bitnami repository, run the following command.
% helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
In Linux environments, repository settings are stored in a directory called .config/helm under the home directory, and the cache of the Chart list published by repositories is stored under .cache/helm/repository in the home directory. This information is also described in the helm command help displayed by helm -h, so check it if necessary.
% helm -h
The Kubernetes package manager
... omitted ...
| Operating System | Cache Path | Configuration Path | Data Path |
|------------------|---------------------------|--------------------------------|-------------------------|
| Linux | $HOME/.cache/helm | $HOME/.config/helm | $HOME/.local/share/helm |
| macOS | $HOME/Library/Caches/helm | $HOME/Library/Preferences/helm | $HOME/Library/helm |
| Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm |
... omitted ...
After registering a repository, you can search for Charts registered in the repository with the helm search command.
helm search repo [<search keyword>]
If you omit the keyword, all Charts provided by the registered repositories are displayed.
% helm search repo
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/airflow 13.1.5 2.3.4 Apache Airflow is a tool to express and execute...
bitnami/apache 9.2.3 2.4.54 Apache HTTP Server is an open-source HTTP serve...
bitnami/argo-cd 4.1.3 2.4.11 Argo CD is a continuous delivery tool for Kuber...
... omitted ...
Repository information is cached locally, so it can become outdated over time. Running the helm repo update command updates the repository cache to the latest version.
% helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
In Helm, deploying an application using a Chart is called “install,” and an installed application instance is called a “Release.” Each instance has a unique name, called the Release name. Release names must not overlap, and you can create multiple Releases from the same Chart.
To install or deploy an application using a Chart published in a repository, run the helm install <Release name> <Chart name> command.
The following example deploys the Chart bitnami/wordpress with the Release name wordpress. If deployment succeeds, NOTES are displayed, including notes about the application.
% helm install wordpress bitnami/wordpress
NAME: wordpress
LAST DEPLOYED: Thu Sep 15 00:33:19 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: wordpress
CHART VERSION: 15.2.2
APP VERSION: 6.0.2
** Please be patient while the chart is being deployed **
Your WordPress site can be accessed through the following DNS name from within your cluster:
wordpress.default.svc.cluster.local (port 80)
To access your WordPress site from outside the cluster follow the steps below:
1. Get the WordPress URL by running these commands:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace default -w wordpress'
export SERVICE_IP=$(kubectl get svc --namespace default wordpress --include "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
echo "WordPress URL: http://$SERVICE_IP/"
echo "WordPress Admin URL: http://$SERVICE_IP/admin"
2. Open a browser and access WordPress using the obtained URL.
3. Login with the following credentials below to see your blog:
echo Username: user
echo Password: $(kubectl get secret --namespace default wordpress -o jsonpath="{.data.wordpress-password}" | base64 -d)
Deployment is performed against the current Kubernetes context, so if you want to use a specific namespace, configure the context in advance with commands such as kubectl config.
Also, the bitnami/wordpress Chart uses persistent storage, so a default Storage Class must be configured in the cluster. How to configure a Storage Class depends on the Kubernetes cluster you use, so check separately how to create a Storage Class for Kubernetes.
You can check the deployed Release list with the helm list command.
% helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
wordpress default 1 2022-09-15 00:33:19.166716 +0900 KST deployed wordpress-15.2.2 6.0.2
If you check the created Pods with the kubectl get pods command, you can see that two Pods, wordpress-d5c8dffb7-bws4d and wordpress-mariadb-0, were created. The d5c8dffb7-bws4d part may differ depending on the environment.
% kubectl get pods
NAME READY STATUS RESTARTS AGE
wordpress-d5c8dffb7-bws4d 0/1 CrashLoopBackOff 5 (2m21s ago) 7m33s
wordpress-mariadb-0 1/1 Running 0 7m33s
… In progress. Writing stopped because an error occurred in the Pod …