kubernetes tutorial | Install K8s Cluster using kubeadm | Deploy a 3 node K8s cluster using kubeadm

preview_player
Показать описание
*CERTIFIED KUBERNETES ADMINISTRATOR*
-------------------------------------------------------------------------

*USEFUL LINKS*
---------------------------
*Install Kubeadm*

*Container Runtimes*

*Install Docker CRI*

*Deploy a Kubernetes Cluster*

*POD NETWORKING*

(Weavenet CNI Plugin)

===============================
#cka #kubernetes #k8s #containers

*DEMO STEPS*
--------------------------

*Step 1: Pre-requisites*

1.a.. Check the OS, Hardware Configurations & Network connectivity
1.b.. Turn off the swap & firewall

$ sudo swapoff -a
$ sudo systemctl stop firewalld
$ sudo systemctl disable firewalld

*Step 2. Configure the local IP tables to see the Bridged Traffic*

2.a.. Enable the bridged traffic
$ lsmod | grep br_netfilter
$ sudo modprobe br_netfilter

Content:
br_netfilter

Content:

$ sudo sysctl --system

*Step 3. Install Docker as a Container RUNTIME*

3.a.. Uninstall any Older versions

$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

3.b.. Install Yum Utilities | Config Manager

$ sudo yum install -y yum-utils

3.c.. Setup the Docker Repository

3.d.. Install Docker Engine, Docker CLI, Docker RUNTIME

*Step 4. Configure Docker Daemon for cgroups management & Start Docker*

4.a.. Create directory
$ sudo mkdir /etc/docker

Content:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ sudo systemctl enable docker
$ sudo systemctl status docker

*Step 5. Install kubeadm, kubectl, kubelet*

Content:

[kubernetes]
name=Kubernetes
enabled=1
gpgcheck=1
repo_gpgcheck=1
exclude=kubelet kubeadm kubectl

5.b.. Set SELinux in permissive mode (effectively disabling it)

$ sudo setenforce 0
$ sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
$ sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
$ sudo systemctl enable --now kubelet

*Step 6. Configuring a cgroup driver*

Ignore if docker is used as a CRI

*Step 7. Deploy a kubernetes cluster using kubeadm*

# Run only in Master node

$ kubeadm init --pod-network-cidr=10.10.0.0/16 --apiserver-advertise-address=master_nodeIP

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

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

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

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

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

kubeadm join 192.168.74.10:6443 --token l431j0.0tz0bbuu7hj64lw5 \
--discovery-token-ca-cert-hash sha256:1743115f18a7b8761105ff5465cd1aeed74a2e8a3f326405da61681d07fdb0e0

*Step 8. Install CNI for POD Networking*

# Run only in Master node

Weave Networks:

*Step 9. Join the worker nodes to the master*

# Run in Worker Nodes as "Root"

kubeadm join 192.168.74.10:6443 --token l431j0.0tz0bbuu7hj64lw5 \
--discovery-token-ca-cert-hash sha256:1743115f18a7b8761105ff5465cd1aeed74a2e8a3f326405da61681d07fdb0e0

# Make sure to replace your tokens and IP's in the above command accordingly

*Step 10. Access the K8s Cluster & Deploy a POD*

kubectl run vsparkz --image nginx
Рекомендации по теме
Комментарии
Автор

from brazil 🇧🇷
tnks, man! awesome video, it helped me so much ❤️❤️

Dellabeneta
Автор

Thank you very much!!! You saved my life!!!

凌甘-zy
Автор

Why are we using docker in step 3 instead of Kubernetes?

puppyqwr
Автор

Hi again.
After making it work. It is time for me to create a snapshot of each server.
What it is the step by step procedure to properly shutdown the K8s cluster.
Which commands, services, and so should be stopped and in what order?

Thank you again and regards

CarlosMad
Автор

to start cluster why i need to run from regular user ???

khalilmaatoug
Автор

Had you video that elaborates on Step 6 ? Perhaps with podman/cri-o ?

horlacsd
Автор

Thanks for the great tutorial; do you have a list of task to be done when when building a AKS cluster on azure? (so K8 cluster with cloud control manager)

plechat
Автор

Why master node needs docker runtime and kubelet, please can you explain

bharavikumar
Автор

Hi bro, why the pod is only ddployed on worker1 not both in the last step. Thank

iotsharingdotcom
Автор

I don't get it, shouldn't be able to get info and manage the cluster from our host ( in our case is windows ) and not from the master itself, I mean
when you do Kubectl get nodes, we Get all the nodes but why are we on the master node ?
aren't we supposed to see the cluster from another host not from the master itself

ceciivanov
Автор

Hey bro can you please make a video on gcp cloud KMS or secret Manager

nishitkumar
Автор

I got strucked at this

Unfortunately, an error has occurred:
timed out waiting for the condition

This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- 'systemctl status kubelet'
- 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.

Please resolve the issue

SANDEEPSANDY-yfry
Автор

hi, i have a question, why you run
kubectl run vspark --image nginx
in master-node,
when you get pod, it show node worker01?

fullstack_gamer
Автор

I'm getting yum not located. Not able to install it on ubuntu. Any fix?

akashpawar
Автор

I want to ask one more thing regarding Kubeadm init, if i shut down accidently the Master node having running the all the services, if master gets shut down accidently how could run again the same cluster upon rebooting the system? Given that Now Master VM ip address is changed. Should i have to do from scratch again all installations? Please need guidelines please..

EhsanIrshad
Автор

currently, docker not allowing us to use as a container runtime why?

sreekanthkamatham
Автор

hi bro how to create 3 node in terminal with different ip address

muhammedfahad
Автор

Hello, I have errors on step 7, the kubelet service is down and when running its command /usr/bin/kubelet, I got an error about step 6 and cgroups:

"Failed to get the kubelet's cgroup. Kubelet system container metrics may be missing." err="cpu and memory cgroup hierarchy not unified. cpu: /, memory:

cientifiqus
Автор

Thanks for the tutorial, when I tried to do kubeadm init I was getting below error. Can you please help me out.
[ERROR CRI]: container runtime is not running: output: time="2023-08-14T10:39:16Z" level=fatal msg="validate service connection: CRI v1 runtime API is not implemented for endpoint rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService"

sathishkumar
Автор

I have got this error when using kubernetes init :

[init] Using Kubernetes version: v1.26.0
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR CRI]: container runtime is not running: output: E0106 21:48:19.883611 25351 remote_runtime.go:948] "Status from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service
time="2023-01-06T21:48:19Z" level=fatal msg="getting status of runtime: rpc error: code = Unimplemented desc = unknown service
, error: exit status 1
[ERROR contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with
To see the stack trace of this error execute with --v=5 or higher

formationdevops