2

For example when I use kubectl get pods the response is:

No resources found in default namespace.

But when I use sudo kubectl get pods the result is:

E1211 12:01:15.409201   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.409569   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.411086   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.412633   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1211 12:01:15.414189   50965 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?

PS: From my previous knowledge I think when I use kubectl without sudo, it refers to 192.168.1.2:6443 but with the sudo word it is looking for localhost:8080. I don't know why?

2 Answers 2

2

I think you haven't configured kubeconfig in root user.

The sudo command allows you to run programs with the security privileges of another user.

When you run sudo kubectl you're running kubectl with root user and most probably you might have not configured kubeconfig for root user.

0

This is only loosely related to your question, but if kubectl get pods gives:

No resources found in default namespace.

check kubectl get namespaces and then re-run the query with kubectl get pods -n <namespace>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.