VOOZH about

URL: https://dev.to/thukhakyawe_cloud/6deploy-jenkins-on-kubernetes-5450

⇱ 6.Deploy Jenkins on Kubernetes - DEV Community


Lab Information

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) Create a namespace jenkins

2) Create a Service for jenkins deployment. Service name should be jenkins-service under jenkins namespace, type should be NodePort, nodePort should be 30008

3) Create a Jenkins Deployment under jenkins namespace, It should be name as jenkins-deployment , labels app should be jenkins , container name should be jenkins-container , use jenkins/jenkins image , containerPort should be 8080 and replicas count should be 1.

Make sure to wait for the pods to be in running state and make sure you are able to access the Jenkins login screen in the browser before hitting the Check button.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

Lab Solutions

Step 1: Create the Jenkins Namespace

kubectl create namespace jenkins

Step 2: Create the Jenkins Service

Create a YAML file for the NodePort service:

cat > jenkins-service.yaml << EOF
apiVersion: v1
kind: Service
metadata:
 name: jenkins-service
 namespace: jenkins
spec:
 type: NodePort
 selector:
 app: jenkins
 ports:
 - protocol: TCP
 port: 8080
 targetPort: 8080
 nodePort: 30008
EOF

Apply the service:

kubectl apply -f jenkins-service.yaml

👁

Step 3: Create the Jenkins Deployment

Create a YAML file for the deployment:

cat > jenkins-deployment.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
 name: jenkins-deployment
 namespace: jenkins
spec:
 replicas: 1
 selector:
 matchLabels:
 app: jenkins
 template:
 metadata:
 labels:
 app: jenkins
 spec:
 containers:
 - name: jenkins-container
 image: jenkins/jenkins
 ports:
 - containerPort: 8080
EOF

Apply the deployment:

kubectl apply -f jenkins-deployment.yaml

👁

Step 4: Monitor the Deployment Progress

Check the status of the pod:

kubectl get pods -n jenkins 

Wait until the pod status shows Running. This might take a few minutes as the Jenkins image needs to be pulled and the container needs to start up.

👁

You can also check the deployment status:

kubectl get deployment -n jenkins

👁

Step 5: Verify Service Configuration

Check that the service is properly configured:

kubectl get svc -n jenkins

👁

Step 7: Access Jenkins

Once the pod is in Running state, you can access Jenkins:

👁

Step 8: Final Verification Commands

Run these commands to verify everything is set up correctly:

Check all resources in jenkins namespace

kubectl get all -n jenkins

Verify pod details

kubectl describe pod -l app=jenkins -n jenkins

Verify service details

kubectl describe svc jenkins-service -n jenkins

👁


Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.