Skip to content

Instantly share code, notes, and snippets.

@giacchetta
Last active August 5, 2024 18:53
Show Gist options
  • Save giacchetta/07984985863b7abb2444973a704816ae to your computer and use it in GitHub Desktop.
Save giacchetta/07984985863b7abb2444973a704816ae to your computer and use it in GitHub Desktop.
Kubernetes 1.30 on Fedora 40

Kubernetes 1.30 on Fedora 40

  1. We need some required packages installed before we actually start with the process. Thus, we need to ensure git is installed.
  • $ dnf install –y git
  1. Once git was installed, we should clone our repository with all the scripts ready to execute. Please, copy the whole URL to ensure the correct files download.
  • $ git clone https://gist.github.com/giacchetta/$(dig +short kubernetes-130-fedora-40.sow.ar txt | sed 's/"//g')
  1. While this is not mandatory, you can find very useful temux if you use a Linux console. If you are on a Terminal, it not necessary at all. Access now to the downloaded folder from our previous git clone. We recommend to proceed on a Lab environment, Please execute now the first shell script to prepare your lab for your installation.
  • $ tmux
  • $ cd 07984985863b7abb2444973a704816ae
  • $ bash –x 1.prepare.sh
  1. Now that we have properly installed all required components, we can proceed with the Kubernetes Cluster installation.
  • $ bash –x 2.install.sh
  1. Congratulations! You have finished you Kubernetes installation process but now we need to ensure the cluster is ready and working, we can test it running the test script that will create an nginx deployment and test a web page. Since we are using a Linux console, we need a console browser or you could also use curl.
  • $ bash –x 3.test.sh
  • $ lynx 10.244.0.?
  1. Finally, we do a complete lab clean up removing the Cluster and all the required packages installed before.
  • $ bash –x 4.uninstall.sh
#/bin/bash
#Disable and Stop firewalld
sudo systemctl disable --now firewalld
# Remove Swap
sudo dnf remove -y zram-generator-defaults
sudo swapoff -a
# Install K8s required packages
dnf install -y iproute-tc containerd containernetworking-plugins
# Enable Kernel modules
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# Enable Kernel flags
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
sudo sysctl --system
# Configura Containerd
sudo bash -c 'containerd config default > /etc/containerd/config.toml'
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
sudo sed -i 's/opt\/cni\/bin/usr\/libexec\/cni/' /etc/containerd/config.toml
sudo ln -s /opt/cni/bin/flannel /usr/libexec/cni/
sudo systemctl enable --now containerd
# Change SELinux
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# Add Kubernetes Repo
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF
# Install Kubernetes
sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet
#/bin/bash
# Configure Kubernetes Cluster
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
#Install Flannel
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply \
-f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
kubectl label nodes --all node.kubernetes.io/exclude-from-external-load-balancers-
#/bin/bash
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply -f https://k8s.io/examples/application/deployment.yaml
sleep 10
kubectl get pods -l app=nginx -o wide
#/bin/bash
sudo kubeadm --kubeconfig /etc/kubernetes/admin.conf reset -f
sudo dnf -y remove iproute-tc containerd containernetworking-plugins kubelet kubeadm kubectl
sudo setenforce 1
sudo sed -i 's/^SELINUX=permissive$/SELINUX=enforcing/' /etc/selinux/config
sudo dnf -y install zram-generator-defaults
sudo swapon -a
sudo rm -f /etc/yum.repos.d/kubernetes.repo /etc/modules-load.d/k8s.conf /etc/sysctl.d/k8s.conf
sudo sysctl --system
sudo rmmod overlay
sudo rmmod br_netfilter
sudo systemctl enable --now firewalld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment