How can I download the Kubeconfig credentials for the namespace of a Preview Environment?

During the creation of a preview environment, Okteto automatically creates a namespace in the Kubernetes cluster. What is the name of the namespace created?

Also, sometimes I need to troubleshoot something on the namespace owned by the preview environment. Is there a way to download the kubeconfig credentials for that namespace?

Hi @ramiro !

The name of the namespace created by Okteto is the name of the preview environment. You can see that name in the Okteto UI or using the command okteto preview list.

Once you have the name, you can execute the following commands:

  • okteto namespace use <preview-env-name>. This will set your current okteto context to the preview environment
  • Then, execute okteto kubeconfig. This will update your local kubeconfig to use the credentials for the namespace created for the preview environment.
  • Any command executed with kubectl will now go against that namespace

Happy coding!