0% found this document useful (0 votes)
12 views27 pages

Shailesh - Main-Kubernet Installation

Uploaded by

Shailesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views27 pages

Shailesh - Main-Kubernet Installation

Uploaded by

Shailesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

1.

Upgrade the package manager:


2. Then install Ha proxy : sudo apt-get install haproxy -y

3. Edit haproxy configuration : edit vi /etc/haproxy/haproxy.cfg

frontend fe-apiserver

bind 0.0.0.0:6443

mode tcp

option tcplog

default_backend be-apiserver

backend be-apiserver

mode tcp

option tcplog

option tcp-check

balance roundrobin
default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256

weight 100

server master1 172.31.38.15:6443 check ==> change the ip address refer aws server

server master1 172.31.38.18:6443 check ==> change the ip address refer aws server

server master1 172.31.38.121:6443 check ==> change the ip address refer aws serve

:wq

Make the changes as belwo to haproxy.cfg configuration firle

fe-apiserver and be-apiserver


4. Restart and veryify the ha proxy:

systemctl restart haproxy

systemctl status haproxy


5. To verify that port 6443 listening to load balancer or not

nc -v localhost 6443

========================================================================

1. Install kubeadm, kubelet and docket on master and worker nodes

(Very Very IMPORTANT, Install and configure these steps on all the Master and Worker Server) STEPS
1 and 2.

a. Update the package manager as below:

login as root by sudo -i

run-> apt-get update


b. Disabling the swap memory also from fstab :

#Turn Off Swap Space

swapoff -a

sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

c. # Install And Enable Docker

apt install docker.io -y

usermod -aG docker ubuntu => this command not run by trainer

systemctl restart docker

systemctl enable docker.service

2. Installing kubernets software :

a. Below is pre-requisite for installing kubernets software :

apt-get update -y && apt-get install -y apt-transport-https curl ca-certificates gnupg-agent software-
properties-common
b. Donwload apt-key for kubedm

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

c. Make the entry in apt package type

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


https://apt.kubernetes.io/ kubernetes-xenial main EOF

d. Again, update the package manager :

apt-get update -y

e. Install kubelet and kubeadm :

#apt-get install -y kubelet kubeadm


f. I am holding kubelet and kubeadm : Don;t want package manager to update this software

apt-mark hold kubelet kubeadm

g. start and enable the kublet services at bootstrap.

#systemctl daemon-reload #systemctl start


kubelet #systemctl enable kublet.service

ABOVE, We just installed required software, yet none of them are Master or Worker

NOW, We have installed all the require software, NOW We will bootstrap the cluster initialize the
cluster.

3. Configure kubeadm to bootstrap the cluster :


IT WILL GENERATE KUBE-CONFIG FILE, IN KUBE-CONFIG FILE THERE IS NO ENTRY FOR MASTER1,
MASTER2.

a. First taket the Loadbalancer port number and Private Ip address, I don't want load balancer to
expose to public therefore take private ip

cat /etc/haproxy/haproxy.cfg

=> the load balancer port we are using will get in configuration file, as below :

=> take load balancer machine private ip address such as below:


==> Endpoint is on Loadbalancer ip, so we have to modify parameter with load balancer ip address
and port number :

kubeadm init --control-plane-endpoint <loadbalancer-pvt ip>:<loadbalancer-port> --upload-certs

b. Now login to first master server as ROOt and initialize the kubeadm, below command : We are
haping multiple master server, with below command wer are generating API SERVER with
loadbalaner.

kubeadm init --control-plane-endpoint 172.31.38.238:6443 --upload-certs

c. After initializing these has given below output : Please see carefully, very important &VERY
IMPORTANT : Dont clear this screen, because once we clear we don't get
d. You can join multiple master or control pany by running below command each as ROOT user, taken
from above output

e. EXECUTE this one on another MASTER server, as below, As we have 3 Master server, so RUN it on
all master server: (Don't run kubeadm init, just take above output and run on other master server)

f. NOW, I will join the Worker server by RUNNING TOKEN :

Execute this Token in below Worker Machine


4. NOW, How I will talk to API Server, I want to see how many nodes are there, deploy the pod,
service, I have multi master kube service,

NOW we have to configure, kube ctl server, in any of master / worker server :

KUBE CTL can be configured to any server, that should have network connectivity to load balancer

a. NOW, we have to configure kubeconfig server :

b. NOW, to configure, KUBECONFIG, SWITCH to NORMAL USER In Load Balancer Server and create
a .kube directory :

c. I NEED kubeconfig file, which is there in Master machine

Go to any of the Master machine and take this file, as highligheted below, as seen below:

/etc/kubernets/admin.conf
d. NOW, I will cat the above file, as shown below in any of the Master Server:

#cat /etc/kubernets/admin.conf

e. COPY the CONFIGURATION FILE from START to END, which came after running cat
/etc/kubernets/admin.conf (Copy all the files below)
f. Create a file under .kube folder, as below = in load balancer server in home directory

$vi ~/ .kube/config and PASTE it under kube/config

PASTING :
g. Change the permission :

Highligthted in yellow, by running command in Home directory :

$sudo chown $(id -u):$(id -g) $HOME/.kube/config

h. As of now I have not installled, KUBECTL software, if I run this command, it will not give anything :

$kubectl cluster-info

I. You can install by using this comman given above as well below, but ignore this below because we
have to install using -- classic

$sudo snap install kubectl --classic


g. Now KUBECTL and KUBECONFIG Installed and we have to validate :

$kubectl cluster-info $kubectl get


nodes

h. As we can see below, All the machine are in NOT READY State, because we have not Deployed
Kubernets Networking :

5. KUBERNETS NETWORKING :

a. Install CNI (Contaniner Networking Interface)(Standard)and completed installation, I am installling


weave interface

# To verify, if kubectl is working or not, run the following command.

kubectl get pods -o wide --all-namespaces

#You will notice from the previous command, that all the pods are running except one: ‘kube-dns’. For
resolving this we will install a # pod network. To install the weave pod network, run the following
command, form Load balance where kube CTL installed :

$ kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d


'\n')"

b. Verify by running below commands:

$ kubectl get pods -n kube-system

ALso, This one IMPORTANT :

$kubectl get pods -n kube-system -o wide

We see below theree API server, three Controler-Mangaer server, Also theree etcd server is nothing
but DATASTORE, it will in sync with each other, The porceesing will request by any API server, but load
will share accross all the etcd data store.

After Installing Networking alll the PODS are running fine :

$ kubectl get pods -n kube-system

$ kubectl get nodes

All Nodes are UP and running :

========================================================================

KUBE CTL ON JENKINS is IMPORTANT


KUBE CTL can be install on any server, BUT IMPORTANT you CAN install on Jenkin server so that we
can create a PIPELINE with API SERVER in KUBERNETS and deploy the application.

1. Whathever way we can install kubectl, like here it is downloaded from INternet

a. Here we install from linux and serch command

b.
c. I don't have kube config file, therefore unable to run kubectl commands, I want that file:

1. create a directory : $ mkdir ~/.kube

2. vi ~/.kube/config ==> copy the kubernets config file in this.

3. Go to master and take the file from cat /etc/admin/kubernets.conf


4. This is just client, request is going to Load balance, becacuase my API is exposed to master server.

5.

6. cat /etc/haproxy/haproxy.conf

Load balancer is pointing to master server


7. Let deploy one application on client machine:

$vi mituntechapp.yml
vi mit

mituntechapp.yml

You might also like