DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Zero to Hero on Kubernetes With Devtron
  • AppOps with Kubernetes and Devtron - The Perfect Fit
  • CI/CD for Kubernetes With Jenkins and Spinnaker

Trending

  • DZone's Article Submission Guidelines
  • Getting Started With NCache Java Edition (Using Docker)
  • Data Processing in GCP With Apache Airflow and BigQuery
  • Being a Backend Developer Today Feels Harder Than 20 Years Ago
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Easily Automate Your CI/CD Pipeline With Kubernetes, Helm, and Jenkins

Easily Automate Your CI/CD Pipeline With Kubernetes, Helm, and Jenkins

Learn how to set up a workflow to automate your CI/CD pipeline for quick and easy deployments using Jenkins, Helm, and Kubernetes.

By 
Eldad Assis user avatar
Eldad Assis
·
Updated by 
Rob Gravelle user avatar
Rob Gravelle
·
Updated Mar. 29, 24 · Tutorial
Like (34)
Save
Tweet
Share
159.0K Views

Join the DZone community and get the full member experience.

Join For Free

Nowadays, it’s critical to get your releases out fast. Gone are the days when developers could afford to wait weeks for their code to be deployed to a testing environment. More than ever, there is great demand for rapid deployment cycles that seamlessly take code from development to production without any hiccups.

Yet, the reality is that developers often find themselves bogged down by the complexities of infrastructure management and the tediousness of manual deployment processes. They crave a solution that allows them to focus solely on their code, leaving the intricacies of deployment to automation.

That's where Continuous Integration and Continuous Deployment (CI/CD) pipelines come in. These automated workflows streamline the entire deployment process, from code compilation to testing to deployment, enabling developers to deliver updates at lightning speed. However, implementing a robust CI/CD pipeline has historically been challenging, particularly for organizations with legacy applications.

Why Kubernetes for Deployment?

This is where Kubernetes, the leading container orchestration platform, shines. Kubernetes has revolutionized the deployment landscape by providing a scalable and flexible infrastructure for managing containerized applications. When combined with Helm, the package manager for Kubernetes, developers gain a powerful toolkit for simplifying application deployment and management.

In this article, we delve into the intricacies of setting up a fully automated CI/CD pipeline for containerized applications using Jenkins, Helm, and Kubernetes. We'll walk you through the process of configuring your environment, optimizing your pipeline for efficiency, and provide a practical template for customizing your own deployment workflows. By the end of this guide, you'll be equipped with the knowledge and tools necessary to accelerate your software delivery cycles and stay ahead in today's competitive landscape. Let's dive in!

Automating CI/CD Pipeline Setup

This 6-step workflow will easily automate your CI/CD pipeline for quick and easy deployments using Jenkins, Helm, and Kubernetes.

In order to get familiar with the Kubernetes environment, I have mapped the traditional Jenkins pipeline with the main steps of my solution.

Jenkins Pipeline with main steps of solution

Note: This workflow is also applicable when implementing other tools or for partial implementations.

Setting Up the Environment

Configure the Software Components

Before you create your automated pipeline, you need to set up and configure your software components according to the following configuration:

Software Components

Recommended Configuration

A Kubernetes Cluster

  • Set up the cluster on your data center or on the cloud.

A Docker Registry

  • Find a solution for hosting a private Docker registry.
  • Consider requirements like privacy, security, latency, and availability when choosing a solution.

A Helm Repository

  • Find a solution for hosting a private Helm repository.
  • Consider requirements like privacy, security, latency, and availability when choosing a solution.

Isolated Environments

  • Create different namespaces or clusters for Development and Staging
  • Create a dedicated and isolated cluster for Production

Jenkins Master

  • Set up the master with a standard Jenkins configuration.
  • If you are not using slaves, the Jenkins master needs to be configured with Docker, Kubectl, and Helm.

Jenkins Slave(s)

  • It is recommended to run the Jenkins slave(s) in Kubernetes to be closer to the API server which promotes easier configuration.
  • Use the Jenkins Kubernetes plugin to spin up the slaves in your Kubernetes clusters.


Prepare Your Applications

Follow these guidelines when preparing your applications:

  • Package your applications in a Docker Image according to the Docker Best Practices.
  • To run the same Docker container in any of these environments: Development, Staging or Production, separate the processes and the configurations as follows:
    • For Development: Create a default configuration.
    • For Staging and Production: Create a non-default configuration using one or more:
      • Configuration files that can be mounted into the container during runtime.
      • Environment variables that are passed to the Docker container.

The 6-Step Automated CI/CD Pipeline in Kubernetes in Action

General Assumptions and Guidelines

  • These steps are aligned with the best practices when running Jenkins agent(s).
  • Assign a dedicated agent for building the App, and an additional agent for the deployment tasks. This is up to your good judgment.
  • Run the pipeline for every branch. To do so, use the Jenkins Multibranch pipeline job.

The Steps

  1. Get code from Git
    1. Developer pushes code to Git, which triggers a Jenkins build webhook.
    2. Jenkins pulls the latest code changes.
  2. Run build and unit tests
    1. Jenkins runs the build.
    2. Application’s Docker image is created during the build.- Tests run against a running Docker container.
  3. Publish Docker image and Helm Chart
    1. Application’s Docker image is pushed to the Docker registry.
    2. Helm chart is packed and uploaded to the Helm repository.
  4. Deploy to Development
    1. Application is deployed to the Kubernetes development cluster or namespace using the published Helm chart.
    2. Tests run against the deployed application in Kubernetes development environment.
  5. Deploy to Staging
    1. Application is deployed to Kubernetes staging cluster or namespace using the published Helm chart.
    2. Run tests against the deployed application in the Kubernetes staging environment.
  6. [Optional] Deploy to Production
    1. The application is deployed to the production cluster if the application meets the defined criteria. Please note that you can set up as a manual approval step.
    2. Sanity tests run against the deployed application.
    3. If required, you can perform a rollback.

Create Your Own Automated CI/CD Pipeline

Feel free to build a similar implementation using the following sample framework that I have put together just for this purpose:

  • A Jenkins Docker image for running on Kubernetes.
  • A 6-step CI/CD pipeline for a simple static website application based on of official nginx Docker image.

Conclusion

Automating your CI/CD pipeline with Jenkins, Helm, and Kubernetes is not just a trend but a necessity in today's fast-paced software development landscape. By leveraging these powerful tools, you can streamline your deployment process, reduce manual errors, and accelerate your time-to-market.

As you embark on your journey to implement a fully automated pipeline, remember that continuous improvement is key. Regularly evaluate and optimize your workflows to ensure maximum efficiency and reliability. With the right tools and practices in place, you'll be well-equipped to meet the demands of modern software development and stay ahead of the competition.

Continuous Integration/Deployment Kubernetes Jenkins (software) Pipeline (software) Docker (software) application

Opinions expressed by DZone contributors are their own.

Related

  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Zero to Hero on Kubernetes With Devtron
  • AppOps with Kubernetes and Devtron - The Perfect Fit
  • CI/CD for Kubernetes With Jenkins and Spinnaker

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: