patternkubernetesMinor
Why do I get different responses either when I use `sudo` before `kubectl` or not?
Viewed 0 times
whykubectlresponseseitherdifferentgetwhenbeforeusenot
Problem
For example when I use
But when I use
PS: From my previous knowledge I think 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?Solution
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
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.Context
StackExchange DevOps Q#17058, answer score: 2
Revisions (0)
No revisions yet.