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
# 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
# comment out line: `disabled_plugins = ["cri"]`
sudo vim /etc/containerd/config.toml
# restart containerd
sudo systemctl restart containerd
# replace "172.26.10.67" with the IP address of your machine
sudo kubeadm init --ignore-preflight-errors Swap --apiserver-advertise-address=172.26.10.67 --pod-network-cidr=10.244.0.0/16
# follow instructions to copy kubeconfig file to $HOME/.kube/config
kubectl create -f https://raw.githubusercontent.com/coreos/flannel/v0.22.0/Documentation/kube-flannel.yml
or
https://github.com/coreos/flannel/raw/master/Documentation/kube-flannel.yml
# set hugepage
sudo bash -c "echo 256 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
# restart kubelet
sudo systemctl restart kubelet
# check if kubelet has recognized huagepage
kubectl get nodes -oyaml | grep hugepages-2Mi
# check node status to be Ready
$kubectl get node
NAME STATUS ROLES AGE VERSION
ip-172-26-10-67.ap-northeast-1.compute.internal Ready control-plane 139m v1.27.4
# all pods should be Running
$kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-h5dcn 1/1 Running 0 138m
kube-system coredns-5d78c9869d-g4x5w 1/1 Running 0 139m
kube-system coredns-5d78c9869d-x8hmd 1/1 Running 0 139m
kube-system etcd-ip-172-26-10-67.ap-northeast-1.compute.internal 1/1 Running 0 139m
kube-system kube-apiserver-ip-172-26-10-67.ap-northeast-1.compute.internal 1/1 Running 0 139m
kube-system kube-controller-manager-ip-172-26-10-67.ap-northeast-1.compute.internal 1/1 Running 0 139m
kube-system kube-proxy-zs75b 1/1 Running 0 139m
kube-system kube-scheduler-ip-172-26-10-67.ap-northeast-1.compute.internal 1/1 Running 0 139m