godaddy / godaddy/kubernetes-client
Use current context namespace as default
- Dominant language
- JavaScript
- Stars
- 963
- Forks
- 189
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have defined a current namespace in my kubeconfig.
Is there a way to use it as the default for all api calls ?
example:
`await this.K8sClient.apis.apps.v1.namespace().deployments(name).get();`
My kubeConfig file:
```
{
apiVersion: 'v1',
clusters: [
{
name: process.env.KUBERNETES_CLUSTER_NAME,
cluster: {
server: process.env.KUBERNETES_HTTP_URL,
},
},
],
users: [
{
name: process.env.KUBERNETES_USERNAME,
},
],
contexts: [
{
name: process.env.KUBERNETES_CONTEXT_NAME,
context: {
cluster: process.env.KUBERNETES_CLUSTER_NAME,
user: process.env.KUBERNETES_USERNAME,
namespace: process.env.KUBERNETES_NAMESPACE,
},
},
],
'current-context': process.env.KUBERNETES_CONTEXT_NAME,
};
```
At the moment I need to define my namespace each time I call the kubernetes api.
Thank you for this library.
Contributor guide
Research direction
Start by tracing kubeConfig loading and the namespace handling behind the example deployments(name).get() call. Verify how current-context is read and how namespace values are passed to API calls; done means calls can omit an explicit namespace while using the namespace from the active kubeconfig context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, kubernetes, nodejs
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100