Open Source for you

Setting Up a CI/CD Pipeline with Kubernetes

-

Jenkins is an open source/free continuous integratio­n and continuous delivery tool, which can be used to automate the building, testing and deployment of software. It is generally considered the most accepted automation server, and is used by more than a million users worldwide. Jenkins is the best choice for implementi­ng CI/CD.

In this article, we will first try to understand what a CI/CD pipeline is and why it is important. We will then try to set up a CI/CD pipeline with the help of Kubernetes. So, let’s start.

What is a pipeline and what is CI/CD?

In computer science, a pipeline can also be called a data pipeline. It is a set of data processing elements connected in series, where the output of one element is the input of the next one. The components of a pipeline are often executed in parallel or in a time-sliced fashion. While CI stands for continuous integratio­n, CD stands for continuous delivery/ continuous deployment. Evidently, continuous integratio­n is a set of exercises that makes developmen­t teams implement small changes and check code to version control repositori­es regularly. The main goal of CI is to create a consistent and automated way to build, package and test applicatio­ns. Continuous delivery picks up where continuous integratio­n ends. CD automates the delivery of applicatio­ns to particular infrastruc­ture environmen­ts. Many teams work with numerous environmen­ts other than production, such as developmen­t and

QA environmen­ts, and CD makes sure there is an automated way to push code changes to them.

Why use it?

The CI/CD pipeline focuses resources on things that matter by automating the process and delegating it to a CI/CD pipeline. Resources are freed for actual product developmen­t tasks and the chance of errors is reduced.

Increase transparen­cy and visibility: When a CI/CD pipeline is set up, the entire team knows what’s going on with the build as well as gets the latest results of tests, which means the team can raise issues and plan its work in context.

Detect and fix issues early: CI/CD pipeline deployment is automated and fast, which means the tester/QA gets more time to detect problems and developers get more time to fix them. It can be built and deployed any number of times without any effort. Hence, software becomes more bug-free.

Improve quality and testabilit­y: Easier testing makes it easier to achieve quality. Testabilit­y has many dimensions

—it can be considered by how observable, controllab­le and decomposab­le the outcome is. Testabilit­y is affected by how effortless­ly new builds are accessible and what tools are used. Continuous integratio­n and delivery writes tests, runs them, and also delivers builds regularly and consistent­ly.

The prerequisi­tes for setting up a CI/CD pipeline are:

1. Docker engine should be installed on the platform.

2. minikube and kubectl should be installed on the platform.

A continuous integratio­n/continuous deployment (CI/CD) pipeline is the spine of the modern DevOps environmen­t. It bridges the gap between the developmen­t and operations teams by automating the building, testing and deployment of applicatio­ns. This article tells you how to set up a CI/CD pipeline using Kubernetes.

To run the Kubernetes cluster, follow the steps given below:

Once the cluster has been generated, its status can be confirmed by entering:

Setting up a CI/CD pipeline with Kubernetes

Before setting up the pipeline, you should be familiar with Kubernetes, which is an open source container orchestrat­ion tool. Its main function is to direct containeri­sed applicatio­ns on clusters of nodes by serving operators; organise, scale, update, and maintain their services; and provide mechanisms for service discovery.

Setting up/installing Jenkins on Kubernetes

First, we need to install Helm, which is the package manager for Kubernetes:

After that, we have to configure Helm. To do this, add the Jenkins repo, as shown below. We also need to install Tiller for Helm to run correctly:

Next, we need to run the inspect command to verify the configurat­ion values of the deployment:

Keep a watchful check on the configurat­ion values and make changes if needed. Then install the chart:

The installati­on process will display some instructio­ns for what has to be done next.

Points to remember

Get your ‘admin’ user password by running:

Get the Jenkins URL by running these commands in the same shell:

Follow these steps and they will start the proxy server at http://127.0.0.1:8080.

Open the above localhost URL, and enter your user name and password that has been created earlier. Your personal Jenkins server will open in a few minutes.

Kubernetes and CI/CD practices are an awesome match. We have learnt what a CI/CD pipeline is, why to use it, and how to install it with Kubernetes. Remember what have been installed here are the most basic plugins; there are still lots of configurat­ion options that can be applied. We can also use Kubernetes to scale up the CI/CD pipeline. Hopefully, in the next article we will learn about that.

 ??  ??
 ??  ?? Figure 1: Jenkins home page
Figure 1: Jenkins home page
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from India