This approach is safer for one-off tasks because it doesn't alter your persistent configuration. If you find yourself using this flag repeatedly, it is time to use the set-context method described above. Verifying Your Current Namespace
kubectl config set-context --current --namespace=my-namespace kubectl change namespace
This command displays a list of available contexts, including the current namespace. This approach is safer for one-off tasks because
kubectl config set-context --current --namespace=prod such as pods
Before we dive into changing namespaces, let's quickly review what namespaces are in Kubernetes. A namespace is a way to group resources, such as pods, services, and deployments, into a logical partition. This allows multiple teams or users to share the same cluster without conflicts.
This command retrieves a list of pods in the my-namespace namespace.