Helm-1: Deploying a Microservice App into Google Kubernetes Engine Using the Helm Chart

We will install Helm on the Ubuntu server, and then create and manage Helm charts. We will deploy the Java microservices app into the GCP Kubernetes Cluster by using the helm chart. Also, we will create a NOTES.txt, and assign image and repository values to “web-app.yaml” file from the “values.yaml” and “chart.yaml” files. Finally, we will observe the Kubernetes cluster and uninstall the chart release from the Kubernetes cluster by using helm commands. We will do these practically step by step in this article.

Cumhur Akkaya
11 min readNov 26, 2023

The article will cover the following topics:

1. Prerequisite
2. Installing Helm
3. Creating a Helm Chart
4. Adding Our Kubernetes Manifest Files to the Chart
5. Creating a NOTES.txt
6. Connecting to Google Kubernetes Engine (GKE) Cluster
7. Assigning Image and Repository Values to Web-app.yaml File from the Values.yaml and Chart.yaml Files
8. Installing The Chart into the GKE Cluster and Printing Out
9. Uninstalling the Release Created by The Chart
10. As a result
11. Next post: “Helm-2: Using Artifacthub.io, Chart Museum Repository, and GitHub as a Chart Repository”
12. References

If you like the article, I will be happy if you click the Medium Follow button to encourage me to write more, and not miss future articles.

Your clapping, following, or subscribing helps my articles to reach a broader audience. Thank you in advance for them.

1. Prerequisite

  1. Running a Kubernetes cluster.

2. Installing Helm

Install the helm into Ubuntu with the following commands. For installations for other operating systems, you can see this link.

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm version

Note: For detailed information about Helm and its installation, you can see the article below. I installed Helm, and then created and managed Helm charts by integrating the Helm repository into Amazon Simple Storage Service (Amazon S3).

3. Creating a Helm Chart

For this article, we’ll create a simple chart called my-vet-chart, and then we'll create some templates inside of the chart. We will create a Helm Chart with the following command;

$ helm create my-vet-chart

Helm charts are structured like this;

Now, we shall take a brief look at Helm charts; (1)

The templates/ directory is for template files. When Helm evaluates a chart, it will send all of the files in the templates/ directory through the template rendering engine.

  • Most files in templates/ are treated as if they contain Kubernetes manifests,
  • The NOTES.txt is one exception,
  • But files whose name begins with an underscore (_) are assumed to not have a manifest inside. (2)

The values.yaml file is also important to templates. This file contains the default values for a chart. These values may be overridden by users during helm install or helm upgrade.

The Chart.yaml file contains a description of the chart. You can access it from within a template.

The charts/ directory may contain other charts (which we call subcharts). Later in this guide we will see how those work when it comes to template rendering.

Now, we shall take a look at the mychart/templates/ directory;

  • NOTES.txt: The "help text" for your chart. This will be displayed to your users when they run helm install.
  • deployment.yaml: A basic manifest for creating a Kubernetes deployment
  • service.yaml: A basic manifest for creating a service endpoint for your deployment
  • _helpers.tpl: A place to put template helpers that you can re-use throughout the chart. That file is the default location for template partials. For more information on using and declaring of templates, you can refer to this link.

4. Adding The Kubernetes Manifest Files to the Chart

Now, remove the contents of the “templates/” directory with the following command. We’ll create our own NOTES.txt.

$ rm -rf templates/*

Folder of templates is now empty;

5. Creating a NOTES.txt

Creating a NOTES.txt file is strongly recommended by Helm documentation, though it is not required. (3)

At the end of a helm install or helm upgrade, Helm can print out a block of helpful information for users. For this we use NOTES.txt file.

To add installation notes to your chart, simply create a templates/NOTES.txt file. This file is plain text. Let’s create a simple NOTES.txt file in the templates folder, as a the following text;

Thank you for installing {{ .Chart.Name }}.
Your release is named {{ .Release.Name }}.

To learn more about the release, try:
$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}

{{ .Chart.Name }} and {{ .Release.Name }} are predefined values in Helm. When we type them directly without defining them anywhere, the relevant values are automatically retrieved from the system.

6. Connecting to Google Kubernetes Engine (GKE) Cluster

Firstly, I have to connect to my cluster in GCP via command-line. I configured kubectl command line access by running the following command in VSCode terminal:

Now I am connected to my Google Kubernetes Engine (GKE) Cluster from my VSCode terminal and I can run kubectl commands;

Likewise, I can see that my cluster has been formed via Google Cloud console;

7. Assigning Image and Repository to Values Web-app.yaml Files from the Values.yaml and Chart.yaml Files

My web application is set to pull the image file from DockerHub, as seen in Figure below.

Even if the “web-app.yaml” file is like this above, our application will be installed if we run the “helm install” command. However, if we want, we can automatically extract the “Image and Repository” values from the values.yaml and Chart.yaml files by making the following settings:

  • Invalues.yamlfile; I assigned the “repository” value as cumhurakkaya/vet-clinic.
  • InChart.yamlfile; I assigned the “appversion” value as “v.1.0.0” .
  • Inweb-app.yamlfile; I assigned the “image” by pulling values.yaml and Chart.yaml files.

Note: We use curly brackets in web-app.yamlfile, as seen figure below because it is written in the Go language.

When I run “helm install” command, web-app.yamlfile will pull the following values from the values.yaml and Chart.yaml files. If there is no “VetClinic” version in DockerHub, it will use the image in the “v.1.0.0" version by pulling it from “cumhurakkaya/vet-clinic” repository in DockerHub.

Image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
=
Image: cumhurakkaya/vet-clinic:VetClinic | cmakkaya/veterinary-clinic:v.1.0.0

8. Installing The Chart into the GKE Cluster and Printing Out

With this simple template, we now have an installable chart. And we can deploy Kubernetes manifest yaml files to Google Kubernetes Engine (GKE) with the “helm install” command, this command installs a chart archive; “my-vet-chart”. It will create a release named “microservices-with-helm” in GKE cluster.

$ helm install microservices-with-helm ./my-vet-chart

We can see “microservices-with-helm”release by using “helm ls” command;

We can see pods, services, and nodes that we created by using “kubectl” command;

Also, we can see pods, services, and nodes that we created by using Google Cloud console;

We can see the running version of our application in the web by clicking on the “external load balancer endpoint IP” address in figure above.

To learn more about the helm release, we can run the following commands;

 helm status microservices-with-helm
helm get all microservices-with-helm

We can see the actual template that was loaded. The helm get manifest command takes a release name (microservices-with-helm) and prints out all of the Kubernetes resources that were uploaded to the server.

helm get manifest microservices-with-helm

Now, Package the local Helm chart by using the “helm package” command. “helm package” command packages a chart into a versioned chart archive file. That is, 4 Kubernetes manifest yaml files (belonging to the microservices app) in the template folder will package. The “my-vet-chart-0.1.0.tgz” file was created by following the command in the “my-vet-chart” folder, as shown in the Figure below.

cd k8s
helm package ./

The created packaged chart file took its version number and name from the Chart.yaml file, where it is indicated by the sign in the figure below.

We can deploy Kubernetes manifest yaml files to the GKE cluster with the “helm install microservices-with-helm my-vet-chart-0.1.0.tgz” command again using the packaged chart file, as shown in the figure below.

We can see pods, services, and nodes that we recreated by using “kubectl” command, as shown in the figure below.

Note: In this article, we stored the packaged chart file on our local computer. We can use artifacthub.io as a chart file repository. Our charts are stored there. Additionally, we can use our EC2 instance as a Chart repository by setting up a Chart Museum Repository in the AWS EC2 instance.
Moreover, we can also use GitHub, Amazon S3 Bucket, etc. as a repository for Helm Chart. We can deploy Kubernetes manifest yaml files into Kubernetes from these Chart repositories using the packaged chart file. We will do these practically in the next article.

Note: To check the generated manifests of a release without installing the chart, using the following flags; (4)

'--debug' and '--dry-run'
For Example:
helm template --debug # It will test rendering chart templates locally.
helm install --dry-run --debug # We've seen this trick already. It's a great way to have the server render your templates, then return the resulting manifest file.

9. Uninstalling the Release Created by The Chart

Now we can uninstall the release that we created by using the following command;

helm uninstall microservices-with-helm ./my-vet-chart

We can see that our pods and services have been deleted with the kubectl command;

10. As a result

In this article, we stored the charts we created on our local computer. We can use artifacthub.io as a chart repository. Our charts are stored there. Additionally, we can use our EC2 instance as a Chart repository by setting up a Chart Museum Repository in the AWS EC2 instance.
Moreover, we can also use GitHub, Amazon S3 Bucket, GCS bucket, Azure Blob Storage, etc. as a repository for Helm Chart. We will do these practically in the next article.

I also explained practically using S3 Bucket as a Chart repository in this article:

In this article, we installed Helm on the Ubuntu server in GCP, and then created and managed a Helm chart. We deployed the Java microservices app into the GCP Cluster by using the helm chart. We created a NOTES.txt, and assigned “image and repository values” web-app.yaml files from the values.yaml and chart.yaml files. Finally, we observed the Kubernetes cluster and uninstalled the chart release from the Kubernetes cluster by using helm commands.

Also, you can see the commands required to manage the Helm in my “The Necessary Commands to Manage The Helm” article with some examples. You can think of this article as a kind of Helm cheatsheet.

If you liked the article, I would be happy if you click on the Medium Following button to encourage me to write and not miss future articles.

Your clap, follow, or subscribe, they help my articles to reach the broader audience. Thank you in advance for them.

For more info and questions, please contact me on Linkedin or Medium.

11. Next post

In the next post, Helm-2: Deploying an App into GKE via the Helm by Using GitHub as a Helm Chart Repository, as shown in the Figure below. We will learn detailed information about the Chart Repository. Then, we will install the Chart Museum Repository into the AWS EC2 instance, and use it as a Chart Repository. Then, we will use a GitHub account as a Chart Repository.

We will do them practically and step by step.

Helm-2: Deploying an App into GKE via the Helm by Using GitHub as a Helm Chart Repository

Happy Clouding…

Don’t forget to follow my LinkedIn or Medium account to be informed about new articles.

--

--

Cumhur Akkaya

✦ DevOps/Cloud Engineer, ✦ Believes in learning by doing, ✦ Dedication To Lifelong Learning, ✦ Tea and Coffee Drinker. ✦ Linkedin: linkedin.com/in/cumhurakkaya