kubernetes 无法 使用命令 log exec

当执行 kubectl logs exec 错误提示通常如下
the server could not find the requested resource
解决方法是去在worker节点上,手工修改kubelet的配置文件,加入正确的IP配置信息,如下最后一行,1.1.1.8是我worker节点正确的内网IP.
vi /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

# Note: This dropin only works with kubeadm and kubelet v1.11+
[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.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS --node-ip 1.1.1.8

重启
systemctl daemon-reload
systemctl restart kubelet.service 

原因

  • 应该是使用kubeadm此类工具安装的时候,碰到节点有多个IP的情况,默认只能去取第一块网卡的信息,导致节点的IP地址不能正确获取,所以才需要手工修改节点的IP配置信息.

你可能感兴趣的:(kubernetes 无法 使用命令 log exec)