Kubectl Error when accessing Namespaces

8/29/2017

I was trying out the Tectonic Kubernetes sandbox setup and according to their documentation:

https://coreos.com/tectonic/docs/latest/tutorials/first-app.html

I did download the kubectl and the corresponding kube-config files, but when I tried to get the namespaces using the following command:

kubectl get namespaces

I get the following error:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

What is this? From where is it picking up this port locahost:8080?

EDIT:

Joe-MacBook-Pro:~ joe$ kubectl config get-contexts
CURRENT   NAME      CLUSTER   AUTHINFO   NAMESPACE
Joe-MacBook-Pro:~ joe$
-- sparkr
kubernetes
tectonic-coreos

1 Answer

8/30/2017

I'm lacking some details on your setup, but the problem is basically clear - you're not connected to the cluster.

You should have a kubeconfig file containing the cluster connection information i.e. the context, I assume if you run kubectl config view you'll get nothing.

I'm on windows using git bash, if I run the same command I get:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://platform-svc-integration.net
  name: svc-integration
contexts:
- context:
    cluster: svc-integration
    user: svc-integration-admin
  name: svc-integration-system
current-context: svc-integration-system
kind: Config
preferences: {}
users:
- name: svc-integration-admin
  user:
    client-certificate: <path>/admin/admin.crt
    client-key: <path>/admin/admin.key

basically what I'm trying to say is you need to configure your context, start by doing kubectl config --help to list your options, it's pretty straight forward but if don't manage just refer to the documentation.

-- Naim Salameh
Source: StackOverflow