Deploying a sample application using Helm charts

Deploying a sample application using Helm charts

Introduction

In this article, we'll walk through a practical demonstration of deploying a sample web application on Kubernetes using Helm charts. Helm charts serve as templates for Kubernetes deployments, streamlining the process of application management. We'll deploy a basic web application called "HelloWorld" using Helm charts to showcase how straightforward it is to manage Kubernetes deployments with Helm.

Prerequisites

Before getting started, ensure you have the following prerequisites set up:

  • Kubernetes cluster: Set up a Kubernetes cluster using Minikube or any other preferred method. Not to forget to start it also.

  • Helm: Install Helm on your local machine following the instructions provided in the Helm documentation.

Step 1: Creating a Helm Chart

  • Open your terminal and navigate to a directory where you'd like to create your Helm chart.

  • Run the following command to create a new Helm chart named "helloworld":

      helm create helloworld
    
  • Navigate into the "helloworld" directory:

      cd helloworld
    

Step 2: Customizing Chart Values

  • Open the values.yaml file in your preferred text editor.

  • Modify the values to specify details about our deployment. For example, you can set the Docker image, port, and any environment variables needed for your web application. Example customization:

      image:
        repository: nginx
        tag: stable
        pullPolicy: IfNotPresent
      service:
        type: LoadBalancer
        port: 80
    

Step 3: Deploying the Application

  • Once you've customized the values, deploy the application using the following Helm command:

      helm install helloworld ./helloworld
    

    Helm will take care of creating the necessary Kubernetes resources based on our chart, such as pods, services, and deployments.

  • Verify the deployment by running the following command:

      kubectl get pods
    

    You should see the pods for your "HelloWorld" application running.

  • Additionally, retrieve the external IP of the service to access the application:

      kubectl get services
    

Step 4: Accessing the Application

  • Copy the external IP of the service associated with your "HelloWorld" application.

  • Paste the external IP into your web browser's address bar and hit Enter.

  • You should see the default Nginx welcome page, indicating that your web application is successfully deployed and accessible.

Conclusion

Congratulations! You've successfully deployed a sample web application on Kubernetes using Helm charts. By following these steps, you've experienced firsthand how Helm simplifies the process of managing Kubernetes deployments, making application deployment and management more efficient and less complex. With Helm, deploying applications to Kubernetes becomes a streamlined and straightforward process.