k8s deploy
install kubelet kubeadm kubectl
- Step1
1 | Set SELinux in permissive mode (effectively disabling it) |
- Step2
1 | cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo |
- step3
1 | sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes |
install Container Runtimes
1 | Runtime Path to Unix domain socket |
- Enable ipv4 packet forward
1 | sysctl params required by setup, params persist across reboots |
- cgroup driver
To set systemd
as the cgroup driver, edit the KubeletConfiguration
option of cgroupDriver
and set it to systemd
. For example:
1 | apiVersion: kubelet.config.k8s.io/v1beta1 |
containerd
stop docker service (is necessary ?)
init config.toml
1
sudo containerd config default | sudo tee /etc/containerd/config.toml
config
Configuring the systemd
cgroup driver
sudo vim /etc/containerd/config.toml
1 | #disabled_plugins = ["cri"] |
sudo systemctl restart containerd
check containerd version
1
2containerd --version
containerd containerd.io 1.7.19
CRI-O
set repo
1
2
3
4
5
6
7
8cat <<EOF | sudo tee /etc/yum.repos.d/cri-o.repo
[cri-o]
name=CRI-O
baseurl=https://mirrors.ustc.edu.cn/kubernetes/addons:/cri-o:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.ustc.edu.cn/kubernetes/addons:/cri-o:/stable:/v1.30/rpm/repodata/repomd.xml.key
EOFinstall
1
2
3dnf install -y container-selinux
dnf install -y cri-o
systemctl start crio.servicebootstrap cluster
1
2
3
4
5swapoff -a
modprobe br_netfilter
sysctl -w net.ipv4.ip_forward=1
kubeadm init
Docker Engine
install docker (existing)
install
cri-dockerd
1
2
3
4
5
6
7
8
9
10
11
12
13
14extract tgz
tar -xzvf cri-dockerd-0.3.15.amd64.tgz
sudo mv ./cri-dockerd /usr/local/bin/
wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.service
wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.socket
sudo mv cri-docker.socket cri-docker.service /etc/systemd/system/
sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
enable service
sudo systemctl daemon-reload
sudo systemctl enable cri-docker.service
sudo systemctl enable --now cri-docker.socket
sudo systemctl status cri-docker.socket
config crictl
- Config containerd
vim /etc/crictl.yaml
1 | runtime-endpoint: unix:///run/containerd/containerd.sock |
- verify mirror
1 | sudo crictl info |
kubeadm deploy cluster
Initializing control-plane node
1 | sudo kubeadm config images pull --config kubeadm.conf |
(optional) resert (back to kubeadm init)
1
sudo kubeadm reset --cri-socket unix:///var/run/containerd/containerd.sock
Use kubectl
1
2
3mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/configcheck the CoreDNS Pod is
Running
1
2
3
4
5
6
7
8
9
10kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-7b5944fdcf-mgwq2 1/1 Running 0 4h22m
kube-system coredns-7b5944fdcf-sxfvt 1/1 Running 0 4h22m
kube-system etcd-dingo7232 1/1 Running 1 4h22m
kube-system kube-apiserver-dingo7232 1/1 Running 1 4h22m
kube-system kube-controller-manager-dingo7232 1/1 Running 1 4h22m
kube-system kube-proxy-w2lfk 1/1 Running 0 4h22m
kube-system kube-scheduler-dingo7232 1/1 Running 1 4h22m
join node
1 | sudo kubeadm join --token <token> <control-plane-host>:<control-plane-port> --discovery-token-ca-cert-hash sha256:<hash> |
- Check on control-plane
1 | kubectl get nodes |
optional
- other node use kubectl
1 | scp root@<control-plane-host>:/etc/kubernetes/admin.conf . |