Comment on page
StackState for Kubernetes troubleshooting Self-hosted
Using Service tokens it's possible to authenticate to StackState without having configured a user account. This is useful for situations where you want to use StackState from headless services like a CI server. In such a scenario you typically don't want to provision a user account in your identity provider.
> sts service-token --help
Manage service tokens.
sts service-token [command]
create Create a service token
delete Delete a service token
list List service tokens
Use "sts service-token [command] --help" for more information about a command.
To create a service token for an installed instance of StackState, you can use the new
sts service-token create
Note that the service token will only be displayed once. It isn't possible to see the token again.
This command takes the following command line arguments:
For example, the command below will create a service token with the name
my-service-tokenand the role
> sts service-token create --name my-service-token --roles stackstate-power-user
✅ Service token created: svctok-aaaaa-bbbb-ccccc-ddddd
When installing StackState, it's possible to bootstrap it with a (temporary) service token. This allows for using the CLI without first interacting with StackState and obtaining an API token from the UI. In order to set this up, you can add the following snippet to the StackState configuration file:
To configure StackState to create a bootstrap service token on Kubernetes, The following values need to be added to the file
authentication.yaml. For example
Follow the steps below to configure StackState to create a bootstrap service token:
authentication.yaml- add the bootstrap token:
- token - The token that will be created on (initial) start of StackState.
- roles - An array of roles that will be assigned to the bootstrap token.
- ttl - Optional. The time-to-live for the service token, expressed as a duration string.
- 2.Store the file
authentication.yamltogether with the
values.yamlfrom the StackState installation instructions.
- 3.Run a Helm upgrade to apply the changes.helm upgrade \--install \--namespace stackstate \--values values.yaml \--values authentication.yaml \stackstate \stackstate/stackstate-k8s
- The first run of the helm upgrade command will result in pods restarting, which may cause a short interruption of availability.
- The authentication configuration is stored as a Kubernetes secret.
The ID, name, expiration date and roles of all created service tokens can be seen using the new
stsCLI. For example:
> sts service-token list
ID | NAME | EXPIRATION | ROLES
107484341630693 | my-service-token | | [stackstate-power-user]
A service token can be deleted using the new
stsCLI. Pass the ID of the service token as an argument. For example:
> sts service-token delete 107484341630693
✅ Service token deleted: 107484341630693
Once created, a service token can be used to authenticate to StackState from a headless service. To do this you can either use the CLI or directly talk to the API.
A service token can be used for authentication with the
stsCLI. For details, see the CLI documentation:
To use a service token to talk directly to the StackState Base API or the StackState Admin API, add it to the header of the request in one of the following ways:
- In the
Authorizationheader:> curl -X GET -H "Authorization: ApiKey <TOKEN>" http://localhost:8080/api/server/status
- In the
X-API-Keyheader:> curl -X GET -H "X-API-Key: <TOKEN>" http://localhost:8080/api/server/status