今天,当我在 CentOS 7.6 中使用此命令启动 kubelet 1.21 时systemctl start kubelet
,显示错误:
Aug 04 18:41:21 k8smasterone kubelet[4835]: I0804 18:41:21.205953 4835 server.go:440] "Kubelet version" kubeletVersion="v1.21.9"
Aug 04 18:41:21 k8smasterone kubelet[4835]: I0804 18:41:21.206255 4835 server.go:573] "Standalone mode, no API client"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297093 4835 server.go:488] "No api server defined - no events will be sent to API server"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297125 4835 server.go:660] "--cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297389 4835 container_manager_linux.go:278] "Container manager verified user specified cgroup-root exists" cgroupRoot=[]
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297517 4835 container_manager_linux.go:283] "Creating Container Manager object based on Node Config" nodeConfig={RuntimeCgroupsName: SystemCgroupsName: KubeletCgroupsName: ContainerRuntime:docker CgroupsPerQOS:true CgroupRoot:/ CgroupDriver:cgroupfs KubeletRootDir:/var/lib/kubelet ProtectKernelDefaults:false NodeAllocatableConfig:{KubeReservedCgroupName: SystemReservedCgroupName: ReservedSystemCPUs: EnforceNodeAllocatable:map[pods:{}] KubeReserved:map[] SystemReserved:map[] HardEvictionThresholds:[{Signal:memory.available Operator:LessThan Value:{Quantity:100Mi Percentage:0} GracePeriod:0s MinReclaim:<nil>} {Signal:nodefs.available Operator:LessThan Value:{Quantity:<nil> Percentage:0.1} GracePeriod:0s MinReclaim:<nil>} {Signal:nodefs.inodesFree Operator:LessThan Value:{Quantity:<nil> Percentage:0.05} GracePeriod:0s MinReclaim:<nil>} {Signal:imagefs.available Operator:LessThan Value:{Quantity:<nil> Percentage:0.15} GracePeriod:0s MinReclaim:<nil>}]} QOSReserved:map[] ExperimentalCPUManagerPolicy:none ExperimentalTopologyManagerScope:container ExperimentalCPUManagerReconcilePeriod:10s ExperimentalMemoryManagerPolicy:None ExperimentalMemoryManagerReservedMemory:[] ExperimentalPodPidsLimit:-1 EnforceCPULimits:true CPUCFSQuotaPeriod:100ms ExperimentalTopologyManagerPolicy:none}
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297544 4835 topology_manager.go:120] "Creating topology manager with policy per scope" topologyPolicyName="none" topologyScopeName="container"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297558 4835 container_manager_linux.go:314] "Initializing Topology Manager" policy="none" scope="container"
Aug 04 18:41:26 k8smasterone systemd[1]: kubelet.service: main process exited, code=exited, status=1/FAILURE
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297568 4835 container_manager_linux.go:319] "Creating device plugin manager" devicePluginEnabled=true
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297661 4835 kubelet.go:307] "Using dockershim is deprecated, please consider using a full-fledged CRI implementation"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297692 4835 client.go:78] "Connecting to docker on the dockerEndpoint" endpoint="unix:///var/run/docker.sock"
Aug 04 18:41:26 k8smasterone kubelet[4835]: I0804 18:41:26.297708 4835 client.go:97] "Start docker client with request timeout" timeout="2m0s"
Aug 04 18:41:26 k8smasterone kubelet[4835]: E0804 18:41:26.298123 4835 server.go:292] "Failed to run kubelet" err="failed to run Kubelet: failed to get docker version: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
Aug 04 18:41:26 k8smasterone systemd[1]: Unit kubelet.service entered failed state.
Aug 04 18:41:26 k8smasterone systemd[1]: kubelet.service failed.
Aug 04 18:41:36 k8smasterone systemd[1]: kubelet.service holdoff time over, scheduling restart.
Aug 04 18:41:36 k8smasterone systemd[1]: Stopped kubelet: The Kubernetes Node Agent.
Aug 04 18:41:36 k8smasterone systemd[1]: Started kubelet: The Kubernetes Node Agent.
Aug 04 18:41:36 k8smasterone kubelet[5232]: I0804 18:41:36.474682 5232 server.go:440] "Kubelet version" kubeletVersion="v1.21.9"
Aug 04 18:41:36 k8smasterone kubelet[5232]: I0804 18:41:36.475069 5232 server.go:573] "Standalone mode, no API client"
为什么kubelet还需要docker来启动?从 1.20 开始,kubernetes 不再需要 dockerhttps://medium.com/swlh/kubernetes-docker-out-a46063d65bab。
这是文件/var/lib/kubelet/kubeadm-flags.env
:
KUBELET_KUBEADM_ARGS="--container-runtime=remote --container-runtime-endpoint=/run/containerd/containerd.sock --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.4.1"