DEPLOYING-A-REACT-APPLICATION-ON-NGINX-WEBSERVER-IN-K8S-CLUSTER-USING-HELM-ON-AWS
What is Helm?
Helm is a tool that streamlines installing and managing Kubernetes applications. Helm helps us to install software, Automatically install software dependencies, Upgrade software, Configure software deployments, Fetch software packages from repositories.
What are helm charts?
Helm Charts help you define, install, and upgrade even the most complex Kubernetes. They consist of YAML configuration files and templates that are rendered in the Kubernetes manifest files.
This is the basic directory structure of the chart:
These directory and file have their respective functions:
- charts/: Chart dependencies can be placed in the directory.
- templates/: This directory contains template files that are combined with configuration values and rendered into Kubernetes manifests.
- Chart.yaml: This file consists the information about the chart, such as chart name and version, maintainer information, a relevant website, and search keywords.
- LICENSE: A license for charts
- README.md: A readme file with information for users of the chart.
- values.yaml: This file stores the values that are used in the chart
How does helm work?
Helm merges the templates and the values which are provided by us and deploy the application in the Kubernetes cluster. In previous versions of Helm, it required a component called tiller
installed on the cluster. That component is no longer needed so Helm is now easier to install and use.
Let me show with an example.
We are going to deploy a basic react application on the Nginx server on Kubernetes with helm on AWS cloud.
I am creating an image that consists of react app running on an Nginx server.
Creating a Dockerfile for deploying the react app running on an Nginx server.
Now, The image is ready to work in Kubernetes.
Let’s, Start with Helming.
The following link will guild you on how to install helm.
https://helm.sh/docs/intro/install
To list the helm
helm list
Below, I created directories as a helm chart consists.
Created a directory named reactapp which consists of files called Chart.yml, vaules.yml, and a templates directory. The C should we capital of Charts file. The template's directory consists of two files “pod.yml” and “servicereact.yml” which consists of code for launching the react application on the Nginx server + exposing the Nginx server.
The charts file is as follow:
Charts.yml consists of the versions of the app.
Now, Let’s get to the template directory.
Below is the “pod.yml” file which will launch a pod of React application with Nginx server with the image we create above.
Here comes the “servicereact.yml” file which will be responsible for exposing the pod.
The values.yml for the above template files is as follows :
The Helm chart (package) is ready to install.
Let’s launch an application using the above chart.
helm install YOUR-APP-NAME YOUR-APP-PATH
To view the helm charts :
helm list
As you can see the app is deployed on the Kubernetes cluster
Now, let's upgrade the application with an exposed port.
helm upgrade YOUR-APP-NAME YOUR-APP-PATH
Our application is exposed to port “30588”
kubectl get svc
To check the application if it’s running or not take the ec2-public and the above-exposed port.
We have successfully deployed a react application on Nginx server on Kubernetes with helm on AWS Cloud
Happy Helming 😃😃
Keep Learning !! Keep Sharing !!
✔️If any quires you can reach out to me at LinkedIn: https://www.linkedin.com/in/suyogshinde/