关于k8s中工作节点无法执行kubectl命令的解决办法
我想在node02执行kubectl命令但是报了The connection to the server localhost:8080 was refused - did you specify the right host or port?经过排查,发现是node02节点没有权限,那我就赋予node02权限。首先在master执行以下命令。填yes,注意是yes,不是y。接下来在node02节点
我想在node02执行kubectl命令但是报了The connection to the server localhost:8080 was refused - did you specify the right host or port?的错。
[root@node02 ~]# kubectl get pod
The connection to the server localhost:8080 was refused - did you specify the right host or port?
经过排查,发现是node02节点没有权限,那我就赋予node02权限
首先在master执行以下命令
scp /etc/kubernetes/admin.conf 10.0.0.50:/etc/kubernetes/admin.conf
会提示你
The authenticity of host '10.0.0.50 (10.0.0.50)' can't be established.
ECDSA key fingerprint is SHA256:ZpGuu/ydQ7uzTgleQEEK4qLI2KdjyElMFW7YEuoiOFk.
ECDSA key fingerprint is MD5:1a:af:70:98:ad:cf:14:ac:8b:05:24:e0:43:41:c9:08.
Are you sure you want to continue connecting (yes/no)?
填yes,注意是yes,不是y
会提示你
Warning: Permanently added '10.0.0.50' (ECDSA) to the list of known hosts.
root@10.0.0.50's password:
输入node02的密码即可
admin.conf 100% 5568 3.4MB/s 00:00
传输成功
接下来传输第二个文件
scp /etc/kubernetes/admin.conf 10.0.0.50:/etc/kubernetes/admin.conf
输入密码
admin.conf 100% 5568 2.6MB/s 0
传输成功
接下来在node02节点操作
export KUBECONFIG=/etc/kubernetes/admin.conf
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
验证
[root@node02 ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-deployment-746ccc65d8-2nkg4 1/1 Running 0 10m
nginx-deployment-746ccc65d8-sxpfb 1/1 Running 0 10m
nginx-deployment-746ccc65d8-xwd4m 1/1 Running 0 10m
成功!!!
更多推荐
所有评论(0)