The ServiceAccount resource allows you to create and manage service accounts in the StreamNative Cloud platform for programmatic access to resources.
apiVersion: resource.streamnative.io/v1alpha1
kind: ServiceAccount
metadata:
name: my-service-account
namespace: default
spec:
apiServerRef:
name: my-connection| Field | Type | Description | Required |
|---|---|---|---|
spec.apiServerRef |
corev1.LocalObjectReference |
Reference to a StreamNativeCloudConnection in the same namespace | Yes |
spec.lifecyclePolicy |
string | Whether to delete the remote service account or keep it when the Kubernetes resource is deleted. Defaults to cleanup when omitted. | No |
| Field | Type | Description |
|---|---|---|
status.conditions |
[]Condition | Current state of the ServiceAccount |
status.observedGeneration |
int64 | Last observed generation |
status.privateKeyType |
string | Type of the private key data |
status.privateKeyData |
string | Private key data in base64 format |
When a ServiceAccount resource is successfully created and contains credentials, the operator automatically creates a Kubernetes Secret to store these credentials:
- Credentials Secret: Contains the OAuth2 JSON credentials data
- Name format:
<serviceaccount-name>-credentials - Contains key:
credentials.json - The Secret is automatically created when:
- The ServiceAccount is in a Ready state
- The
privateKeyTypeis set toTYPE_SN_CREDENTIALS_FILE - The
privateKeyDatafield contains valid base64-encoded credentials
- Name format:
This Secret is owned by the ServiceAccount resource and will be automatically deleted when the ServiceAccount is deleted.
Service accounts provide a way to manage access to StreamNative Cloud resources programmatically. They are typically used for automation, CI/CD pipelines, or any system that needs to interact with StreamNative Cloud resources without using personal user credentials.
To create a service account, you need:
- A StreamNativeCloudConnection resource configured with valid credentials
spec.organizationset on that connection; the remote service account is created in that organization
apiVersion: resource.streamnative.io/v1alpha1
kind: ServiceAccount
metadata:
name: automation-account
namespace: default
spec:
apiServerRef:
name: my-connectionYou can mount the credentials secret in your application pods:
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: my-app-image
volumeMounts:
- name: credentials-volume
mountPath: /etc/credentials
readOnly: true
volumes:
- name: credentials-volume
secret:
secretName: automation-account-credentialsThe application can then read the credentials from /etc/credentials/credentials.json and use them for OAuth2 authentication.
Set spec.lifecyclePolicy: KeepAfterDeletion if you want deleting the Kubernetes ServiceAccount resource to leave the remote StreamNative Cloud service account in place.
After creating a service account, you can create API keys for it using the APIKey resource:
apiVersion: resource.streamnative.io/v1alpha1
kind: APIKey
metadata:
name: my-api-key
namespace: default
spec:
apiServerRef:
name: my-connection
serviceAccountName: automation-account
description: "API Key for automation"
expirationTime: "2025-12-31T23:59:59Z"
instanceName: my-pulsar-instance