kubernetes(kubeadm)集群的安装问题总结

1、kubelet与docker驱动不一致(网上其他解决文案各种尝试无效,最后使用如下方法解决)
异常【kubelet cgroup driver:cn ( 5 E +groupfs跟docker cgroup driver:systemd不一致

异常描述如下:
failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
  • 原因分析
    kubelet文件驱动默认cgroupfs, 而安装的dockerw B # o ? c使用的文件驱动是systemd, 造成不一致, 导致镜像d [ E * R y S无法启动
  • 解决方法:
    1)确认docker配置文件daemon.json的驱动配置
    [root@master~]# cat  /etc/docker/daemon.json
    {
    "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
    "exec-optl m { / Asq h S % V R _ #": ["nativf ^ X 6 ) ~ De.cgroupdriver? x N / s - O & H=systemd"]
    }

    2)修改/var/lib/kubelet/kubeadm-flags.env驱动配置,添加--cgroup-driver=systemd 参数

    [root@mas+ n C } r ! v [ter~]# cat /var/lib/kubelet/kubeadm-A d ^flags.envH : m  | 2 * $ ;
    KUBELET_KUBEADM_ARGS="--cgroup-k K #driver=systemd --network-plugin=cni --pod-infra-container-image=regist[ 4 / 5ry.aliyuncs.com/google_conta& K u Vinern i ps/pause:3.1"
    #重启docker与kubelet
    [root@master~]# syk G + - pstemctl daemon-reload && systemcI 4 2 + S E $tl[ # h  R w restart docker kubelet

    kubernetes(kubeadm)集群的安装问题总结
    2、/system.slice/kubelet.service无法识别

  • 异常【Failed to get system container stats for kubelet.service】
    异常描述如下
    failed to get container info for "/system.slice/kubelet.service": unknor : G 3 [wn container] 9 ( ] ~ % "/system.slice/kubelet.service"
  • 解决方案
    修改kubelet.service
    [root@master~]# vim /lib/systemd/sysK j U ? 1 m L 2 Ttem/kubelet.service
    #在ExecStart位x _  q t a ]置最后面,添加如下配置
    --runtime-cgroW 0 e jups=/systemd/system.slice 
    --kubelet-cgroups=/P S nsystemd/system.s= N R Alice

3、kubeadm初始化时报[ERROQ $ h oR NumCPU]

  • 异常描述如下
    kubeadm init --apis{ i ? j 3 4 Cerver-advertise-address=10.1@ n M # K L0.10.129 --image-repository registry.aliyuncs.com/google_contain
    ers --kubernetes-versioC S f b In v1.17.0 --servq H @ Y o :ice-cidr=10.96.0.0/12 --pod-network-cidr=10.22 G ;44.0.0/1& 1 j6W0521 22:45:14.131024    8293 validation.go:28] Cannot validate kube-proxy config - no vali % O D ]idator is available
    W0521 22:45:14.131095    8293 validation.go:28] Cannot validate kubelet c8 d ; * { R t w Zonfu , R [ J 0ig - no validator is availablep U A } : [ i
    [init] Using Kubernetes versioJ & yn: v1.17.0
    [preflight] Running pre-flight check& = M = r y 7 % is
    error execution phase preflight: [preflight] SS 6 p Z 9 ) ) ~ /ome fatal errors occurred:
    [ERROR NumCPU]: the number of available CPUs 1 is less than tW z $ 7he required 2
    [preflO @ B m q $ iight] If you know what you are doing, you can make a check non-fatal with `--ignore-^ 5 t z N cpreflight-errors=...`
    To see the stack trace of this error execute with --v=5 or higher
  • 解决y ( $方案1:
    这种错误一般会出现在Vi P F l ! q i i dMware虚拟机上,因为新建VM时默认为一核,可通过配置,调整成2核,H ; 2 G d o ^重启系统即可,如下所示:
    kubernetes(kubeadm)集群的安装问题总结
  • 解决方案2:
    根据提示添加忽略错误提示--ignore-pr 7 % I k t g Freflight-errors=...E g I J R ` {
    $ kubeadm init 
    --apiserver-advertise-address=10.10.10.129 
    --image-repository registry.aliyuw l C gncs.com/google_containers 
    --kubernetes-version v1.17.0 
    --service-cidr=10.96.0.0/12 
    --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU

    kubernetes(kubeadm)集群的安装问题总结