0% found this document useful (0 votes)
17 views41 pages

Create Kubernetes Cluster1728210188222

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

Create Kubernetes Cluster1728210188222

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

Kubernetes installation Hands on done by Lokeshkumar

Create Kubernetes cluster using


Kubeadm on Ubuntu 22.04 LTS
by Lokeshkumar

In this Article we are going to learn How to Create Kubernetes cluster using Kubeadm on
Ubuntu 22.04 LTS and Join Worker Node to the Cluster.

Prerequisites:

• 2 or 3 Ubuntu 20.04 LTS System with Minimal Installation


• Minimum 2 or more CPU, 3 GB RAM.
• Disable SWAP on All node
• SSH Access with sudo privileges
Table of Contents
Firewall Ports/Inbound Traffic Ports for Kubernetes Cluster

S.No Protocol Direction Port Range Purpose Used By

Kubernetes API
TCP Inbound 6443* All
1 server
etcd server client kube-
TCP Inbound 2379-2380
2 API apiserver,etcd
Self, Control
TCP Inbound 10250 Kubelet API
3 plane

TCP Inbound 10251 kube-scheduler Self


4
kube-controller-
TCP Inbound 10252 Self
5 manager

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Master node :
You can clone the repository for reference.

git clone https://github.com/techiescamp/kubeadm-scripts

Step #1:IPtables to see bridged traffic


Execute the following commands on all the nodes for IPtables to see bridged traffic.

sudo modprobe overlay

sudo modprobe br_netfilter

# sysctl params required by setup, params persist across reboots


cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

# Apply sysctl params without reboot


sudo sysctl –system

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Step #2:Disable swap on all the Nodes


For kubeadm to work properly, you need to disable swap on all the nodes using the
following command.

sudo swapoff -a

(crontab -l 2>/dev/null; echo "@reboot /sbin/swapoff -a") | crontab - || true

Step #3:Install CRI-O Runtime On All The Nodes


Create the .conf file to load the modules at bootup

cat <<EOF | sudo tee /etc/modules-load.d/crio.conf

overlay

br_netfilter

EOF

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

# Set up required sysctl params, these persist across reboots.


cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

Execute the following commands to enable overlayFS & VxLan pod communication.

sudo modprobe overlay

sudo modprobe br_netfilter

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Set up required sysctl params, these persist across reboots.

cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf

net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward =1

net.bridge.bridge-nf-call-ip6tables = 1

EOF

Reload the parameters.

sudo sysctl –system

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Step #4:Install Kubeadm & Kubelet & Kubectl on all


Nodes
Install the required dependencies

Update your system packages:

sudo apt-get update

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Install apt-transport-https curl

sudo apt-get install -y apt-transport-https curl

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Add gpg keys

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

sudo vi /etc/apt/sources.list.d/kubernetes.list

Add this below lines in this file

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

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Lets install kubelet kubeadm kubectl

sudo apt-get update

sudo apt-get install -y kubelet kubeadm kubectl

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

sudo apt-mark hold kubelet kubeadm kubectl

ls

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Run the ./common.sh file (kubeadm-scripts/scripts) in this location on both nodes:

sudo ./common.sh

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

lastly you see like this

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Now you need to change master.sh file

sudo nano master.sh

PUBLIC_IP_ACCESS="false"

False replace with true

PUBLIC_IP_ACCESS="true"

By default I would be PUBLIC_IP_ACCESS="true" only but once we need verify that’s it

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

After using sudo ./master.sh the master / control plane will generate the token as mentioned below

the same token has to use in every node join with master then the communication will be establish in
between control plane and cluster

Now run the master.sh file

sudo ./master.sh

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

+ POD_CIDR=192.168.0.0/16

+ sudo kubeadm config images pull

[config/images] Pulled registry.k8s.io/kube-apiserver:v1.28.2

[config/images] Pulled registry.k8s.io/kube-controller-manager:v1.28.2

[config/images] Pulled registry.k8s.io/kube-scheduler:v1.28.2

[config/images] Pulled registry.k8s.io/kube-proxy:v1.28.2

[config/images] Pulled registry.k8s.io/pause:3.9

[config/images] Pulled registry.k8s.io/etcd:3.5.9-0

[config/images] Pulled registry.k8s.io/coredns/coredns:v1.10.1

+ [[ true == \f\a\l\s\e ]]

+ [[ true == \t\r\u\e ]]

++ curl ifconfig.me

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed


Kubernetes installation Hands on done by Lokeshkumar
https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

100 13 100 13 0 0 48 0 --:--:-- --:--:-- --:--:-- 48

++ echo ''

+ MASTER_PUBLIC_IP=43.205.242.73

+ sudo kubeadm init --control-plane-endpoint=43.205.242.73 --apiserver-cert-extra-


sans=43.205.242.73 --pod-network-cidr=192.168.0.0/16 --node-name ip-1-0-0-73 --ignore-preflight-
errors Swap

[init] Using Kubernetes version: v1.28.2

[preflight] Running pre-flight checks

[preflight] Pulling images required for setting up a Kubernetes cluster

[preflight] This might take a minute or two, depending on the speed of your internet connection

[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'

[certs] Using certificateDir folder "/etc/kubernetes/pki"

[certs] Generating "ca" certificate and key

[certs] Generating "apiserver" certificate and key

[certs] apiserver serving cert is signed for DNS names [ip-1-0-0-73 kubernetes kubernetes.default
kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 1.0.0.73
43.205.242.73]

[certs] Generating "apiserver-kubelet-client" certificate and key

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

[certs] Generating "front-proxy-ca" certificate and key

[certs] Generating "front-proxy-client" certificate and key

[certs] Generating "etcd/ca" certificate and key

[certs] Generating "etcd/server" certificate and key

[certs] etcd/server serving cert is signed for DNS names [ip-1-0-0-73 localhost] and IPs [1.0.0.73
127.0.0.1 ::1]

[certs] Generating "etcd/peer" certificate and key

[certs] etcd/peer serving cert is signed for DNS names [ip-1-0-0-73 localhost] and IPs [1.0.0.73
127.0.0.1 ::1]

[certs] Generating "etcd/healthcheck-client" certificate and key

[certs] Generating "apiserver-etcd-client" certificate and key

[certs] Generating "sa" key and public key

[kubeconfig] Using kubeconfig folder "/etc/kubernetes"

[kubeconfig] Writing "admin.conf" kubeconfig file

[kubeconfig] Writing "kubelet.conf" kubeconfig file

[kubeconfig] Writing "controller-manager.conf" kubeconfig file

[kubeconfig] Writing "scheduler.conf" kubeconfig file

[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"


Kubernetes installation Hands on done by Lokeshkumar
https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

[control-plane] Using manifest folder "/etc/kubernetes/manifests"

[control-plane] Creating static Pod manifest for "kube-apiserver"

[control-plane] Creating static Pod manifest for "kube-controller-manager"

[control-plane] Creating static Pod manifest for "kube-scheduler"

[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-


flags.env"

[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"

[kubelet-start] Starting the kubelet

[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory
"/etc/kubernetes/manifests". This can take up to 4m0s

[apiclient] All control plane components are healthy after 6.506746 seconds

[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-


system" Namespace

[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration


for the kubelets in the cluster

[upload-certs] Skipping phase. Please see --upload-certs

[mark-control-plane] Marking the node ip-1-0-0-73 as control-plane by adding the labels: [node-
role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

[mark-control-plane] Marking the node ip-1-0-0-73 as control-plane by adding the taints [node-
role.kubernetes.io/control-plane:NoSchedule]

[bootstrap-token] Using token: k7pcqe.rw7k3dik9mifkm4x

[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles

[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes

[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for
nodes to get long term certificate credentials

[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve
CSRs from a Node Bootstrap Token

[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates
in the cluster

[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace

[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client


certificate and key

[addons] Applied essential addon: CoreDNS

[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

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

Alternatively, if you are the root user, you can run:

export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.

Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of control-plane nodes by copying certificate authorities

and service account keys on each node and then running the following as root:

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

kubeadm join 43.205.242.73:6443 --token k7pcqe.rw7k3dik9mifkm4x \

--discovery-token-ca-cert-hash
sha256:f42bbb0341f5717ce53dc2a12ee753ec15d2bd02c80462bfa29187baa8394750 \

--control-plane

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 43.205.242.73:6443 --token k7pcqe.rw7k3dik9mifkm4x \

--discovery-token-ca-cert-hash
sha256:f42bbb0341f5717ce53dc2a12ee753ec15d2bd02c80462bfa29187baa8394750

+ mkdir -p /root/.kube

+ sudo cp -i /etc/kubernetes/admin.conf /root/.kube/config

++ id -u

++ id -g

+ sudo chown 0:0 /root/.kube/config

+ kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/tigera-


operator.yaml

namespace/tigera-operator created

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/bgpfilters.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/blockaffinities.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/caliconodestatuses.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/ipamblocks.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/ipamconfigs.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/ipamhandles.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/ipreservations.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/kubecontrollersconfigurations.crd.projectcalico.org
created

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/networksets.crd.projectcalico.org created

customresourcedefinition.apiextensions.k8s.io/apiservers.operator.tigera.io created

customresourcedefinition.apiextensions.k8s.io/imagesets.operator.tigera.io created

customresourcedefinition.apiextensions.k8s.io/installations.operator.tigera.io created

customresourcedefinition.apiextensions.k8s.io/tigerastatuses.operator.tigera.io created

serviceaccount/tigera-operator created

clusterrole.rbac.authorization.k8s.io/tigera-operator created

clusterrolebinding.rbac.authorization.k8s.io/tigera-operator created

deployment.apps/tigera-operator created

+ curl https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/custom-
resources.yaml -O

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 824 100 824 0 0 1943 0 --:--:-- --:--:-- --:--:-- 1947

+ kubectl create -f custom-resources.yaml

installation.operator.tigera.io/default created

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

apiserver.operator.tigera.io/default created

root@ip-1-0-0-73:~/kubeadm-scripts/scripts#

Use the following commands from the output to create the kubeconfig in master so
that you can use kubectl to interact with cluster API

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

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

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Master node setup completed


Referred by :
https://www.fosstechnix.com/kubernetes-cluster-using-kubeadm-on-ubuntu-22/

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Kubernetes Worker node setup:


Prerequisites:

• 2 or 3 Ubuntu 20.04 LTS System with Minimal Installation


• Minimum 2 or more CPU, 3 GB RAM.
• Disable SWAP on All node
• SSH Access with sudo privileges

Table of Contents
Firewall Ports/Inbound Traffic Ports for Kubernetes Cluster

Worker node(s) Ports


S.No Protocol Direction Port Range Purpose Used By
Self, Control
1 TCP Inbound 10250 Kubelet API
plane
2 TCP Inbound 30000-32767 NodePort Services All

You can clone the repository for reference.

git clone https://github.com/techiescamp/kubeadm-scripts

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Step #1:IPtables to see bridged traffic

Execute the following commands on all the nodes for IPtables to see bridged traffic.

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf

overlay

br_netfilter

EOF

sudo modprobe overlay


sudo modprobe br_netfilter

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

# Apply sysctl params without reboot sudo sysctl –system


sudo sysctl --system

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Step #2:Disable swap on all the Nodes


For kubeadm to work properly, you need to disable swap on all the nodes using the
following command.

sudo swapoff -a

(crontab -l 2>/dev/null; echo "@reboot /sbin/swapoff -a") | crontab - || true

Step #3:Install CRI-O Runtime On All The Nodes


Create the .conf file to load the modules at bootup

cat <<EOF | sudo tee /etc/modules-load.d/crio.conf

overlay

br_netfilter

EOF

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

# Set up required sysctl params, these persist across reboots.

cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward = 1

net.bridge.bridge-nf-call-ip6tables = 1

EOF

Execute the following commands to enable overlayFS & VxLan pod communication.

sudo modprobe overlay

sudo modprobe br_netfilter

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Set up required sysctl params, these persist across reboots.

cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf

net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward =1

net.bridge.bridge-nf-call-ip6tables = 1

EOF

Reload the parameters.

sudo sysctl --system

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Step #4:Install Kubeadm & Kubelet & Kubectl on all Nodes


Install the required dependencies

Update your system packages:

sudo apt-get update

Install apt-transport-https curl

sudo apt-get install -y apt-transport-https curl

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Add gpg keys

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

sudo vi /etc/apt/sources.list.d/kubernetes.list

Add this below lines in this file

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

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Lets install kubelet kubeadm kubectl

sudo apt-get update

sudo apt-get install -y kubelet kubeadm kubectl

sudo apt-mark hold kubelet kubeadm kubectl

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Run the ./common.sh file (kubeadm-scripts/scripts) in this location on both nodes:

sudo ./common.sh

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

Now you need to change master.sh file

sudo nano master.sh

PUBLIC_IP_ACCESS="false"

False replace with true

PUBLIC_IP_ACCESS="true"

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

note : should not run master.sh file in worker nodes , it is for only master node

After setting up and installation check the nodes in Master as below


mentioned command

kubectl get node or kubectl get all

Join node into master by using token which generated by


master

note : same token should use for all the nodes

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244
Kubernetes installation Hands on done by Lokeshkumar

kubectl get po -n kube-system

In master check the nodes status with below command

kubectl get nodes

Kubernetes installation Hands on done by Lokeshkumar


https://www.linkedin.com/in/lokeshkumar-%E2%98%81%EF%B8%8F-4a2860244

You might also like