CertKeen

Certified Kubernetes Administrator (CKA) · Free practice question 4 of 12

Setting the default namespace in a context

An engineer at Merriden Toys works mostly in namespace inventory and is tired of typing -n inventory. Which command makes inventory the default namespace for the current kubeconfig context?

  1. A.kubectl namespace set inventory --default --context=current
  2. B.export KUBE_NAMESPACE=inventory
  3. C.kubectl config use-context inventory
  4. D.kubectl config set-context --current --namespace=inventory
Show answer and explanation

Correct answer: D. kubectl config set-context --current --namespace=inventory

Why: Each kubeconfig context stores a cluster, a user and an optional namespace; set-context --current --namespace changes the namespace of the active context. use-context switches to a context with that name, kubectl has no namespace set command, and kubectl does not read a KUBE_NAMESPACE variable.

More free Certified Kubernetes Administrator (CKA) questions