javascript: Error setting user info form Default config ~/.kube/config.
Trying to get list of pods using the default config file (set by kubectl). Getting an error setting user info
"pods is forbidden: User “system:anonymous” cannot list resource “pods” in API group “” in the namespace “infra”
Node JS code snippet
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
k8sApi.listNamespacedPod('infra')
.then((res) => {
console.log(res);
});
tried with python and it works as expected
from kubernetes import client, config
# Configs can be set in Configuration class directly or using helper utility
config.load_kube_config()
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_namespaced_pod("infra")
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (17 by maintainers)
Commits related to this issue
- Update to openapi-generator compiled code using v4.1.0 v4.1.0 generates code the allows asynchronous authentication methods. Using kubernetes-client/gen@795993978f8563a9c09089993be4d2b97d492eec ```... — committed to johnfrench3/Awesome-javascript-Project-build by deleted user 5 years ago
- Convert `Authenticator.applyAuthentication` to return a `Promise<void>` cc https://github.com/kubernetes-client/javascript/issues/294 — committed to johnfrench3/Awesome-javascript-Project-build by deleted user 5 years ago
- Update to openapi-generator compiled code using v4.1.0 v4.1.0 generates code the allows asynchronous authentication methods. Using kubernetes-client/gen@795993978f8563a9c09089993be4d2b97d492eec ```... — committed to mattstern31/javascript by mattstern31 5 years ago
- Convert `Authenticator.applyAuthentication` to return a `Promise<void>` cc https://github.com/kubernetes-client/javascript/issues/294 — committed to mattstern31/javascript by mattstern31 5 years ago
I finished the code and opened a PR @brendandburns @silasbw thanks for your help guys!