> ## 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](https://docs.siderolabs.com/omni/getting-started/create-a-cluster.md)

> [!NOTE]
>
> Kubernetes Service Accounts authenticate to a Kubernetes cluster. If you need to authenticate to Omni itself, see [Omni Service Accounts](https://docs.siderolabs.com/omni/omni-cluster-setup/create-an-omni-service-account.md) instead.

## 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.

To invalidate the kubeconfig before its token expires, see [Revoke Kubernetes Access Tokens](https://docs.siderolabs.com/omni/security-and-authentication/revoke-kubernetes-access-tokens.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.