DEV Community

chauhoangminhnguyen
chauhoangminhnguyen

Posted on • Originally published at howtodevez.blogspot.com

Helm for beginer - Deploy nginx to Google Kubernetes Engine

Introduction

Helm is a package manager for Kubernetes, which simplifies the process of deploying and managing applications on Kubernetes clusters. Helm uses a packaging format called charts, which are collections of files that describe a related set of Kubernetes resources.

Helm

Key Components of Helm

  • Charts: Helm packages are called charts. A chart is a collection of files that describe a related set of Kubernetes resources. A single chart might be used to deploy something simple, like a memcached pod, or something complex, like a full web app stack with HTTP servers, databases, caches, and so on.
  • Values: Charts can be customized with values, which are configuration settings that specify how the chart should be installed on the cluster. These values can be set in a values.yaml file or passed on the command line.
  • Releases: When you install a chart, a new release is created. This means that one chart can be installed multiple times into the same cluster, and each can be independently managed and upgraded.

Prerequisites

To get started, you'll need to:

Practical Steps

First, use gcloud to create a cluster like this:

gcloud container clusters create {cluster name} \
  --project {project id} \
  --zone {zone id} \
  --machine-type {machine type id} \
  --num-nodes {number of node}

# ex:
gcloud container clusters create k8s-cluster \
  --project project-id \
  --zone asia-southeast1-a \
  --machine-type e2-micro \
  --num-nodes 1
Enter fullscreen mode Exit fullscreen mode

To install helm, use the following command:

 

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
Enter fullscreen mode Exit fullscreen mode

To create a helm chart, use the following command:

helm create chart-name
Enter fullscreen mode Exit fullscreen mode

After executing, a template is created that includes files like development.yaml, service.yaml, and others, similar to working with Kubernetes. Among these files, pay special attention to values.yaml. The values in this file are bound to the template when Helm is installed. By simply changing these values according to your needs, you can easily modify the deployment configuration.

Next, in the values.yaml file, look for the following information:

image:
  repository: nginx

service:
  type: ClusterIP
  port: 80
Enter fullscreen mode Exit fullscreen mode
  • The repository is a Docker image used for deployment, which you can customize as needed. 
  • The current service type is ClusterIP, using port 80.

Here, you can change the service type to LoadBalancer. Then, install helm chart as follows:
helm install chart

The change to a LoadBalancer service type allows your cloud provider to supply an EXTERNAL-IP. You can then retrieve the EXTERNAL-IP information as follows:

kubectl get all

If you keep the original content of the values.yaml file, you can install helm chart and change the service type to LoadBalancer like this:

helm install chart with type

Access the EXTERNAL-IP to see the following results:

Deployed

Result
To uninstall helm chart and clear up resources, you can use the following command:

Helm uninstall chart

Feel free to share your thoughts in the comments!


If you found this content helpful, please visit the original article on my blog to support the author and explore more interesting content.

BlogspotBlogspotDev.toFacebookX


Some series you might find interesting:

Top comments (0)