问题:在node节点执行出现以下错误。
[root@localhost ~]# kubectl get node
error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
1.在k8s 的master节点可以看到 admin.conf
[root@localhost kubernetes]# pwd
/etc/kubernetes
[root@localhost kubernetes]# ls
admin.conf controller-manager.conf kubelet.conf manifests pki scheduler.conf
2. 在主节点移动到node
[root@localhost kubernetes]# scp admin.conf root@192.168.31.121:/etc/kubernetes
3.添加变量
[root@localhost kubernetes]# export KUBECONFIG=/etc/kubernetes/admin.conf
[root@localhost kubernetes]# source /etc/profile
4.可以看到已经可以了
[root@localhost kubernetes]# kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 54m v1.18.0
node1 Ready <none> 27m v1.18.0
[root@localhost kubernetes]#