报错:
[root@master ~]# kubectl get pod
Unable to connect to the server: dial tcp: lookup localhost on 192.168.8.1:53: no such host
原因:k8s在找master节点,查找名字为localhost的master节点,在/etc/hosts中没有找到,找dns。
解决:修改/etc/hosts,在master添加localhost。
后,会报另一个问题:
[root@master ~]# kubectl get pod
The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决:修改环境变量,
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile