问题一
Failed to get system container stats for "/system.slice/docker.service": failed to get cgroup stats for "/system.slice/docker.service": failed to get container info for "/system.slice/docker.service": unknown container "/system.slice/docker.service
原因:kubelet设置的cgroups和docker的不一致导致,修改一样的即可
修改kubelet
vim /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf [Service] Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml" # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file. Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd" EnvironmentFile=-/etc/sysconfig/kubelet ExecStart= ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS $KUBELET_CGROUP_ARGS
修改docker
vim /etc/docker/daemon.json { "registry-mirrors": ["https://koea0c8l.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"], "graph": "{{ docker_data_dir }}", "insecure-registries": ["{{ harbor_domain }}", "{{ harbor_domain_name }}"] } #{{}}里面的是ansible的一种变量,可以忽略
修改完分别重启下即可