Aravind Pratapagiri September 12th, 2021 – 5 min read
Introduction:
Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
A Kubernetes cluster adds a new automation layer to Jenkins. Kubernetes makes sure that resources are used effectively and that your servers and underlying infrastructure are not overloaded. Kubernetes’ ability to orchestrate container deployment ensures that Jenkins always has the right amount of resources available. This section will describe option to install/run Jenkins on Kubernetes.
Prerequisites:
Install Helm
To install Helm CLI, follow the instructions from the Installing Helm page.
Macos : brew install helm
Windows : choco install kubernetes-helm
Once Helm is installed and set up properly, add the Jenkins repo as follows:
Configure Helm:
$ helm repo add jenkinsci https://charts.jenkins.io
$ helm repo update
The helm charts in the Jenkins repo can be listed with the command:
$ helm search repo jenkinsci
Install Steps: Jenkins on EKS using helm.
Step 1: Create Namespace
$ kubectl create namespace jenkins
namespace/jenkins created
Step 2: Install Jenkins using helm charts. Attached values.yaml
$ helm upgrade –install jenkins –namespace jenkins -f jenkinsvalues.yaml jenkinsci/jenkins
Release “jenkins” does not exist. Installing it now.
- Get your ‘admin’ user password by running:
kubectl exec –namespace jenkins -it svc/jenkins -c jenkins — /bin/cat /run/secrets/chart-admin-password && echo
8J1n3lV2SeIXbAVoYcnHl9 - Get the Jenkins URL to visit by running these commands in the same shell:
echo http://127.0.0.1:8080
kubectl –namespace jenkins port-forward svc/jenkins 8080:8080 - Login with the password from step 1 and the username: admin
- Configure security realm and authorization strategy
- Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file
Step 3: Apply ingress.
$ kubectl –namespace jenkins apply -f ing-jen1-west-1.yaml
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
ingress.extensions/tcp created
$ kubectl -n jenkins get ing
NAME CLASS HOSTS ADDRESS PORTS AGE
tcp <none> *.xxxxxxxxxxxx.com jenkins.us-west-1.elb.amazonaws.com 80 17s
Uninstall Steps Jenkins from EKS:
$ helm uninstall jenkins -n jenkins
release “jenkins” uninstalled
$ kubectl delete ns jenkins
namespace “jenkins” deleted
Access Jenkins Console:
http://jenkins.us-west-1.elb.amazonaws.com
Github repo: helm-charts/charts/jenkins at main · jenkinsci/helm-charts