新 Node 操作


root@k8s-master-u2404-4-20-102:~# hostnamectl set-hostname k8s-master-u2404-4-20-102
root@k8s-master-u2404-4-20-102:~# cat /etc/netplan/50-cloud-init.yaml 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: false
            dhcp6: false
            addresses: [172.16.101.102/24]
            gateway4: 172.16.101.2
            nameservers:
              addresses: [114.114.114.114, 8.8.8.8]
    version: 2

root@k8s-master-u2404-4-20-102:~# netplan apply

** (generate:1718): WARNING **: 00:15:59.532: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:1717): WARNING **: 00:15:59.850: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (process:1717): WARNING **: 00:15:59.947: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

Master 操作


root@k8s-master-u2404-4-20-101:~# scp -r /opt/kubernetes root@172.16.101.102:/opt/

root@k8s-master-u2404-4-20-101:~# scp /opt/kubernetes/ssl/ca.pem root@172.16.101.102:/opt/kubernetes/ssl

root@k8s-master-u2404-4-20-101:~# scp -r /usr/lib/systemd/system/{kubelet,kube-proxy}.service root@172.16.101.102:/usr/lib/systemd/system

新 Node 操作

root@k8s-master-u2404-4-20-102:~# rm -rf /opt/kubernetes/cfg/kubelet.kubeconfig 
root@k8s-master-u2404-4-20-102:~# rm -rf /opt/kubernetes/ssl/kubelet*
root@k8s-master-u2404-4-20-102:~# rm -rf /opt/kubernetes/logs/*

root@k8s-master-u2404-4-20-102:~# cat /opt/kubernetes/cfg/kubelet.conf 
KUBELET_OPTS=" \
--v=2 \
--hostname-override=k8s-master-u2404-4-20-102 \
--kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig \
--bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig \
--config=/opt/kubernetes/cfg/kubelet-config.yml \
--cert-dir=/opt/kubernetes/ssl \
--runtime-request-timeout=15m  \
--container-runtime-endpoint=unix:///run/cri-dockerd.sock \
--cgroup-driver=systemd \
--node-labels=node.kubernetes.io/node=''"

root@k8s-master-u2404-4-20-102:~# cat /opt/kubernetes/cfg/kube-proxy-config.yml
kind: KubeProxyConfiguration
apiVersion: kubeproxy.config.k8s.io/v1alpha1
bindAddress: 0.0.0.0
metricsBindAddress: 0.0.0.0:10249
clientConnection:
  kubeconfig: /opt/kubernetes/cfg/kube-proxy.kubeconfig
hostnameOverride: "k8s-master-u2404-4-20-102"
clusterCIDR: 10.244.0.0/16
mode: ipvs
ipvs:
  scheduler: "rr"
iptables:
  masqueradeAll: true

root@k8s-master-u2404-4-20-102:~# systemctl daemon-reload
root@k8s-master-u2404-4-20-102:~# systemctl start kubelet kube-proxy
root@k8s-master-u2404-4-20-102:~# systemctl enable kubelet kube-proxy
Created symlink /etc/systemd/system/multi-user.target.wants/kubelet.service → /usr/lib/systemd/system/kubelet.service.
Created symlink /etc/systemd/system/multi-user.target.wants/kube-proxy.service → /usr/lib/systemd/system/kube-proxy.service.

Master 操作


root@k8s-master-u2404-4-20-101:~# kubectl get csr
NAME                                                   AGE   SIGNERNAME                                    REQUESTOR           REQUESTEDDURATION   CONDITION
node-csr-1x0lxKKp0glEfMqH5hf2xtzxZrmElOl165FMzkWUndg   54m   kubernetes.io/kube-apiserver-client-kubelet   kubelet-bootstrap   <none>              Pending
node-csr-dGg7j9x3aoZoziWOX4HDeizANJtqbIRjzGQyAXfEWaQ   95m   kubernetes.io/kube-apiserver-client-kubelet   kubelet-bootstrap   <none>              Approved,Issued

root@k8s-master-u2404-4-20-101:~# kubectl certificate approve node-csr-1x0lxKKp0glEfMqH5hf2xtzxZrmElOl165FMzkWUndg
certificatesigningrequest.certificates.k8s.io/node-csr-1x0lxKKp0glEfMqH5hf2xtzxZrmElOl165FMzkWUndg approved  

错误记录

root@k8s-u-2404-101:~# kubectl get pods -A
NAMESPACE     NAME                                      READY   STATUS                  RESTARTS       AGE
kube-system   calico-kube-controllers-ddf655445-zq5zp   1/1     Running                 0              22h
kube-system   calico-node-h6zm6                         1/1     Running                 0              22h
kube-system   calico-node-z2s2w                         0/1     Init:CrashLoopBackOff   32 (53s ago)   70m

1、首先查看kube-proxy是否启动,如果未启动,手动启动看看少什么,目前我这里主要是少ipset
apt -y install ipset

2、无法拉取镜像
docker pull calico/cni:v3.27.3

3、查看node的kube-proxy,重启或者查看日志报错

4、如果以上都无法解决,重新部署

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注