DevOps/ Automation

Automating Jenkins & Docker with Kubernetes

Integrating Kubernetes with Docker & Jenkins

Why Do we Need Kubernetes?

Getting Started

1. JOB-1:

Jenkins Setup

JOB-2:

if sudo ls ./*.html
then
sudo kubectl create -f /k8s-jenkins/files/testing.yml

sleep 15
sudo sh /root/k8s-copy.sh
elif sudo ls ./*.py
then
sudo kubectl create -f /k8s-jenkins/files/testing.yml

sleep 15
sudo sh /root/k8s-copy.sh
elif sudo ls ./*.php
then
sudo kubectl create -f /k8s-jenkins/files/testing.yml

sleep 15
sudo sh /root/k8s-copy.sh
fi
for podname in $(kubectl get pods -l env=testing -o custom-columns=:metadata.name | tr -d '\n'); do kubectl cp /k8s-jenkins/files/index.html "${podname}":/usr/local/apache2/htdocs; done

JOB4:

sudo cp /k8s-jenkins/files/testing.yml /k8s-jenkins/files/deployment.yml
sudo sed -i 's/testing/production/g' /k8s-jenkins/files/deployment.yml
sudo sed -i 's/myweb/mywebprod/g' /k8s-jenkins/files/deployment.yml
sudo sed -i 's/claimName: mywebprod-pv-claim/claimName: myweb-pv-claim/g' /k8s-jenkins/files/deployment.yml

sudo kubectl create -f /k8s-jenkins/files/deployment.yml

port=$(sudo kubectl get service -l env=production | cut -d " " -f 15 | cut -d ":" -f 2 | cut -d "/" -f 1 | tr -d '\n')

export DISPLAY=:0
sleep 10

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Avik Kundu

Software Engineer @ Red Hat | Learning, Sharing & Contributing to the Open Source