๐Ÿš€ Deploying a React.js App Using Helm on Kubernetes: A Step-by-Step Guide with CI/CD ๐Ÿš€

Written by Sivaranjan with sample notes

ยท

2 min read

๐Ÿš€ Deploying a React.js App Using Helm on Kubernetes: A Step-by-Step Guide with CI/CD ๐Ÿš€

In today's fast-paced tech environment, continuous deployment and integration are critical for maintaining competitive advantage. One of the most efficient ways to manage your deployments is through Kubernetes and Helm. Today, I will share how I deployed a React.js app using Helm with CI/CD stages including SCM checkout, SonarQube analysis, Docker build, Docker push, and Kubernetes deployment. Let's dive in! ๐ŸŒŠ

๐ŸŽฏ Objectives

  • Checkout Code from Source Control Management (SCM)

  • Analyze Code Quality with SonarQube

  • Build Docker Image of the React.js app

  • Push Docker Image to a Registry

  • Deploy Application on Kubernetes using Helm

๐Ÿ› ๏ธ Tools Used

  • SCM: GitHub

  • Code Quality: SonarQube

  • Containerization: Docker

  • Container Registry: Docker Hub

  • Orchestration: Kubernetes (K8s)

  • Package Manager: Helm

  • CI/CD: Jenkins

๐Ÿ“‹ Prerequisites

  • A running Kubernetes cluster

  • Helm installed

  • Jenkins for CI/CD pipeline

  • SonarQube server

  • Docker Hub account

๐Ÿ“‚ Step 1: SCM Checkout ๐Ÿ—‚๏ธ

Start by checking out the code from your GitHub repository. This is typically the first step in your Jenkins pipeline.

stage('SCM Checkout') {
    steps {
        git 'https://github.com/your-username/your-repo.git'
    }
}

๐Ÿ” Step 2: SonarQube Analysis ๐Ÿงน

Next, analyze the code quality using SonarQube. This ensures your code adheres to the required standards and is free of critical bugs.

stage('SonarQube Analysis') {
    steps {
        script {
            def scannerHome = tool 'SonarQubeScanner'
            withSonarQubeEnv('SonarQube') {
                sh "${scannerHome}/bin/sonar-scanner"
            }
        }
    }
}

๐Ÿ—๏ธ Step 3: Docker Build ๐Ÿณ

Build the Docker image for the React.js app. This encapsulates your app and its dependencies into a portable container.

stage('Docker Build') {
    steps {
        script {
            docker.build("your-username/your-app:${env.BUILD_ID}")
        }
    }
}

๐Ÿš€ Step 4: Docker Push ๐Ÿ“ค

Push the Docker image to Docker Hub. This makes your image available for deployment.

stage('Docker Push') {
    steps {
        script {
            docker.withRegistry('https://index.docker.io/v1/', 'docker-hub-credentials') {
                docker.image("your-username/your-app:${env.BUILD_ID}").push()
            }
        }
    }
}

๐Ÿ“ฆ Step 5: Deploy on Kubernetes using Helm ๐Ÿ›ณ๏ธ

Finally, deploy your app on Kubernetes using Helm. Helm simplifies the deployment process by managing Kubernetes manifests as charts.

stage('Helm Deploy') {
    steps {
        script {
            sh "helm upgrade --install my-app ./helm-chart --set image.tag=${env.BUILD_ID}"
        }
    }
}

๐ŸŒŸ Conclusion

Deploying a React.js application on Kubernetes using Helm, while incorporating a robust CI/CD pipeline, ensures your application is always up-to-date, reliable, and scalable. Leveraging tools like Jenkins, SonarQube, Docker, and Helm allows for seamless automation and efficient management of your application lifecycle. ๐Ÿš€

By following these steps, you can achieve continuous deployment and integration with minimal manual intervention, allowing your development team to focus on building amazing features and improving code quality. Happy coding! ๐ŸŽ‰


ย