Monday, June 22, 2020

How to setup Kubernetes Cluster in Ubuntu | Install Kubernetes Cluster in Ubuntu | Setup Master Node and one worker Node in AWS

Kubernetes  is an open source container platform that eliminates many of the manual processes involved in deploying and scaling containerized applications. We will learn how to setup Kubernetes Cluster in Ubuntu 18.0.4. You can setup Kubernetes Cluster in many ways. One of the ways is to use Kubeadm. 

Kubeadm is a tool built to provide kubeadm init and kubeadm join as best-practice “fast paths” for creating Kubernetes clusters.


1. Ubuntu instance with 4 GM RAM - Master Node - (with port open to all traffic
2. Ubuntu instance with at least 2 GM RAM - Worker Node - (with ports open to all traffic)

Kubernetes Setup using Kubeadm

###Start - Execute the below commands in both Master/worker nodes##########

Login to both instances execute the below commands:
sudo apt-get update -y  && sudo apt-get install apt-transport-https -y

Change to root user
sudo su -
sudo curl -s | apt-key add -

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main

sudo apt-get update

#Disable swap memory
swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

Enable IP tables
#We need to enable IT tables for pod to pod communication.
modprobe br_netfilter
sysctl -p
sudo sysctl net.bridge.bridge-nf-call-iptables=1

Install Docker on both Master and Worker nodes
apt-get install -y

Add ubuntu user to Docker group
usermod -aG docker ubuntu
systemctl restart docker
systemctl enable docker.service

Install Kubernetes Modules
sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni

sudo systemctl daemon-reload
sudo systemctl start kubelet
sudo systemctl enable kubelet.service
sudo systemctl status docker
#End - Execute the above commands in both Master/worker nodes##########

Initialize Kubeadm on Master Node(only on Master Node)

#Execute the below command as root user
sudo su -
kubeadm init

#exit from root user and execute as normal user

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Installing the Weave Net Add-On
kubectl apply -f "$(kubectl version | base64 | tr -d '\n')"
It make take a few mins to execute the above command

You will get below messages.
serviceaccount "weave-net" created
clusterrole "weave-net" created
clusterrolebinding "weave-net" created
role "weave-net" created
rolebinding "weave-net" created
daemonset "weave-net" created

Now execute the below command to see the pods.

kubectl get pods  --all-namespaces

Now login to Worker Node

Join worker node to Master Node
The below command will join worker node to master node.
sudo kubeadm join <master_node_ip>:6443 --token xrvked.s0n9771cd9x8a9oc \
    --discovery-token-ca-cert-hash sha256:288084720b5aad132787665cb73b9c530763cd1cba10e12574b4e97452137b4a

Go to Master and type the below command
kubectl get nodes
the above command should display both Master and worker nodes.

It means Kubernetes Cluster - both Master and worker nodes are setup successfully and up and running!!!

Deploy Nginx on a Kubernetes Cluster
Let us run some apps to make sure they are deployed to Kuberneter cluster. We will do this in master node. The below command will create deployment:

kubectl create deployment nginx --image=nginx

View Deployments
kubectl get deployments
Create as a service 
kubectl create service nodeport nginx --tcp=80:80
kubectl get svc
run the above command to see a summary of the service and the ports exposed.

Now go Master or worker node, enter public dns and access it with port exposed
You should see the welcome page!

Friday, June 19, 2020

Install Helm 2 on Linux - Setup Helm 2 on Linux | Install Helm 2 on Ubuntu | Setup Helm 2 on Linux

Helm is package manager for Kubernetes. Helm helps you manage Kubernetes applications. Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application. Charts are easy to create, version, share, and publish.

Helm is made of two components: the CLI binary named helm that allows you to perform communication with a remote component, named tiller that lives inside your Kubernetes cluster that is responsible to perform patches and changes to resources you ask to manage. 

Helm can be installed by below way:

Download installables
sudo curl -LO
provide permission
sudo chmod 700

Execute script to install 
sudo ./

Verify installation

helm version --client

Tiller is the service that actually communicates with the Kubernetes API to manage our Helm packages.
cat <<EOF > tiller-rbac-config.yaml
apiVersion: v1
kind: ServiceAccount
  name: tiller
  namespace: kube-system
kind: ClusterRoleBinding
  name: tiller
  kind: ClusterRole
  name: cluster-admin
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system
Apply the RBAC configuration for Tiller via a kubectl command: 
kubectl create -f tiller-rbac-config.yaml 

Initialize Tiller
helm init --service-account tiller

Thursday, June 18, 2020

Install AWS CLI 2 on Red Hat Linux

curl "" -o ""
sudo ./aws/install

Tuesday, June 2, 2020

Migrate jenkins jobs from one server to another | Migrate Jenkins jobs from one Jenkins server to another Jenkins server

How to migrate Jenkins jobs from one Jenkins instance to another Jenkins instance?
Jenkins jobs can be migrated in many ways. You can establish SSH connection b/w source machine and target machine and use scp command to copy from one instance to another instance. You can also use Job import plug-in to migrate jobs.


Make sure you install Job Import plugin in target Jenkins instance.

Steps to migrate jobs from source Jenkins to Target Jenkins instance:

Make sure you have right Jenkins source URL by logging to Source Jenkins.
Click on Manage Jenkins --> Configure System
Copy the Jenkins URL.
Logout from source Jenkins.

Steps in Target Jenkins
1. Login to Target Jenkins
2. Go to Manage Jenkins -->configure system--> click on Job import plug-in
Add source Jenkins url and login credentials.

3. Click on Save
4. Go to Jenkins -->Job Import plug-in
 5. Select source Jenkins from down and check search into folder option
  click on Query

6. Now it should pull all the jobs, choose the jobs you would like to migrate and click on Import.
Make sure you choose install required plug-ins option as well.
 Now you should see the message.
7. Go to Jenkins home page and refresh it. You should see the jobs migrated successfully.
You can watch these steps in my YouTube channel as well:

Note: Please note that Credentials will not be migrated, only Jobs and plug-ins will be migrated.

How to change Default port 8080 for Jenkins | Change Jenkins Default port 8080 in Ubuntu

Jenkins default port is 8080. Default port can always be changed by modifying configuration file of Jenkins. Let's say you have installed Jenkins in Ubuntu ec2, if you like to change from 8080 to 8090.

Change port no from 8080
Locate the below file in Ubuntu:
sudo vi /etc/default/jenkins

Restart Jenkins after changes
sudo service jenkins restart  
Please watch the above steps in YouTube channel:

Monday, June 1, 2020

How to change Default port for Tomcat | Change Tomcat Default port 8080

Tomcat default port is 8080. That can be changed by modifying server.xml of Tomcat.

Change port no from 8080
1. Locate server.xml, for Ubuntu it is at below location:

2. sudo vi /var/lib/tomcat8/conf/server.xml
Let's say you like to change from 8080 to 8090

you need to scroll down by clicking down arrow button in this file change the port no from 8080 to 8090 at line starting with <Connector port="8080">

Restart Tomcat after changes

sudo systemctl restart tomcat8