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.

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


To install helm, use the following command: 

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


To create a helm chart, use the following command:

helm create chart-name

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

  • 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:


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:


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:


Access the EXTERNAL-IP to see the following results:

Result

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


Feel free to share your thoughts in the comments!

Comments

Popular posts from this blog

Kubernetes Practice Series

NodeJS Practice Series

Docker Practice Series

React Practice Series

Sitemap

Setting up Kubernetes Dashboard with Kind

Explaining Async/Await in JavaScript in 10 Minutes

Create API Gateway with fast-gateway

Deploying a NodeJS Server on Google Kubernetes Engine

What is react-query? Why should we use react-query?