Learn How to Deploy NGINX on Kubernetes Using Helm Chart
Tags: helm, kubernetes, tutorial, devops
Published: 2023-03-08 09:16:36

Deploying NGINX on Kubernetes using the Bitnami Helm Chart simplifies the deployment of the popular web server on a Kubernetes cluster. The Bitnami NGINX Helm Chart includes a single replica deployment of NGINX and a service to expose it to other Kubernetes resources. By using the Bitnami Helm Chart, you don't need to worry about configuring NGINX from scratch, and you can take advantage of the additional features and security patches provided by Bitnami. After installing the Helm chart, you can create Kubernetes ingress resources to route traffic to your services and take advantage of NGINX's capabilities as a reverse proxy and load balancer. Overall, using the Bitnami Helm Chart can help you deploy NGINX on Kubernetes more quickly and with less configuration.

In this tutorial, I'll show you how to deploy the NGINX helm chart on Kubernetes using a CD tool. 

## Prerequisites
- Free [Harness cloud account](https://app.harness.io/auth/#/signup/?module=cd&utm_source=internal&utm_medium=social&utm_campaign=devadvocacy&utm_content=pavan_nginx_article&utm_term=get-started) (on-premise) 
- A Kubernetes cluster access to deploy our Helm chart. You can use [Minikube](https://minikube.sigs.k8s.io/docs/start/) or [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) for a cluster access. 
- Docker installed. Preferably [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/). 

## Tutorial
To deploy the [Bitnami NGINX Helm chart](https://bitnami.com/stack/nginx/helm), you need a continuous delivery platform, and we are making use of a best-in-class tool, Harness. 

Signup to Harness and login to your account. 
![Signup to Harness CD](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr754bdw0ivmto44in4e.png)

Next, create a project
![project creation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gql2lzh4e2lygkzmqvy4.png)

Add details for the project, name it as per your wish.
![name project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdwrskpybuhk3zza5dbt.png)

Invite collaborators if you want to your CD project.
![Invite collaborators](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oqb2s0enpttvpoaz8fv.png)

Select the Continuous Delivery module for the project.
![cd module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/up6y6f3ytrqxzdpblx9p.png)

Start your CD journey from here
![CD journey](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6sne7kzfi1n0ss46fwq.png)

Select your deployment type and click on other deployment types. [We are focused on Helm deployment]
![deployment type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wq7dcscbllv81k4gz886.png)

Start creating a pipeline for your project.
![pipeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xn2svht358e62q1m1ev.png)

Add details of the pipeline
![pipeline details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkgyevo7r63xxaazkxgr.png)

Select 'Deploy' as stage
![deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb7zrq0ms1z95pwrl0pi.png)

Select the deployment type as Native Helm
![native helm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16a8j849emshg1dib7w0.png)

Create a service for the project
![service details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeoz20cbxki8pgtprr7u.png)

![adding service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/834bugswfnilowkrsl1v.png)

Add manifest details, select Helm Chart
![manifest details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9v0qu6gryeuwmcasjumb.png)

Select HTTP Helm
![Helm chart store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/difu3p0mzrqxo0n97hou.png)

Specify the Helm chart store 
![Helm store details update](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zkdyiqirthk1d6ojuh4a.png)

Create a new HTTP Helm Repo Connector
![HTTP Helm Repo Connector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x51qxnyg4l289bj4u5oj.png)

Add the Helm repo connector details
![repo connector details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8tip5vvk1l1gv34t3nf.png)

Connect the Helm repo with the Harness Delegate.
![connect with Harness delegate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbt8syy6sslglvsmsqu1.png)

So, what is Harness Delegate?
A Delegate is a service that runs on your infrastructure to execute tasks on behalf of the Harness platform.

Now, you need to install this Harness Delegate on your Kubernetes cluster.

Make sure you have a cluster access from any cloud provider.
Nothing to worry about if you don't have access to any cluster access. We will make use of Minikube. 

Install Minikube on your local machine by following this [link](https://minikube.sigs.k8s.io/docs/start/).

Once the installation is complete, start the Minikube cluster with the following command.

```
minikube start
```
You should see a successful output as shown below,
![minikube started](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bea3dsmumzfa63s9durf.png)

It is time to install our Harness Delegate
![Delegate setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4urywjbo67th7i5wz6ce.png)

Run the commands as shown in the installation process
![delegate installation process](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkvwi2581zagbeilqoxr.png)

Once done, verify if the Delegate has been installed successfully.
![delegate successful](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gs4e08czahdddlemglyk.png)

Let's go back to the steps where we stopped previously (before installing the Harness Delegate).
Now you should see the Delegate we just installed. Select the same and continue.
![see delegate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bg6ifewlyh9a35k2ytul.png)

You should see a successful connection between the helm repo and our Delegate. 
![delegate connection successful](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l63rlj6jyff0unpgisfi.png)

Next, add the manifest details as shown
![add manifest details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/voehnuasadgnzdvan5k3.png)

You should see the manifest details we added
![manifest details added](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7dliu307jeka7n66wz4c.png)

You should see the service added; click continue.
![service added](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0uoq0zsatffldzhs872p.png)

Add new environment as pre-prod
![add environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yieyirlylmb00ufx2g68.png)

![preprod environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dhzbspbf34tcpkx5z8o.png)

Similarly, add a new infrastructure
![add a new infrastructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhkgu4yvkwqii1qhnar7.png)

Select 'Kubernetes' here.
![adding infra](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4cbq4a41ggrm9pz3mul.png)

Under cluster details, select the connector and add the cluster details. 
![infra details for kube](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/094fkyqqmswg9gmij21k.png)

Let's connect our infrastructure with our Delegate.
![infrastructure with our Delegate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/haz1wffnsrebdncpluw7.png)

![connection of infra](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4gjqk3xcg4zpi56okcys.png)

Make sure the connection is successful
![success with connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bjw2mpshoc7iskw7m4l.png)

You should see the cluster details and connector in the infrastructure 
![cluster details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k1f9asanvo8ehhcizop.png)

You should see the infrastructure we just added.
![Kube infra added now](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1t8p84yharythupzrwqy.png)

Click continue and you will go to the execution step where we should select the deployment type. We will select 'Rolling'.
![select the deployment type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n69fp1e845yyzkv307r5.png)

Finally, this is how our Helm chart deployment looks like. 
![Helm chart deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08h89um1gug0vo0f5mqa.png)

Save the pipeline and run it.
![Save the pipeline](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9z3t79ppx290psc16fb.png)

You should see a successful execution of all the steps. 
![successful execution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlu0x7cnu3sgqp9nnlb6.png)

Let's get to the console view for more clarity.
![Harness console view](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycei10cxe36lr7o2xup6.png)

Let's verify if the NGINX deployment is done properly using the command

```
kubectl get deployment
```
You should see the following output
![nginx deployment status](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xsv2qulswvh3zvv9bt9n.png)

Let's expose the deployed NGINX to the outside world and see if we can access it.
![nginx local](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vxypyjpaf0le1kdf9ma.png)

As you can see, the external IP is pending.

We can expose the external IP using the below minikube command

```
minikube tunnel
```
You should see the following output
![minikube tunnel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7myg9i7198yndxc68a9p.png)

Now, open a new terminal window and run the following command

```
kubectl get service
```
You should see the external IP now.
![service exposure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gg1mejkox7ygqpx4kgi8.png)

We can access the NGINX using the `externalip:port`

![nginx service on local](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9n66e0icauuxlahgiaq.png)

Congratulations! We successfully deployed an NGINX helm chart on Kubernetes using Harness CD module.

This way, you can easily deploy any of the [Helm charts listed here](https://bitnami.com/stacks/helm) on Kubernetes using the Harness Continuous Delivery module.