root@master-node:/tmp/k8s-1.6/production/memcached# kubectl get pod --all-namespaces
NAMESPACE     NAME                         READY     STATUS    RESTARTS   AGE
default       pro-w-mem-1448348793-jpr24   1/1       Running   0          3m
kube-system   kube-dns-1782573344-bd7pb    2/3       Running   0          4m
root@master-node:/tmp/k8s-1.6/production/memcached# kubectl exec -it  kube-dns-1782573344-bd7pb -n=kube-system sh
Defaulting container name to kubedns.
Use 'kubectl describe pod/kube-dns-1782573344-bd7pb' to see all of the containers in this pod.
Error from server: error dialing backend: dial tcp: lookup master-node on 100.100.2.136:53: no such host

K8s集群中调取启动pod后,发现通过Kubectl命令无法进入到容器内,但使用docker exec 可以。

其实问题提示的很明显,说是无可达主机

root@master-node:/tmp/k8s-1.6/production/memcached# kubectl get node
NAME          STATUS    AGE       VERSION
master-node   Ready     31m       v1.6.2

解决方法:添加节点对应的Node名解析

root@master-node:/tmp/k8s-1.6/production/memcached# vim /etc/hosts
10.0.3.242 master-node
root@master-node:/tmp/k8s-1.6/production/memcached# kubectl exec -it kube-dns-1782573344-bd7pb -n=kube-system sh
Defaulting container name to kubedns.
Use 'kubectl describe pod/kube-dns-1782573344-bd7pb' to see all of the containers in this pod.
/ # exit



Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐