Hanzo

KMSSecret CRD

Kubernetes Custom Resource for automatic secret synchronization from KMS

KMSSecret CRD

The KMSSecret Custom Resource Definition (CRD) enables automatic synchronization of secrets from Hanzo KMS to Kubernetes Secrets. The kms-operator watches for KMSSecret resources and keeps the target K8s Secrets up to date.

API Version

apiVersion: secrets.lux.network/v1alpha1
kind: KMSSecret

Full Spec

apiVersion: secrets.lux.network/v1alpha1
kind: KMSSecret
metadata:
  name: example-kms-sync
  namespace: hanzo
  labels:
    app.kubernetes.io/name: example
    app.kubernetes.io/component: secrets
    app.kubernetes.io/part-of: hanzo-platform
spec:
  # KMS API endpoint (use in-cluster address)
  hostAPI: http://kms.hanzo.svc.cluster.local/api

  # How often to re-sync secrets (seconds)
  resyncInterval: 60

  # Authentication configuration
  authentication:
    universalAuth:
      credentialsRef:
        # K8s Secret containing clientId and clientSecret
        secretName: universal-auth-credentials
        secretNamespace: hanzo
      secretsScope:
        # KMS project to read from
        projectSlug: secrets-639-c
        # KMS environment
        envSlug: prod
        # Path within the project
        secretsPath: /example

  # Target K8s Secret
  managedSecretReference:
    # Name of the K8s Secret to create/update
    secretName: example-secrets
    # Namespace for the K8s Secret
    secretNamespace: hanzo
    # K8s Secret type
    secretType: Opaque
    # What happens when the KMSSecret CRD is deleted
    creationPolicy: Orphan

Field Reference

spec.hostAPI

Typestring
RequiredYes
DescriptionURL of the KMS API. Always use the in-cluster address for security.
Examplehttp://kms.hanzo.svc.cluster.local/api

spec.resyncInterval

Typeinteger
RequiredYes
DescriptionInterval in seconds between secret re-sync operations.
Default60
Minimum10

spec.authentication.universalAuth

credentialsRef

FieldTypeRequiredDescription
secretNamestringYesK8s Secret containing Machine Identity credentials
secretNamespacestringYesNamespace of the credentials Secret

The referenced Secret must contain two keys:

  • clientId — Machine Identity client ID
  • clientSecret — Machine Identity client secret

secretsScope

FieldTypeRequiredDescription
projectSlugstringYesKMS project slug
envSlugstringYesEnvironment slug (prod, staging, dev)
secretsPathstringYesPath within the project (e.g., /chat, /)

spec.managedSecretReference

FieldTypeRequiredDescription
secretNamestringYesTarget K8s Secret name
secretNamespacestringYesTarget namespace
secretTypestringNoK8s Secret type. Default: Opaque
creationPolicystringNoOrphan or Owner. Default: Owner (deletes Secret with CRD)

Creation Policies

PolicyBehavior
OwnerK8s Secret is deleted when the KMSSecret CRD is deleted (default)
OrphanK8s Secret survives CRD deletion. Recommended for production to prevent accidental secret loss.

Labeling Convention

All Hanzo services follow this labeling pattern:

labels:
  app.kubernetes.io/name: <service-name>
  app.kubernetes.io/component: secrets
  app.kubernetes.io/part-of: hanzo-platform

Troubleshooting

Secret not syncing

# Check KMSSecret status
kubectl describe kmssecret <name> -n hanzo

# Check kms-operator logs
kubectl logs -l app=kms-operator -n hanzo --tail=50

# Verify credentials are valid
kubectl get secret universal-auth-credentials -n hanzo -o jsonpath='{.data.clientId}' | base64 -d

Common errors

ErrorCauseFix
authentication failedInvalid or expired credentialsRegenerate Machine Identity credentials in KMS
project not foundWrong projectSlugVerify project slug in KMS UI
path not foundEmpty or non-existent pathCreate the path and add at least one secret in KMS
forbiddenInsufficient permissionsGrant the Machine Identity Viewer role on the project

Next Steps

Machine Identity authentication

Full inventory of services using KMS

IAM-specific secret management

How is this guide?

Last updated on

On this page