News
Seven days of Black Friday madness — great deal from Serverspace!

THE NEW YEAR
WHEEL OF FORTUNE

Spin the wheel and win a guaranteed prize right now!

By registering, you are signing up to receiving emails.
BM
December 21 2022
Updated December 11 2024

How to install Jenkins on Kubernetes

Kubernetes Linux Ubuntu

Introduction

Jenkins — is a continuous integration server that is distributed open source in the Java language. In this publication we will install this CI using kubernetes clusters.
Kubernetes is software for orchestrating containerized applications - automating their deployment, scaling, and coordination in a cluster environment. Thanks to containerization, you can easily restrict applications from each other, as well as change the allocated server resources from one application to another if needed.

In Serverspace, you can create a ready-made Kubernetes cluster, because it is convenient!

Requirements

  • At least 2 CPUs to implement a kubernetes server
    Or rent a kubernetes server
  • Client server, for managing and configuring kubernetes clusters

Preinstallation

Before installing CI, you need to deploy Kubernetes. To do this in Serverspace infrastructure, simply log in to your personal account, then go to Kubernetes and start the installation:

browser_ziwdrehf3m

Configure the dedicated cluster according to the characteristics you need, don't forget to give it a name.

P.s It will take about 15 minutes to create the cluster, be patient.

After creating the cluster, you will be able to download the configuration file of the server with Cubernetes. You will need this config file later when installing CI, to link the client-server and the server with the kubernetes clusters.

oymb8OrDiX

Download the configuration file to your computer, upload it to the server by choosing one of the suggested solutions:

  • You can create a new file and put the kubernetes cluster config into it.
nano config-kubernetes

Insert the kubernetes config file into the created file and save it.

  • You can upload the file remotely using the SFTP protocol.

Getting started

Install the necessary packages for the CI installation.

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

Specify the location of the k8s server configuration file.

export KUBECONFIG=<your path to config>

putty_ZJTgND2ZC3

P.s. We copied/created this file after starting the kubernetes server.

Check the connection to the server.

kubectl cluster-info

 

F0X9zFserb

Create a space for CI.

kubectl create namespace <your_namespace>

To install and run CI on a Kubernetes server, we need to create a configuration file, with our server settings.

nano our_project_jen.yaml

Enter these parameters into the created configuration file.

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: {}

This configuration file will deploy the latest CI release. Also the ports specified in the configuration will be created and opened, you can change them to what you need.

Now point the created space which configuration file to use.

kubectl create -f jenkins.yaml --namespace <your_namespace>

Wait for the cluster to install the jenkins image and run it, use the command below to test the module.

kubectl get pods -n jenkins

After running the image, I will create two more services to use the web version of jenkins.
Create and modify the service configuration file.

nano jenkins-service.yaml

Add these settings to the created file.

putty_4acnbrcerf
Point cluster to use this configuration file with the same space created.

kubectl create -f jenkins-service.yaml --namespace <your_namespace>

Checking status of the service.

kubectl get services --namespace jenkins

Use this command to see the ip address, or you can look it up in the kubernetes cluster control panel.

kubectl get nodes -o wide

Before going to the web version, get the password of the Jenkins superuser.

kubectl logs jenkins-CHANGE -n jenkins

Where "CHANGE" is the name of your container.

putty_503qBKel8J

The password is in the logs of our running image.

putty_psA3bB8u8Z

Go to the web version of CI to continue the installation, enter in the dialog box the password that we learned earlier.

firefox_5XDPSs98mb

To complete installing Jenkins, follow the instructions provided with the web version.

browser_BGmYzAyuz4

Conclusion

In this publication I demonstrated how to deploy Jenkins CI using dedicated kubernetes server resources from Serverspace.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.