CloudsmithAccessToken creates a short-lived Cloudsmith access token that can be used to authenticate against Cloudsmith's container registry for pushing or pulling container images. This generator uses OIDC token exchange to authenticate with Cloudsmith using a Kubernetes service account token and generates Docker registry credentials in dockerconfigjson format.
| Key | Description |
|---|---|
| auth | Base64 encoded authentication string for Docker registry access. |
| expiry | Time when token expires in UNIX time (seconds since January 1, 1970 UTC). |
To use the Cloudsmith generator, you must configure OIDC authentication between your Kubernetes cluster and Cloudsmith. Your cluster must have a publicly available OIDC service account issuer endpoint for Cloudsmith to validate tokens against.
https://api.cloudsmith.io).You can determine the issuer and subject fields by creating and decoding a service account token for the service account you wish to use (this is the service account you will specify in spec.serviceAccountRef). For example, if using the default service account in the default namespace:
Obtain issuer:
kubectl create token default -n default | cut -d '.' -f 2 | sed 's/[^=]$/&==/' | base64 -d | jq -r '.iss'
Use these values when configuring the OIDC service in your Cloudsmith Workspace settings.
| Parameter | Description | Required |
|---|---|---|
apiHost |
The Cloudsmith API host. Defaults to api.cloudsmith.io. |
No |
orgSlug |
The organization slug in Cloudsmith. | Yes |
serviceSlug |
The OIDC service slug configured in Cloudsmith. | Yes |
serviceAccountRef |
Reference to the Kubernetes service account for OIDC token exchange. | Yes |
{% include 'generator-cloudsmith.yaml' %}
Example ExternalSecret that references the Cloudsmith generator:
{% include 'generator-cloudsmith-example.yaml' %}
Once the dockerconfigjson secret is created, you can use it to authenticate with Cloudsmith's container registry in several ways:
Reference the secret in your pod's imagePullSecrets:
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
imagePullSecrets:
- name: cloudsmith-credentials
containers:
- name: app
image: docker.cloudsmith.io/my-org/my-repo/my-image:latest
Add the secret to a ServiceAccount for automatic usage:
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-service-account
imagePullSecrets:
- name: cloudsmith-credentials
Extract the dockerconfigjson and use it with Docker:
kubectl get secret cloudsmith-credentials -o jsonpath='{.data.\.dockerconfigjson}' | base64 -d > ~/.docker/config.json
docker pull docker.cloudsmith.io/my-org/my-repo/my-image:latest
expiry field in the generated secret indicates when the token will expire.refreshInterval in your ExternalSecret to ensure tokens are refreshed before expiration.apiHost.imagePullSecrets and that the image exists in your Cloudsmith container registry.docker.cloudsmith.io/org/repo/image:tag) in your image references.