Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up Kubernetes v1.28.9 with kubeadm on CentOS 7

Tech 1

This guide walks through deploying a production-ready Kubernetes cluster using kubeadm on CentOS 7, targeting version 1.28.9. The topology consists of one control-plane node and two worker nodes.

Kernel Upgrade for Stability

Older kernel versions may cause unexpected behavior in container runtimes and networking subsystems. Upgrade to the long-term supported (LTS) kernel:

# List current boot entries
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

# Import ELRepo GPG key and install repository
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum -y install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm

# Install LTS kernel
yum --enablerepo="elrepo-kernel" -y install kernel-lt.x86_64

# Set default boot entry to new kernel and regenerate config
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg

# Reboot and verify
reboot
# After reboot:
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

Disable Firewall

Ensure consistant network policies by disabling firewalld:

systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld | grep Active

Disable Swap

Kubernetes requires swap to be disabled:

# Comment out swap lines in fstab and deactivate immediately
sed -i '/swap/d' /etc/fstab
swapoff -a

Disable SELinux

Set SELinux to permissive mode permanently:

sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0

Configure Hostname Resolution

Add static host mappings to /etc/hosts. Replace IPs and names as needed:

cat <<EOF >> /etc/hosts
192.168.18.219 master
192.168.18.220 node01
192.168.18.221 node02
EOF

Set Unique Hostnames

Apply appropriate hostnames across nodes:

# On control plane
hostnamectl set-hostname master

# On first worker
hostnamectl set-hostname node01

# On second worker
hostnamectl set-hostname node02

# Confirm and reload network context
hostname
systemctl restart systemd-hostnamed

Synchronize System Time

Use chrony to maintain time consistency across all node:

yum install -y chrony
systemctl enable --now chronyd
chronyc sources -v
# Verify output includes at least one active NTP source
date

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.