> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siderolabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Kubeconfig for a Kubernetes Service Account

> Generate a kubeconfig for a Kubernetes Service Account using omnictl for secure, token-based cluster access.

This guide walks you through generating a kubeconfig for a Kubernetes Service Account using `omnictl`.

## Prerequisites

To follow this guide, you must have:

* [`omnictl` installed and configured](../getting-started/install-and-configure-omnictl)
* [A cluster created in Omni](../getting-started/create-a-cluster)

<Info>
  Kubernetes Service Accounts authenticate to a Kubernetes cluster. If you need to authenticate to Omni itself, see [Omni Service Accounts](../omni-cluster-setup/create-an-omni-service-account) instead.
</Info>

## Create the Kubernetes service account kubeconfig

Run the following command to generate the kubeconfig:

```bash theme={null}
omnictl kubeconfig --service-account --cluster <cluster> --user <username> <path to kubeconfig>
```

Replace the placeholders with your own values:

* `<cluster>`: The name of your cluster in Omni
* `<username>`: Any username you want to assign to the service account
* `<path to kubeconfig>`: The file path where the kubeconfig will be written

This creates a service account token with the specified username and writes a kubeconfig for the given cluster to the path you provided.

You can then use this kubeconfig with `kubectl` as normal.
