bobbybabu007 / jenkins-docker-k8s

Deploying and Scaling Jenkins on Kubernetes

Home Page:https://devopsblogs.wordpress.com/2019/11/07/deploying-and-scaling-jenkins-on-kubernetes/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins in Docker-Compose

  1. Enable & Validate docker environment & docker-compose setup.
choco install -y docker-desktop
choco install -y docker-compose
  1. Update the Docker-compose.yml with volume-mount mappings, and image refs.

  2. Use the existing Docker-compose setup to bring up Jenkins locally on a Docker environment

$env:HOME="C:\Users\<USERNAME>"
docker-compose up -d
docker ps -a
docker container logs jenkins
docker container exec -it jenkins "cat /var/jenkins_home/secrets/initialAdminPassword"
  1. Give the containers about 5 minutes to spin up Jenkins, you can access it on http://localhost:8080 (not https)

Jenkins in Kubernetes

This repository has a Dockerfile and Jenkins official helm chart for setting up a simple Jenkins master for running in Kubernetes.

This Jenkins has the required tools to work in and with Kubernetes

  • Jenkins application with pre-loaded plugins (see plugins-pack-1.txt)
  • Skipped setup wizard
    • You can control admin user and password with --set adminUser=${USER},adminPassword=${PASSWORD}
    • You can add and remove plugins by editing the plugins-pack-1.txt file

Deploy Jenkins helm chart to Kubernetes

# Init helm on your cluster
$ helm init
$ kubectl apply -f rbac-config.yaml

# Deploy the Jenkins helm chart
# (same command for install and upgrade)
$ helm upgrade --install jenkins ./helm/jenkins

Customize & Build your Jenkins

  • Build & Push your custom Jenkins-nonprod image to DockerHub
# Build the image
docker image build -t bobbybabu007/jenkins-nonprod:<VERSION> -f Dockerfile-nonprod .

# Push the image
docker image push bobbybabu007/jenkins-nonprod:<VERSION>

  • Build & Push your custom Jenkins-prod image to DockerHub
# Build the image
$ docker image build -t bobbybabu007/jenkins:<VERSION>  -f Dockerfile-prod .

# Push the image
$ docker push bobbybabu007/jenkins:<VERSION>

Data persistence

By default, in Kubernetes, the Jenkins deployment uses a persistent volume claim that is mounted to /var/jenkins_home. This assures your data is saved across crashes, restarts and upgrades.

About

Deploying and Scaling Jenkins on Kubernetes

https://devopsblogs.wordpress.com/2019/11/07/deploying-and-scaling-jenkins-on-kubernetes/


Languages

Language:Mustache 87.8%Language:Groovy 6.3%Language:Dockerfile 4.4%Language:Starlark 1.4%