...
The driver of docker's cgroup needs to be consistent with that of kubelet. It is recommended to set it to systemd.
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
docker info | grep -i cgroup |
Check the current configuration, if it is the system in the figure below, skip the follow-up and go directly to the third section
Execute screenshot
If it is cgroupfs, add the following statement
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
vim /etc/docker/daemon.json # add this { "exec-opts": ["native.cgroupdriver=systemd"] } |
Restart to check for changes
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
systemctl daemon-reload && systemctl restart docker docker info | grep -i cgroup |
...
If it is the version inconsistent, you need to uninstall it through yum remove ${name}.
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
yum list installed | grep kube |
Execute screenshot
3.2 Install kubelet kubeadm kubectl version 1.23.7
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
yum -y install kubelet-1.23.7 kubeadm-1.23.7 kubectl-1.23.7 |
Execute screenshot
3.3 Verify installation
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
kubelet --version kubeadm version kubectl version |
Execute screenshot
4 Initialize the master
Execute only on the master node. The main content is to pull the image of version 1.23.7, initialize the master node, and configure the calico network plug-in for the master node
4.1 Pull the k8s image Pull the k8s image
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master kubeadm config images list --kubernetes-version=v1.23.7 |sed -e 's/^/docker pull /g' -e 's#k8s.gcr.io#registry.aliyuncs.com/google_containers#g' |sh -x docker pull registry.aliyuncs.com/google_containers/coredns:v1.8.6 docker images |
Execute screenshot
Please make sure that the above 7 images have been pulled down
4.2 Init master
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.23.7 --pod-network-cidr=10.10.0.0/16 |
Execute screenshot
You can see that the prompt initialization is successful, and at the end of the prompt, the way to join the worker node is provided. The prompt executes the following command to use kubectl normally
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config |
Execute screenshot
Note that if an error occurs and you need to re-init, you need to execute the following statement first to ensure that kubeadm is re-executed normally
...
Here select cilium as the network plug-in
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master curl -L --remote-name-all https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz tar -zxvf cilium-linux-amd64.tar.gz mv cilium /usr/local/bin/ cilium version cilium install |
Execute screenshot
5 Initialize workers
Add worker nodes to the cluster
...
The joining of the worker node needs to initialize the join statement given by the master. If you forget this statement, execute the following statement on the master node machine to get it again.
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master kubeadm token create --print-join-command |
Execute screenshot
5.2 Join the master node
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# worker, change the ip,token and cert-hash to your's kubeadm join ${YOUR IP} --token ${YOUR TOKEN} --discovery-token-ca-cert-hash ${YOUR CERT HASH} |
When you have the join statement, copy it and execute it on the worker node, you can see
Execute screenshot
Note that if an error occurs and you need to re-init, you need to execute the following statement first to ensure that kubeadm is re-executed normally
...
After the worker is added, you can execute the following command on the master machine to confirm the newly added node.
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master kubectl get nodes |
Execute screenshot
6
...
Install karmada
6.1 Install the Karmada kubectl plugin
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# master wget https://github.com/karmada-io/karmada/releases/download/v1.4.0/kubectl-karmada-linux-amd64.tgz tar -zxf kubectl-karmada-linux-amd64.tgz mv kubectl-karmada /usr/bin |
Execute screenshot
6.2 Install karamda via karmadactl
Install karamda via kubectl. China mainland registry mirror can be specified by using kube-image-mirror-country
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
kubectl karmada init --kube-image-registry=registry.cn-hangzhou.aliyuncs.com/google_containers |
...
Execute screenshot
Check all your pod is READY
Execute command
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
kubectl get po -A |
Execute screenshot
referenceReference
https://lazytoki.cn/index.php/archives/4/
...