【问题标题】:When I try to run kubectl command through sshpass,it failed with Unable to connect to the server当我尝试通过 sshpass 运行 kubectl 命令时,失败并显示无法连接到服务器
【发布时间】:2018-03-01 03:23:46
【问题描述】:

我用过这样的命令:

sshpass -p password ssh root@x.x.x.x 'date;kubectl get pod;date' 

我明白了:

Wed Sep 20 14:39:19 CST 2017
Unable to connect to the server: EOF
Wed Sep 20 14:39:20 CST 2017

如何解决这个问题?

所有 kubectl 命令在目标系统上运行良好。 命令:

sshpass -p password ssh root@x.x.x.x 'kubectl'

也很好用:

 mynode /etc » sshpass -p password ssh -o StrictHostKeyChecking=no root@x.x.x.x "kubectl"                                                        
kubectl controls the Kubernetes cluster manager. 

Find more information at https://github.com/kubernetes/kubernetes.

Basic Commands (Beginner):
  create         Create a resource by filename or stdin
  expose         Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  run            Run a particular image on the cluster
  set            Set specific features on objects

Basic Commands (Intermediate):
  get            Display one or many resources
  explain        Documentation of resources
  edit           Edit a resource on the server
  delete         Delete resources by filenames, stdin, resources and names, or by resources and label selector
...

【问题讨论】:

  • 看你可以通过k8s配置文件并测试一下。 kubectl --kubeconfig=path to kube config
  • 对不起,我没明白你的意思,我忘了提供一些重要信息。请看上面的问题。

标签: ssh kubernetes kubectl sshpass


【解决方案1】:

你能试试运行这样的东西吗?

ssh master-01 -x 'kubectl --kubeconfig=/root/.kube/config get nodes'

在你的情况下是这样的:

 sshpass -p password  ssh master-01 -x 'kubectl --kubeconfig=/root/.kube/config get nodes'

【讨论】:

    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 2017-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 2017-05-19
    相关资源
    最近更新 更多