kubectl commands giving error

3/3/2018

All my kubectl get commands are failing with the following error The connection to the server localhost:8080 was refused - did you specify the right host or port?

I checked the ip of my /etc/kubernetes/admin.conf and it has the following apart from other stuff: server: https://10.23.23.19:6443

Since that is the IP of my machine, I thought of running the command like this kubectl get pods --server=10.23.23.19:6443

Above gives me the error - Unable to connect to the server: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02"

What am I doing wrong? I have a 3 node cluster and all this is on the master. When 2 other nodes joined, they did join successfully is what I saw as the status on the screen though.

I used this tutorial(with slight deviations of my own to get started) - https://www.linuxtechi.com/install-kubernetes-1-7-centos7-rhel7/

-- curiousengineer
kubectl
kubernetes

3 Answers

11/7/2018

Unable to connect to the server: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02"

That error is because the --server arg is missing https://. It should be this:

kubectl get pods --server=https://10.23.23.19:6443

You will probably get a 403 error instead after adding https:// since there is still no auth defined, but that's the cause for the malformed http response.

-- Matthew
Source: StackOverflow

7/3/2018

there is no problem if you:

curl https://127.0.0.1:10252/healthz -k

return is OK

-- King LV
Source: StackOverflow

3/3/2018

/etc/kubernetes/admin.conf is the location that the provisioning system placed your config in, but it is not the one used by kubectl by default. The usual place that kubectl looks at for configuration is ~/.kube/config so either put your config file there or hint to kubectl that it needs to look in a different place with --kubeconfig <path> param.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow