Configure Credentials for OCM Controllers
Goal
Configure credentials to allow OCM Controllers to access OCM components stored in private OCI registries.
You will end up with
- A Kubernetes secret containing registry credentials
- OCM Controller resources configured to use these credentials
- Verified access to private OCM repositories
Estimated time: ~5 minutes
Prerequisites
- Controller environment set up (OCM Controllers, kro and Flux in a Kubernetes cluster)
- OCM CLI installed
- kubectl installed
- Credentials for your private OCI registry (username and password, Docker config file, or OCM CLI config file)
- The registry URL where your OCM components are stored
Security Warning
Kubernetes secrets are only base64-encoded, not encrypted. Ensure proper RBAC policies to restrict access to secrets containing credentials.
Configure and propagate credentials for OCM resources
Create a Kubernetes secret with credentials
Choose one of two methods to create the secret:
Reference the secret in OCM Controller resources
Add the
spec.ocmConfigfield to your OCM Controller resources to use the credentials. Create arepository.yamlwith aRepositoryresource. Replace<your-namespace>with your actual namespace in the registry URL.apiVersion: delivery.ocm.software/v1alpha1 kind: Repository metadata: name: my-repository spec: repositorySpec: baseUrl: ghcr.io/<your-namespace> type: OCIRegistry interval: 1m ocmConfig: - kind: Secret name: ocm-secretApply the resource:
kubectl apply -f repository.yamlYou should see this output
repository.delivery.ocm.software/my-repository createdVerify the resource is ready and can access your registry (due to the complex status field of OCM resources, to show the status, we need to use
custom-columns)kubectl get repository my-repository -o 'custom-columns=NAME:.metadata.name,READY:.status.conditions[0].message,AGE:.metadata.creationTimestamp'You should see this output
NAME READY AGE my-repository Successfully reconciled OCM repository 2026-02-25T15:45:49ZCredential inheritance for dependent resources
ocmConfigis propagated by default. AComponent,Resource, orDeployerresource will automatically inherit theocmConfigfrom the resource it references (e.g. aRepository) if it does not specify its ownocmConfig. This means you do not need to repeat the credential configuration in every dependent resource.Create a
component.yamlthat references theRepositoryyou just created:apiVersion: delivery.ocm.software/v1alpha1 kind: Component metadata: name: my-component spec: component: <your-namespace>/my-component repositoryRef: name: my-repository semver: 1.0.0 interval: 1mThe
Componentautomatically inherits theocmConfigfrommy-repository— no explicitocmConfigfield needed.Apply the resource:
kubectl apply -f component.yamlYou should see this output
component.delivery.ocm.software/my-component createdVerify the resource is ready and can access your registry (due to the complex status field of OCM resources, to show the status, we need to use
custom-columns)kubectl get component my-component -o 'custom-columns=NAME:.metadata.name,READY:.status.conditions[0].message,AGE:.metadata.creationTimestamp'You should see this output
NAME READY AGE my-component Applied version 1.0.0 2026-02-25T15:49:58ZIf you need the
Componentto use additional credentials on top of those from theRepository, specify both inocmConfig:spec: # ...existing configuration... ocmConfig: - kind: Secret name: another-ocm-secret - kind: Repository apiVersion: delivery.ocm.software/v1alpha1 name: my-repository
Advanced: Prevent credential propagation
To prevent a resource from propagating its credentials to dependent resources, set policy: DoNotPropagate on
the relevant ocmConfig entry of that resource:
apiVersion: delivery.ocm.software/v1alpha1
kind: Repository
metadata:
name: my-repository
spec:
repositorySpec:
baseUrl: ghcr.io/<your-namespace>
type: OCIRegistry
interval: 1m
ocmConfig:
- kind: Secret
name: ocm-secret
policy: DoNotPropagateTroubleshooting
Symptom: “failed to list versions: response status code 401: unauthorized”
Cause: The credentials are incorrect, missing, or the secret is not referenced in the resource.
Fix:
Verify the secret exists:
kubectl get secret ocm-secretCheck the secret contains the correct credentials:
kubectl get secret ocm-secret -o yamlEnsure the
ocmConfigfield references the correct secret name in your resource.
Symptom: “failed to read OCM config: key .ocmconfig not found in secret”
Cause: When using the OCM config method, the secret key must be named .ocmconfig.
Fix:
Recreate the secret with the correct key name, e.g., referencing an .ocmconfig file in the same folder:
kubectl delete secret ocm-secret
kubectl create secret generic ocm-secret --from-file=./.ocmconfigThe filename in --from-file must be .ocmconfig (with the dot).
Symptom: “Component shows Not Ready with credential errors”
Cause: The referenced Repository has no ocmConfig, or the Component specifies its own ocmConfig that is
missing or references a non-existent resource.
Fix:
Ensure the Repository the Component references has a valid ocmConfig — the Component will inherit it
automatically. If the Component needs additional credentials, add them explicitly:
spec:
# ...existing configuration...
ocmConfig:
- kind: Secret
name: ocm-secretNext Steps
- Tutorial: Deploy a Helm Chart - Use the OCM Controllers to deploy applications from component versions
- How-To: Configure Credentials for Multiple Registries - Configure credentials for multiple registries in an
.ocmconfigfile