Question : The Nautilus DevOps team is planning to set up a Jenkins CI server to create/manage some deployment pipelines for some of the projects. They want to set up the Jenkins server on Kubernetes cluster. Below you can find more details about the task:
1. At first kubectl utility configure and working from jump server, run below commands
thor@jump_host
~$ kubectl get namespace NAME STATUS AGE default Active 2m42s kube-node-lease Active
2m45s kube-public Active 2m45s kube-system Active 2m46s local-path-storage Active
2m29s thor@jump_host
~$ thor@jump_host
~$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE kubernetes ClusterIP
10.96.0.1 <none> 443/TCP 2m59s thor@jump_host
~$ |
2. Create namespace as per the task request.
thor@jump_host
~$ kubectl create namespace jenkins namespace/jenkins
created thor@jump_host
~$ thor@jump_host
~$ kubectl get namespace NAME STATUS AGE default Active 4m9s jenkins Active 3s kube-node-lease Active
4m12s kube-public Active 4m12s kube-system Active 4m13s local-path-storage Active
3m56s thor@jump_host
~$ |
thor@jump_host
~$ vi /tmp/jenkins.yaml thor@jump_host
~$ cat /tmp/jenkins.yaml apiVersion: v1 kind: Service metadata: name: jenkins-service namespace: jenkins spec: type: NodePort selector: app: jenkins ports: - port: 8080 targetPort: 8080 nodePort: 30008 --- apiVersion:
apps/v1 kind: Deployment metadata: name: jenkins-deployment namespace: jenkins labels: app: jenkins spec: replicas: 1 selector: matchLabels: app: jenkins template: metadata: labels: app: jenkins spec: containers: - name: jenkins-container image: jenkins/jenkins ports: - containerPort: 8080 thor@jump_host ~$ |
thor@jump_host
~$ kubectl create -f /tmp/jenkins.yaml service/jenkins-service
created deployment.apps/jenkins-deployment
created thor@jump_host
~$ |
thor@jump_host
~$ kubectl get deploy -n jenkins NAME READY UP-TO-DATE AVAILABLE
AGE jenkins-deployment 1/1
1 1 6m48s thor@jump_host
~$ thor@jump_host
~$ kubectl get pods -n jenkins NAME READY STATUS
RESTARTS AGE jenkins-deployment-6b6c78f968-27gpz 1/1
Running 0 2m9s thor@jump_host
~$ kubectl get service -n jenkins NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE jenkins-service NodePort
10.96.93.208 <none> 8080:30008/TCP 37s thor@jump_host
~$ |
6. Validate the task by curl or open the browser by clicking 'Open Port on Host 1'
thor@jump_host
~$ kubectl exec jenkins-deployment-6b6c78f968-27gpz -n jenkins -- curl http://localhost:8080 % Total
% Received % Xferd Average
Speed Time Time
Time Current Dload Upload
Total Spent Left
Speed 0
0 0 0
0 0 0
0 --:--:-- --:--:-- --:--:--
0<html><head><meta http-equiv='refresh'
content='1;url=/login?from=%2F'/><script>window.location.replace('/login?from=%2F');</script></head><body
style='background-color:white; color:white;'>
Authentication
required <!-- -->
</body></html>
100 541
100 541 0
0 772 0 --:--:-- --:--:-- --:--:-- 772 thor@jump_host
~$ |
7. Click on Finish & Confirm to complete the task successful
Happy Learning!!!!
Apart from this if you need more clarity, I have made a tutorial video on this , please go through and share your comments. Like and share the knowledge
0 Comments