Jenkins Kubernetes PDF
Jenkins Kubernetes PDF
Jenkins Kubernetes PDF
Installing Jenkins
Prerequisites
Before continuing with this tutorial, make sure you have ubuntu machine created and logged in
as a user with sudo privileges.
1. Install Java.
Since Jenkins is a Java application, the first step is to install Java. Update the package
index and install the Java 8 OpenJDK package with the following commands:
Import the GPG keys of the Jenkins repository using the following wget command:
The command above should output OK which means that the key has been successfully
imported and packages from this repository will be considered trusted.
3. Install Jenkins.
Once the Jenkins repository is enabled, update the apt package list and install the latest
version of Jenkins by typing:
Jenkins service will automatically start after the installation process is complete. You can
verify it by printing the service status:
Setting Up Jenkins
To set up your new Jenkins installation, open your browser, type your domain or IP address
followed by port 8080 make sure you opened port 8080 in AWS security groups
, http://your_ip_or_domain:8080 and screen similar to the following will be displayed:
During the installation, the Jenkins installer creates an initial 32-character long alphanumeric
password. Use the following command to print the password on your terminal:
Copy the password from your terminal, paste it into the Administrator password field and
click Continue and install Selected Plugins.
1. Install Docker
3. Restart Jenkins
System Requirements
Master Machine : 4 GB RAM , 2 Core Processer
Worker Machines: 1 GB RAM , 1 Core Processer
apt-get update -y
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
modprobe br_netfilter
sysctl -p
sudo sysctl net.bridge.bridge-nf-call-iptables=1
systemctl daemon-reload
systemctl start kubelet
systemctl enable kubelet.service
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
copy kubeadm join token and execute in Worker Nodes to join to cluster
We can deploy docker applications into Kubernetes cluster from Jenkins using below 2
approaches.
sudo -i -u jenkins
cd ~
mkdir .kube
4. Create config file and copy config file content from Kubernetes Cluster master machine
and save the content.
vi .kube/config
5. We can use kubectl commands directly in pipe line script , kubectl commands will get
executed in Kubernetes cluster directly.