1
votes

I used such command:

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

I got:

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

How to fix this issue?

All kubectl commands work well on target system. Command:

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

also work well:

 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
...
1
see you can pass the k8s configuration file and test it . kubectl --kubeconfig=path to kube configsfgroups
I am sorry I don't get your point and I forgot to provided some important information. Please see the question above.Lior

1 Answers

0
votes

can you try run something like this?

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

in your case like this:

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