Kubernetes (Service Account)

The Kubernetes (Service Account) resource type in StrongDM enables you to grant access to a self-managed or on-premises Kubernetes cluster by using a service account token for authentication.

For an overview of the available Kubernetes features and supported platforms, please see our Kubernetes guide.

Overview

This guide describes how to set up a Kubernetes cluster in StrongDM with the credentials of a Kubernetes service account. This process involves setting up a Kubernetes cluster, generating a permanent service account token, and using that token to configure a new Kubernetes (Service Account) cluster in the StrongDM Admin UI. When done with this guide, you will be able to use StrongDM to connect to a Kubernetes cluster with the credentials of a Kubernetes service account.

If you would like to learn more about how to enable automatic resource discovery within your Kubernetes cluster, or use privilege levels to allow users to request various levels of access to the Kubernetes cluster, please read the Kubernetes Discovery and Privilege Levels section to learn more about those features prior to following this configuration guide.

Prerequisites

Ensure that the API server you intend to add to StrongDM is accessible from your StrongDM nodes (gateways, relays, or proxy clusters). See our guide on Nodes for more information.

If you are using kubectl 1.30 or higher, it will default to using websockets, which the StrongDM client did not support prior to version 45.35.0. This can be remedied by taking one of the following actions:

  • Update your client to version 45.35.0 or greater.

  • Set the environment variable KUBECTL_REMOTE_COMMAND_WEBSOCKETS=false to restore the previous behavior in your kubectl.

Configure the Kubernetes Cluster

Before you can add the cluster to your StrongDM environment, you need to set up the cluster itself. Follow these steps to configure your cluster.

  1. Create a ServiceAccount:

    kubectl create serviceaccount <serviceaccount-name>
  2. Create a Role or ClusterRole.

The permissions given in this Role are exactly what StrongDM users get when they connect to this resource.

The following example ClusterRole gives blanket permissions to the whole cluster:

  1. Create a RoleBinding or ClusterRoleBinding to associate the Role or ClusterRole with the ServiceAccount.

    To create a RoleBinding:

    To create a ClusterRoleBinding:

  2. Create a Secret to manually generate a permanent token.

In this step, you manually create a token secret that the kube-apiserver detects and then populates with a token associated with the ServiceAccount. This secret (and token) does not expire. For reference, please see the Kubernetes documentation, Configure Service Accounts for Pods.

  1. First save and complete the following yaml template:

  2. Run:

  3. If not done already, obtain the generated token by inspecting the Secret just created.

  4. Save the token in a safe place, as you will need it when adding your resource in the StrongDM Admin UI next.

There are alternative ways to generate tokens, other than the manual way described in this guide. However, such ways typically yield temporary tokens, which may adversely affect resource registration. For example, if the following command is used to get a token directly to stdout, the --duration flag may not be respected:

kubectl create token <serviceaccount-name> --duration <duration> | pbcopy

Resource Configuration in StrongDM

This section provides instructions for adding the resource in either the StrongDM Admin UI, CLI, Terraform provider, or SDKs.

Set up and Manage With the Admin UI

If using the Admin UI to add the resource to StrongDM, use the following steps.

  1. Log in to the StrongDM Admin UI and go to Resources > Clusters.

  2. Click Add cluster.

  3. For Cluster Type, select Kubernetes (Service Account).

  4. For API Token, set the token that you generated and saved in the previous section of this guide.

  5. Set all other required resource properties to configure how the StrongDM node connects.

  6. Click Create to save the resource.

The Admin UI updates and shows your new cluster in a healthy or unhealthy state. Healthy indicates a successful connection. If it is unhealthy, click into the cluster's name and view the Diagnostics tab to determine where the connection is failing.

Resource Properties

The following table describes the configuration properties available for your Kubernetes (Service Account) cluster.

Property
Requirement
Description

Display Name

Required

Meaningful name to display the resource throughout StrongDM; exclude special characters like quotes (") or angle brackets (< or >)

Cluster Type

Required

Kubernetes (Service Account)

Proxy Cluster

Required

Defaults to "None (use gateways)"; if using proxy clusters, select the appropriate cluster to proxy traffic to this resource

Hostname

Required

Hostname or IP address of the API server, such as api.aks.example.com; relay server should be able to connect to your target server or hostname

Port

Required

Port to connect to the API server; default port value 443

Connectivity Mode

Required

Select either Virtual Networking Mode, which lets users connect to the resource with a software-defined, IP-based network; or Loopback Mode, which allows users to connect to the resource using the local loopback adapter in their operating system; this field is shown if Virtual Networking Mode enabled for your organization

IP Address

Optional

If Virtual Networking Mode is the selected connectivity mode, an IP address value in the configured Virtual Networking Mode subnet in the organization network settings; if Loopback Mode is the selected connectivity mode, an IP address value in the configured Loopback IP range in the organization network settings (by default, 127.0.0.1); if not specified, an available IP address in the configured IP address space for the selected connectivity mode will be automatically assigned; this field is shown if Virtual Networking Mode and/or multi-loopback mode is enabled for your organization

Port Override

Optional

If Virtual Networking Mode is the selected connectivity mode, a port value between 1 and 65535 that is not already in use by another resource with the same IP address; if Loopback Mode is the selected connectivity mode, a port value between 1024 to 64999 that is not already in use by another resource with the same IP address; when left empty with Virtual Networking Mode, the system assigns the default port to this resource; when left empty for Loopback Mode, an available port that is not already in use by another resource is assigned; preferred port also can be modified later from the Port Overrides settings

DNS

Optional

If Virtual Networking Mode is the selected connectivity mode, a unique hostname alias for this resource; when set, causes the desktop app to display this resource's human-readable DNS name (for example, k8s.my-organization-name) instead of the bind address that includes IP address and port (for example, 100.64.100.100:5432)

Secret Store

Optional

Credential store location; defaults to none (credentials are stored in StrongDM resource configuration); to learn more, see Secret Store options

API Token

Required

Permanent token associated with the ServiceAccount on the Kubernetes cluster

Healthcheck Namespace

Optional

If enabled for your organization, the namespace used for the resource healthcheck; defaults to default if empty; supplied credentials must have the rights to perform one of the following kubectl commands in the specified namespace: get pods, get deployments, or describe namespace

API Token

Required

Permanent token associated with the ServiceAccount on the Kubernetes cluster

Authentication

Required

Authentication method to access the cluster; select either Leased Credential (default) or Identity Aliases (to use the Identity Aliases of StrongDM users to access the cluster)

Identity Set

Required

Displays if Authentication is set to Identity Aliases; select an Identity Set name from the list

Healthcheck Username

Required

If Authentication is set to Identity Aliases, the username that should be used to verify StrongDM's connection to it; username must already exist on the target cluster

Resource Tags

Optional

Resource Tags consisting of key-value pairs <KEY>=<VALUE> (for example, env=dev)

Display name

Some Kubernetes management interfaces, such as Visual Studio Code, do not properly render cluster names containing spaces. If you run into problems, please choose a Display Name without spaces.

Secret Store

By default, server credentials are stored in StrongDM. However, these credentials can also be saved in a secrets management tool.

Non-StrongDM options appear in the Secret Store dropdown if they are created under Settings > Secrets Management. When you select another Secret Store type, its unique properties display. For more details, see Configure Secret Store Integrations.

Test the Connection

  1. After creating the Kubernetes (Service Account) cluster resource in the Admin UI, navigate to Infrastructure > Clusters and locate your newly added cluster. The health indicator should turn green once connectivity and token authentication are validated.

  2. On a test client using the StrongDM Desktop App or CLI, connect to the cluster and run a basic command such as:\

  3. Confirm the command returns resources and the connection is routed through StrongDM.

  4. If discovery is enabled, in the Admin UI verify that namespaces, roles, and service accounts appear under the cluster’s Discovery tab. This indicates StrongDM successfully queried the Kubernetes API.

  5. If the health status remains red or yellow:

    • Verify the cluster’s hostname and port are correct and that the API endpoint is reachable from your relay or gateway.

    • Check that the service account token is valid and has sufficient permissions to access the API.

    • Confirm the healthcheck_namespace exists and the user specified in identity_alias_healthcheck_username has the appropriate access.

    • Review the Diagnostics tab for authentication or network error logs.

Once connectivity is verified and you can successfully run Kubernetes commands, the cluster resource is ready. You can then assign roles, apply policies, and monitor access through StrongDM.

Help

If you encounter issues, please consult the StrongDM Help Center.

Be prepared to provide the following information to StrongDM Support, so that they can inspect logs and confirm node and resource health:

  • Resource name or ID

  • CLI error output or logs

  • Node name and region

  • Timestamps of failed attempts

Last updated

Was this helpful?