A context in kubeconfig conists of a cluster, a user, and a namespace. The current context is the cluster that is currently the default for kubectl, and is the default context used by kubectl commands.

cluster - The cluster where the API server is running user - The user account that you want to use to interact with the cluster namespace - The default namespace to use for CLI operations without specifying a namespace

View current context

kubectl config view
  • kubectl config get-contexts - List all the contexts
  • kubectl config use-context <context-name> - Switch to a different context
  • kubectl config set-context <context-name> --namespace=<namespace-name> - Set the namespace for the current context

or you can edit the kubeconfig file directly like a sane person


  • kubectl get all - List all objects in the current namespace

  • kubectl get <object-type> - List all objects of a type

  • kubctl get <object-type> <object-name> - Get a specific object

  • kubectl describe <object-type> <object-name> - Get detailed information about a specific object

  • kubectl delete <object-type> <object-name> - Delete a specific object

object types:

  • pods
  • services
  • replicasets
  • deployments
  • nodes
  • ingress
  • secrets
  • configmaps
  • namespaces