# Cluster Access - Kubeconfig

## Cluster Access - Kubeconfig

<code class="expression">space.vars.product\_name</code> provides Kubernetes cluster access via kubeconfig — a YAML file containing cluster connection details and authentication configuration. For more information, refer to the [Kubernetes kubeconfig documentation](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/).

The kubeconfig file works with `kubectl`, Kubernetes client libraries (Go, Python, Java, etc.), and any tool that supports the standard kubeconfig format.

### Download Kubeconfig

In order to access your clusters outside of the <code class="expression">space.vars.product\_name</code> UI, you need a kubeconfig file that is properly configured for authenticating with your cluster.

The kubeconfig file can be obtained by following these steps:

1. In the <code class="expression">space.vars.product\_name</code> UI, navigate to the Kubernetes cluster you want to access.
2. Click the **Download Kubeconfig** button in the top right of the page.

The kubeconfig file will be downloaded to your system's default Downloads folder.

### Using kubeconfig

To connect to the cluster using the kubeconfig, follow these steps:

1. Download the kubeconfig (see above).
2. [Install `kubectl`](https://kubernetes.io/docs/tasks/tools/) on your machine.
3. Install [kubelogin](https://github.com/int128/kubelogin), the OIDC plugin for `kubectl`:

   ```bash
   # Homebrew (macOS and Linux)
   brew install kubelogin

   # Krew (macOS, Linux, Windows and ARM)
   kubectl krew install oidc-login

   # Chocolatey (Windows)
   choco install kubelogin
   ```

   Alternatively, you can install kubelogin manually by downloading the binary from the [releases page](https://github.com/int128/kubelogin/releases) and placing it in your `PATH` as a kubectl plugin:

   ```bash
   unzip kubelogin_linux_amd64.zip -d /tmp/kubelogin/
   mv /tmp/kubelogin/kubelogin /usr/local/bin/kubectl-oidc_login
   chmod +x /usr/local/bin/kubectl-oidc_login
   ```

   Verify the plugin is detected:

   ```bash
   kubectl plugin list
   # Expected output:
   # The following compatible plugins are available:
   # /usr/local/bin/kubectl-oidc_login
   ```
4. Export the `KUBECONFIG` environment variable in your terminal:

   ```bash
   export KUBECONFIG=~/Downloads/<cluster-name>.kubeconfig
   ```
5. Use `kubectl` to access the resources on the cluster:
   * The first time you log in, you will be redirected to a browser page granting your <code class="expression">space.vars.product\_name</code> account access to the Kubernetes workloads.
   * Once authenticated, use `kubectl` normally. For example:

     ```bash
     kubectl get nodes
     ```

{% hint style="info" %}
To skip the browser-based login and authenticate directly in the terminal, add `--grant-type=password` as an argument to the `oidc-login` command in your kubeconfig. This will prompt for your username and password in the terminal instead.
{% endhint %}

### Troubleshooting

* **kubelogin not found** — Ensure `kubelogin` is installed and available on your `PATH`. See the [kubelogin installation guide](https://github.com/int128/kubelogin#setup).
* **Browser does not open for OIDC login** — Verify that your default browser is configured and that the redirect URI is reachable from your machine.
* **`KUBECONFIG` not set** — If `kubectl` cannot find your cluster, make sure the `KUBECONFIG` environment variable points to the correct file path.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.platform9.com/private-cloud-director/2026.1/kubernetes-clusters/pcd-kubernetes-clusters/cluster-access-kubeconfig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
