Skip to content

Latest commit

 

History

History
116 lines (77 loc) · 4.82 KB

K8s-Helm-Jenkins.md

File metadata and controls

116 lines (77 loc) · 4.82 KB

LAB: Helm-Jenkins on running K8s Cluster (2 Node Multipass VM)

  • "Whenever you trigger a Jenkins job, the Jenkins Kubernetes plugin will make an API call to create a Kubernetes agent pod. Then, the Jenkins agent pod gets deployed in the kubernetes with few environment variables containing the Jenkins server details and secrets."
  • "When the agent pod comes up, it used the details in its environment variables and talks back to Jenkins using the JNLP method" (Ref: DevopsCube)

K8s Cluster (2 Node Multipass VM)

Helm Install

curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
helm version

Jenkins Install

helm repo add jenkins https://charts.jenkins.io        
helm repo list
mkdir helm
cd helm
helm pull jenkins/jenkins                                           
tar zxvf jenkins-3.11.4.tgz                                       
  • After unzipping, entered into the jenkins directory, you'll find values.yaml file. Disable the persistence with false.
  • If your cluster on-premise does not support storage class (like our multipass VM cluster), PVC and PV, disable persistence. But if you are working on minikube, minikube supports PVC and PV automatically.
  • If you don't disable persistence, you'll encounter that your PODs will not run (wait pending). You can inspect PVC, PV and Pod with kubectl describe command.

image

  • Install Helm Jenkins Release:
helm install j1 jenkins
kubectl get pods
kubectl get svc
kubectl get pods -o wide

image

  • To get Jenkins password (username:admin), run:
kubectl exec --namespace default -it svc/j1-jenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo  

image

  • Port Forwarding:
kubectl --namespace default port-forward svc/j1-jenkins 8080:8080

image

Install Graphical Desktop to Reach Browser using Multipass VM

sudo apt update
sudo apt install ubuntu-desktop xrdp
sudo passwd ubuntu    # set password

Jenkins Configuration

  • Helm also downloads automatically some of the plugins (kubernetes:1.31.3, workflow-aggregator:2.6, git:4.10.2, configuration-as-code:1.55.1) (Jenkins Version: 2.319.3)
  • Manage Jenkins > Configure System > Cloud image

image

image

image

image

image

  • New Item on main page:

image

image

  • Add script > Build > Execute Shell:

image

  • After triggering jobs, Jenkins (on Master) creates agents on Worker1 automatically. After jobs are completed, they are terminated.

image

Reference