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 Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Easily Automate Your CI/CD Pipeline With Jenkins, Helm, and Kubernetes

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

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

Eldad Assis user avatar by
Eldad Assis
·
Mar. 04, 18 · Tutorial
Like (32)
Save
Tweet
Share
154.32K Views

Join the DZone community and get the full member experience.

Join For Free


Developers don’t want to think about infrastructure and why it takes so long to deploy their code to a real testing environment. They just want it up and running!

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

Nowadays it’s critical to get your releases out fast, which requires having an automated CI/CD pipeline that takes your code from text to binaries to a deployed environment. Implementing an automated pipeline in the past has been challenging, especially when dealing with legacy applications. This is where Kubernetes comes in. Kubernetes has revolutionized the way we deploy and manage our containerized applications. Using Helm together with Kubernetes, you gain simplified application deployment.


This article will show you how to prepare and configure your environment to achieve a complete automated CI/CD pipeline for your containerized applications using Jenkins, Helm, and Kubernetes. You will receive tips on how to optimize your pipeline and a working template for customizing your own pipeline.

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

Image title

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.
  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.

Bon voyage for your Kubernetes CI/CD voyage!


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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • SAST: How Code Analysis Tools Look for Security Flaws
  • Public Cloud-to-Cloud Repatriation Trend
  • A Simple Union Between .NET Core and Python
  • Artificial Intelligence in Drug Discovery

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: