kubens - fails: current-context is not set
Routes kubens failures with no selected context. Use when kubens - (or kubens) reports current-context is not set. Not for unknown namespace names.
kubens needs a current context to know which cluster and namespace entry to edit, and none is selected. Select a context first (kubectx [name] or kubectl config use-context [name]), then kubens works - the dash included.
The error
current-context is not setWhat to do
- Select a context:
kubectx [name] Expected: Prints Switched to context "[name]"..
- Retry:
kubens [namespace] Expected: Prints Active namespace is "[namespace]"..
When this applies
- the exact current-context is not set message from kubens
- fresh kubeconfigs with no selection
- after kubectx -u
When it does NOT apply
- no namespace exists with name (a context is selected, the name is wrong)
- Forbidden errors listing namespaces
Works with
kubens (ahmetb/kubectx)
kubens with no args lists nothing and errors the same way
Same missing-selection cause. Select a context first.
Why it happens
kubens edits the namespace field of the current context entry. With no current context there is no entry to edit, so every kubens form fails the same way.
Edge cases
- Scripts that unset the context for safety must select one before calling kubens.
- KUBECONFIG merging can drop the selection if the first file has none - check kubectl config current-context.
Resolved from
gh:nao1215/atago (e2e kubens behavior spec) - https://github.com/nao1215/atago/blob/HEAD/doc/e2e/kubectx.md
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.