Kuberty.io
  • blog
Kuberty.io

Jenkins

Home / Jenkins
23May

How to Set Up Jenkins on the Kubernetes Cluster?

May 23, 2022 admin Jenkins, Kubernetes

Jenkins is a consistent integration technique that will automate a portion of the software development procedure. There are various developing teams available who are working on different projects in different microservices environments. The environment is complicated and has limited resource availability. It will help you to deliver a flawless outcome on a specified schedule. You can know the benefit of installing Jenkins on the Kubernetes cluster to get the desired results.

A Kubernetes cluster will add the new automatic layer to Jenkins. There is a prerequisite requirement of a surface to a command or terminal to set up. Resources must be used effectively so that service did not get overused through it. The cluster can deploy the container if it has enough resources in Jenkins.

Here are some practical examples of how to set up Jenkins on a cluster;

Make a namespace for the Jenkins Installation

It is essential to make a specific namespace that will provide more control over the continuous integration environment. However, one can make the namespace for Jenkins by typing the following command in the terminal.

Initially, kubectl could be used to create a namespace in Jenkins;

$ kubectl create namespace Jenkins

There is a need to write the name of the namespace which is used as a DNS compatible label. The output will confirm the namespace’s successful creation. It is the first requirement for the installation of Jenkins on the cluster software. Use the command which is provided in the existing namespace to avoid any confusion in creating the name for the deployment of Jenkins. It will satisfy the requirements of the individuals for setting up the software.

Creating Jenkins Deployment File

Once you have designated a namespace, you need to use the preferred Linux text editor to create the deployment file. It is the second requirement for the setting of Jenkins on the cluster. The deployment file will be created according to requirements after utilizing the resources and examples. There is a volume mounts section of the file that will create consistent volume for installing the software. The role of the volume is to store the basic Jenkins data and take care of it for a long period. You can save the changes for once by adding the content and exiting the file. It is the next and essential step involved in the creation of the Jenkins deployment file.

Further, YAML needs to be created to deploy Jenkins;

Open the new file named jenkins.yaml with the help of nano editor or any preferred editor;

nano jenkins.yaml

Thereafter, you have to add the codes to specify Jenkins image;

Jenkins.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: jenkins

spec:

replicas: 1

selector:

matchLabels:

app: jenkins

template:

metadata:

labels:

app: jenkins

spec:

containers:

– name: jenkins

image: jenkins/jenkins:lts

ports:

– name: http-port

containerPort: 8080

– name: jnlp-port

containerPort: 50000

volumeMounts:

– name: jenkins-vol

mountPath: /var/jenkins_vol

volumes:

– name: jenkins-vol

emptyDir: {}

In the production cluster, there is no need to use the host path. Instead, a clustered administrator will provide the provision of the network resources to change the volume. You must make sure about it while deploying Jenkins on a Kubernetes cluster.

Deployment of Jenkins

To deploy Jenkins on the cluster, use the freshly generated file. The system may be directed to install Jenkins data under the Jenkins namespace using a guide and command. It is an essential step that you need to follow for installing Jenkins on the Kubernetes cluster. The collection of information is possible by following the guide and command available at the cluster.

Create and Deploy Jenkins Service

Kubernetes cluster will manage the life cycle of a pod. It is managed within the cluster to avoid additional space. There is a need to regularly remove and deploy the pods to obtain the desired state and balance the workload available at the cluster. A service refers to an abstraction that will expose Jenkins to the wider network. It will allow you to maintain a persistent connection with the pods. There is no requirement for change to take place within the cluster. You should create a service with a Jenkins service file by using any text editor to add the content. The content can be taken from the example provided at the cluster. With the help of commands, you can make the service after tagging the Jenkins namespace. Now, you have the service available to the Jenkins dashboard installed at the Kubernetes cluster. Collection of the complete information about it is essential to install the data on the cluster correctly.

kubectl create -f jenkins.yaml –namespace jenkins

To verify the pod’s state, you need to use kubectl

kubectl get pods -n jenkins

You may find different names in your system. However, after the pod starts to run you have to find it with service.

Create a new file name as jenkins-service.yaml:

nano jenkins-service.yaml

Enter the code to specify Nodeport service;

apiVersion: v1

kind: Service

metadata:

name: jenkins

spec:

type: NodePort

ports:

– port: 8080

targetPort: 8080

nodePort: 30000

selector:

app: jenkins

—

apiVersion: v1

kind: Service

metadata:

name: jenkins-jnlp

spec:

type: ClusterIP

ports:

– port: 50000

targetPort: 50000

selector:

app: jenkins

Access to Jenkins Dashboard

You can go to your browser and have a session on a node by using the IP address which is defined in the service file. If you want to access Jenkins, you need to initially enter some credentials. The default username and some installations are an admin at the dashboard. There is the availability of a password in several ways. You can use examples related to Jenkins deployment and name to find the correct name of the port for entering the command. Once you have found a location and the name of the pod, it will provide you access to the pod logs. The password is useful at the end of the formatted string. By this, you can successfully install Jenkins on the Kubernetes cluster. That enables us to build the latest and accurate development pipelines. Understanding Jenkins working is also essential to get desired results with complete access over the dashboard.

Use kubectl to get the node IPs;

kubectl get nodes -o wide

It will produce output with the external IPs. Look for your IP and copy it.

Further, open the website with the address http://your_external_ip:30000.

It will redirect to the page that required the administration password for guidelines to get the password from Jenkins Pod logs.

You have to use kubectl to get the password.

Use the following command to get back your Pod name;

kubectl get pods -n jenkins

Look into Pod logs for the password, and change the highlighted section with Pod name;

kubectl logs jenkins-6fb994cfc5-twnvn -n jenkins

To find the password scroll up or down a bit;

Running from: /usr/share/jenkins/jenkins.war

webroot: EnvVars.masterEnvVars.get(“JENKINS_HOME”)

. . .

Jenkins initial setup is required. An admin user has been created and a password generated.

Please use the following password to proceed to installation:

your_jenkins_password

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

After getting your Password, copy and paste it into Jenkins UI.

How Jenkins Works

Jenkins has become a standard for software development pipelines industries. Before the notion of continuous integration, the development process was tempered by several integrations and long testing procedures. Jenkins refers to a self-contained solution that is compatible with different integration plugins to offer a comprehensive and easy-to-use environment. Developers also use to daily check the changes made to the source code. You can build the source codes and generate deployable files with quality assurance and security checks.

Jenkins uses plugins to produce Metric, which is the detailed and qualified information to build a continuous process. If the building fails, then the information and the testing can provide additional changes to the submitted code. It is an essential thing that developers should know while installing Jenkins on the Kubernetes cluster. Collection of information about it is essential for the people to install Jenkins on the cluster.

Conclusion

Now you know about the installation of Jenkins on a Kubernetes cluster, it will automate different tasks and assist the developers to submit the code effectively. It also increases productivity and reduces wastage of time. The following of each step in the setting up of Jenkins over the Kubernetes cluster will solve many complexities in the performance of the task for developers. The building of the local software and testing the data is possible without any additional requirement of skills and expertise.

It will also provide a service over the Jenkins dashboard. The meeting of the needs is possible for the individuals with installing Jenkins over the cluster. You need to follow each step to get the desired results without wasting time manually. The correct installation is possible for the submission of the code sufficiently. It will provide a continuous loop resulting in a well-polished product. Jenkins build creates a ready-to-deploy package that will lead to the next phase of development and production.

Read more
03Apr

Kubernetes vs Jenkins

April 3, 2021 admin Jenkins, Kubernetes

Jenkins is one of the most popular, free, and open-source continuous integration (CI) servers that can be extended. Jenkins CI, in a nutshell, is the most widely used and has the most active communities among all the other open-source CI servers. It’s written in Java and comes with over 300 plugins to help you create and validate practically every project.

On the other hand, to speed development and simplify operations, Kubernetes is used to run a cluster of Linux containers as a single framework. It’s a Docker container orchestration framework that’s open source. It performs workload scheduling on compute cluster nodes and actively controls workloads to ensure that their state corresponds to the users’ stated intentions.

While Jenkins is classified as a “Continuous Integration” tool, Kubernetes can be identified as a “Container Management” tool.

In this article, we will walk you through the uses and differences between Kubernetes and Jenkins that are two of the most widely used tools in DevOps. While, it’s not a question of “either-or” for Jenkins and Kubernetes, it’s more of a “both-and”. This means that Kubernetes and Jenkins have their own different use-cases and can’t be compared as such. It’s not like we have to choose one over the other. It’s best if we have both of them in our technological stack.

Kubernetes and Container Orchestration

Kubernetes is a free and open-source framework that can be used to manage containerized workloads or utilities that allows you to declare configurations as well as perform automation. It has a sizable and quickly expanding ecosystem. Services, tools, and resources for Kubernetes are readily available.

App development techniques have been changed by container deployment. Google created Kubernetes for automated scaling, installing, and handling systems in response to the need for new technologies and techniques. It offers a single API interface for managing even the most complex applications that are distributed across various servers and platforms.

Kubernetes, for example, is a container orchestration platform that automates container management in a rapidly changing and volatile environment. We’ll delve into the complexities of container environments to fully comprehend their function.

Small virtual environments with their own memory, device files, and processing space are known as containers. They are much smaller than standard virtual computers and do not need their own operating systems. They are compact and indefinitely versatile across various computers and operating systems due to their scalability and self-sufficiency.

Developers can create apps as a set of smaller, self-contained microservices. A single service can, in theory, only execute one role. These microservices are then rapidly and reliably coupled and deployed on a Kubernetes cluster.

Working of Kubernetes

The containers are made to be as light as possible. As a consequence, they are delicate and transient. Instead of improving a container’s resilience, Kubernetes takes advantage of a container’s instability and helps us to manage clusters of containers seamlessly.

Kubernetes only includes a broad overview of how you want your cluster to work. This configuration is typically a simple manifest file sent to Kubernetes using a command-line interface tool.

Kubectl is the default Kubernetes CLI. Kubectl is a command-line interface for controlling cluster resources and sending commands to the Kubernetes API server. The API server then attaches and eliminates containers in your cluster dynamically to ensure that the intended state and the current state of the cluster are still the same.

The Master Node, Worker Nodes, and Pods are the essence of a Kubernetes cluster. The Master Node houses the modules that make global cluster decisions, such as the API server.

Jenkins and Continuous Integration

Continuous Integration is a programming process that requires developers to commit updates to source code in a repository shared among teammates many times a day or more often. The repository is then built for any commits made. As a result, teams can spot problems early on. Apart from that, the Continuous Integration platform can perform a variety of other tasks, such as deploying the development application to the test server, informing the associated teams about the build and test performance, and so on.

Jenkins is an open-source, freely-available, Java-based automation platform with a plethora of plugins especially crafted for Continuous Integration. Jenkins is used to consistently design and validate the applications, which makes it easy for developers to incorporate updates to the code and for the end-users to get a brand-new build. It also enables you to deliver your applications continuously by connecting with a variety of testing and implementation technologies.

Organizations will use Jenkins to automate the software creation process and speed up the process. Apart from CI and pipeline management, Jenkins also provides other useful SDLC elements such as product development stage, report generation, test environments, bundle, stage, tools for product launch, static analysis, and many more. Let’s discuss how a developer can use Jenkins in their typical Software development process.

Working of Jenkins

 

The code is first committed to the source code repository by a developer. Meanwhile, the Jenkins server monitors the archive for updates at daily intervals. The Jenkins server senses the modifications in the source code repository shortly after a commit is made. Jenkins will pull those updates and begin working on a new build. The concerned team will be alerted if the build fails. If the build is successful, it then deploys it in the test server or environment. It receives and generates feedback during checking and then notifies the developers of the development and test results. Also, it will continue to monitor the source code archive for updates, and the whole process will be monitored. The same process will be repeated for each commit.

Features and Need of Kubernetes

Let’s discuss the key features of Kubernetes that make it popular among organizations and developers:

  1. It allows you to discover services and perform load-balancing. It can expose a container using its own IP address or its DNS name. If a container receives a lot of traffic, Kubernetes can load balance and disperse the traffic to keep the deployment secure.
  2. Orchestration of storage. It helps you to mount whatever storage device you choose, including local storage, cloud services, and more.
  3. You can perform automated rollouts as well as rollbacks. Kubernetes allows you to specify the coveted state that you want for your currently-deployed containers and then shift the current state to the new state at a regulated pace. You can use it to simplify the development of containers for your production, as well as the removal of present containers and the use of all the resources to another container.
  4. You can perform bin packing automatically. You send Kubernetes a cluster of nodes to use for containerized task execution. Kubernetes is told the estimate of the CPU or the amount of memory (RAM) that the containers would require. To make the most of your assets, Kubernetes will fit containers into your nodes.
  5. It has the ability to self-heal. It restarts failed containers, restores them, destroys containers that don’t respond to a user-defined health check, and doesn’t announce them to clients until they’re ready to work.
  6. Password and Configuration Management. You may use Kubernetes to store and handle confidential data including secret keys, OAuth tokens, and SSH keys. Without restoring your container images or disclosing secrets in your stack setup, you can deploy and upgrade secrets and server configuration.

Features and Need of Jenkins

Now, let’s discuss the key features that allow Jenkins to sit right on top of the deck when it comes to CI tools:

  1. Jenkins is an open-source automation server that is completely free to use.
  2. Since it has been in the market for a long time, it is a favored CI/CD platform by both early-stage startups and major companies.
  3. It has a vast ecosystem of plugins. There are nearly 1500 plugins available for use.
  4. Jenkins can be used for a range of cloud services, including Amazon EC2, VMware, Digital Ocean, GCP, and others.
  5. Jenkins pipelines can be incredibly helpful when it comes to understanding CD standards for major projects.
  6. It is written in Java and hence, it is platform-independent.
  7. Jenkins is widely used, with around 147,000 active installations and over 1M users all over the world.

What Not to Expect from Kubernetes?

Kubernetes isn’t the typical all-in-one PaaS (Platform as a Service) solution. Since Kubernetes works at the container level instead of the hardware level, it offers certain functionality that is familiar to PaaS providers, such as deployment, scaling, and load balancing, as well as the ability to incorporate reporting, tracking, and alerting systems. Also, Kubernetes is not a monolithic system, and its default implementations are both optional and pluggable. Kubernetes offers the building blocks for constructing developer platforms while also preserving user preference and versatility.

  1. There are no limits on the types of systems that may be used. Kubernetes is designed to accommodate a wide range of workloads such as data-processing and stateful or stateless workloads. If an app can operate inside a container, Kubernetes should be a breeze.
  2. It does not build the application or deploy source code. Doesn’t matter whether you use tools like Kubernetes or not, the working cultures, priorities, or other tools adopted by companies, as well as functional specifications, affect the overall CI/CD workflows.
  3. Cluster storage mechanisms like Ceph, middleware such as message buses, caches, databases, data-processing structures such as Spark, etc. are not accessible as built-in utilities. Such modules can operate on Kubernetes and/or be accessed by Kubernetes-based applications through portable frameworks like the Open Service Broker.
  4. There are no specifications for tracking, reporting, or alerting solutions. It includes several proof-of-concept integrations as well as metrics collection and export mechanisms.
  5. It neither provides nor needs a configuration language or framework. It exposes a declarative API that can be used to attack some kind of declarative specification.
  6. No detailed computer design, repair, management, or self-healing solutions are provided or adopted.

Shortcomings of Jenkins

Jenkins also has a number of flaws (not necessarily disadvantages). A few of them are mentioned below:

  1. Jenkins is a more “feature-driven” and “developer-centric” app. Jenkins can require a big learning curve for those users who are not accustomed to working with complex UI tools.
  2. Changes in settings (including plugin installations) can cause problems, such as Jenkins not starting up. In those cases, you would look for a workaround online, which you can luckily do because Jenkins has a huge user base!

Overall, Jenkins is a versatile continuous integration and delivery (CI/CD) platform that is genuinely made for developers.

Wrapping Up

It’s a difficult task to deploy a cluster of containers across several servers and platforms. Also, it will be extremely inefficient to manage multiple clusters of containers without an appropriate Container Orchestration Tool.

The administration of your clusters can be automated with a framework like Kubernetes. It not only assists in application deployment but also preserves application requirements and operates more effectively than a human administrator.

On the other hand, it is clear that traditional development methods not only bog down product implementation procedures but also bring down the software quality. Customer disappointment occurs as a result of this. To deal with the chaos, a framework was needed where developers could constantly initiate a build and test on any update they made to the source code. This is the essence of CI. Jenkins is, by far, the best and most mature tool that is available for continuous integration and is heavily used by developers worldwide.

As discussed, it’s not an option of either-or when it comes to Kubernetes and Jenkins. It’s always better if we use them both to enhance the entire development lifecycle. We hope that you now have a good understanding of container orchestration and continuous integration and how Jenkins and Kubernetes work. You can use this knowledge to build, test, deploy, and maintain productive software deployments.

Read more
corporate-one-light
+1 800 622 22 02
info@scapeindustries.com

Company

Working hours

Mon-Tue

9:00 – 18:00

Friday

9:00 – 18:00

Sat-Sun

Closed

Contacts

3 New Orchard Road
Armonk, New York 10504-1522
United States
915-599-1900

© 2021 Kuberty.io by Kuberty.io