Kubernetes K8s Setup on CentOS:7 with easy steps.

Let's learn together and serve the society, Make India Proud.
Search for a command to run...

Let's learn together and serve the society, Make India Proud.
No comments yet. Be the first to comment.
Kubernetes, or K8s, is a system for managing containerized apps in a clustered environment. It provides efficient ways of managing distributed components across various infrastructures.
Your quick start guide to setting up Prometheus on a Linux VM.
How Real Teams Deploy to Production: Kubernetes Deployment Strategies

Hello, this is Rakesh Kumar — your DevOps project practice trainer and your friend.I’m back again with a brilliant DevOps project that is not only production-ready but also highly valuable for real-world learning. This project is designed to take you...

Introduction If you are learning DevOps, you may be asking yourself: 👉 “I already know Bash scripting. Do I really need Python? Can’t I do the same work with Bash?” This is a common question, and the truth is: No, you don’t always need Python – Bas...

Project Idea – Build Your Own Mini Shell

Why every DevOps engineer needs Python in their toolkit

Hey everyone! In this article, we'll learn how to set up a Kubernetes (k8s) cluster on a Linux CentOS 7 machine. You can do this either on cloud servers or virtual machines within your infrastructure.
If you are trying to set up a Kubernetes (k8s) cluster on an Ubuntu machine, try this article link: https://rakeshkumarjangid.hashnode.dev/how-to-setup-kubernetes-cluster-over-cloud-on-ubuntu-os, So let's start...
| Cluster Type | Specifications | OS Type |
| On-Primise VM (1 Master + 2 Worker) | 4 GRB RAM, 2 Core, 20 GB storage in each machine | Centos:7 |
| Cloud AWS | T2.Medium or up | AWS Linux |
#nmcli# cat /etc/os-release
# nmcli con show
NAME UUID TYPE DEVICE
ens160 4443b0e3-1b19-3b0e-9861-7f0fbf825f6c ethernet ens160
| VMs Nodes-Private-IP | VMs Node-Hostname |
| 192.168.1.1 | master.localhost.com |
| 192.168.1.2 | w1.localhost.com |
| 192.168.1.3 | w2.localhost.com |
# hostnamectl set-hostname master.localhost.com && exec bash
# nmcli con mod ens160 ipv4.addresses 192.168.1.1/24 ipv4.gateway 192.168.1.255 ipv4.dns 8.8.8.8
# nmcli con up ens160
/etc/sysconfig/network-scripts/ifcfg-ensp* file.# vi /etc/sysconfig/network-scripts/ifcfg-ensp***
IPADDR= ?
NETMASK= ?
GATEWAY=?
DNS1=?
/etc/hosts file# vi /etc/hosts
192.168.1.1 www.master.localhost.com
192.168.1.2 www.w1.localhost.com
192.168.1.3 www.w2.localhost.com
:wq!
# swapoff -a
# sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
# setenforce 0
# sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# systemctl disable firewalld && systemctl stop firewalld
# free -h
# sestatus
# systemctl statuts firewalld
# ssh-keygen -t rsa
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.X
# yum-config-manager --add-repo https://download.docker.com/linux/centos/dockerce.repo
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum install docker-ce-20* -y
# systemctl start docker && systemctl enable docker
# cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
# sysctl --system
# cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
# yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
# systemctl restart kubelet ; systemctl enable kubelet ; systemctl status kubelet
# systemctl enable docker && systemctl restart docker
(On Master Node only)# kubeadm init
# echo "kubeadm join 172.31.4.165:6443 --token kw9d4k.l44fcziztb3br21a \
--discovery-token-ca-cert-hash
sha256:2952821ac60c0ddb079cc82bd621a72e61aae08a4e700c4f8d457058d7f51dd7" > ~/join.txt
MASTER NODE Only with regular user.$ mkdir -p $HOME/.kube
$ cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ chown $(id -u):$(id -g) $HOME/.kube/config
(Execute only on Master Node) → ( Treated as Router)$ https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
kubeadm join> code and copy it at each worker node.# kubeadm join 172.31.4.165:6443 --token kw9d4k.l44fcziztb3br21a \
--discovery-token-ca-cert-hash
sha256:2952821ac60c0ddb079cc82bd621a72e61aae08a4e700c4f8d457058d7f51dd7
# kubeadm token create --print-join-command
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master.localhost.com Ready master 1d 1.27.2 192.168.1.1 <none> CentOS Linux 7 (Core) 4.19.0-19-amd64 docker://20.10.7
w1.localhost.com Ready <none> 1d 1.27.2 192.168.1.2 <none> CentOS Linux 7 (Core) 4.19.0-19-amd64 docker://20.10.7
w2.localhost.com Ready <none> 1d 1.27.2 192.168.1.3 <none> CentOS Linux 7 (Core) 4.19.0-19-amd64 docker://20.10.7
$ kubectl get ns
$ kubectl get pods -n kube-system -o wide
$ kubect api-resources
$ kubectl get po -n kube-system -o wide
Congratulations to all. Thanks you sir