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!
- At least 2 CPUs to implement a kubernetes server
Or rent a kubernetes server
- Client server, for managing and configuring kubernetes clusters
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:
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.
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.
Insert the kubernetes config file into the created file and save it.
- You can upload the file remotely using the SFTP protocol.
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>
P.s. We copied/created this file after starting the kubernetes server.
Check the connection to the server.
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.
Enter these parameters into the created configuration file.
- name: jenkins
- name: http-port
- name: jnlp-port
- name: jenkins-vol
- name: jenkins-vol
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.
Add these settings to the created file.
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.
The password is in the logs of our running image.
Go to the web version of CI to continue the installation, enter in the dialog box the password that we learned earlier.
To complete installing Jenkins, follow the instructions provided with the web version.
In this publication I demonstrated how to deploy Jenkins CI using dedicated kubernetes server resources from Serverspace.