Hi
I’m trying to get kubernetes installed on CentOS 8, but there seems to be a version mismatch with docker-ce, selinux and containerd.io could i get a functioning combination of version numbers?
i followed How to Install a Kubernetes Cluster on CentOS 8 click by click.
Thanks in advance
I didn’t really put much effort into this, but just doing this seems to work for me.
Edited: Containerd needs to be reloaded after Docker is configured.
I needed dnf-utils and tc for this setup.
# dnf install -y dnf-utils tc
Some stuff related to bridged networks and iptables.
# cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
# cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
# sysctl --system
Add docker repo, install docker and containerd.
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# dnf install -y docker-ce docker-ce-cli containerd.io
Configure docker for the cgroup driver.
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
Enable and start containerd and docker.
# systemctl enable containerd
# systemctl restart containerd
# systemctl enable docker
# systemctl daemon-reload
# systemctl restart docker
Add the Kubernetes repo.
# 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
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kubelet kubeadm kubectl
EOF
Disabling selinux is lazy, but it will make just getting things up easier.
# setenforce 0
# sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
Install kube tools.
# dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
# systemctl enable --now kubelet
Initialize the cluster.
# kubeadm init --pod-network-cidr=192.168.0.0/16
Export the admin’s kubeconfig so we can use kubectl
.
# export KUBECONFIG=/etc/kubernetes/admin.conf
You will see that coredns is not ready yet.
# kubectl get pods -A
Add a CNI then wait for things to come up.
# kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
# kubectl get pods -A --watch
Things are now runnings. There is 1 coredns replica that isn’t up. That is because I just didn’t have the sufficient CPU resources available.
# kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-58497c65d5-hjpk6 1/1 Running 0 10m
kube-system calico-node-dxq7h 1/1 Running 0 10m
kube-system coredns-65595d68cf-vgv5m 1/1 Running 0 36s
kube-system coredns-65595d68cf-z6s5x 1/1 Running 0 36s
kube-system etcd-c01 1/1 Running 0 12m
kube-system kube-apiserver-c01 1/1 Running 0 12m
kube-system kube-controller-manager-c01 1/1 Running 0 12m
kube-system kube-proxy-r9r5w 1/1 Running 0 12m
kube-system kube-scheduler-c01 1/1 Running 0 12m
I had to remove the taint because the node is a master.
# kubectl get nodes
NAME STATUS ROLES AGE VERSION
c01 Ready control-plane,master 14m v1.22.1
# kubectl taint nodes c01 node-role.kubernetes.io/master-
After this I can now run nginx.
# kubectl run nginx-test --image nginx
pod/nginx-test created
# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-test 1/1 Running 0 116s