Skip to main content
Generate a kubeconfig to connect to a instance. kubeconfig write generates a kubeconfig that allows connecting kubectl to an instance. The config is written to a temporary file. When running kubectl, the created kubeconfig can be selected by setting the KUBECONFIG environment variable or by setting the --kubeconfig flag. To skip writing the config and run a configured kubectl directly, see nsc kubectl

Usage

Example

The following example shows how to generate a kubeconfig and use it to deploy an application into an instance:
1

Create an ephemeral instance

Create an ephemeral instance and note its ID:
Output
2

Generate a kubeconfig

Generate a kubeconfig for the instance:
Output
3

Deploy an application

Set the generated kubeconfig and deploy the example application:
Output

Options

—output_to <path>

Write the config path to file. If file already exists, it will get overwritten.
Last modified on August 20, 2026