kubectl config rename-context old-name new-name
# List all available contexts kubectl config get-contexts kubectl config use-context my-prod-cluster kubectl use-context
use-context is faster, less error-prone, and keeps your original config intact. kubectl config rename-context old-name new-name # List all
It lets you instantly switch between clusters, namespaces, or users without editing config files. or users without editing config files.