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:49ZPropagate credentials to dependent resources (optional)
OCM Controller resources can inherit credentials from referenced resources, reducing duplication. Create a
component.yamlwith a component referencing the OCM config from theRepositoryresource you just created. Specify the component reference to an existing component in your registry.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: 1m ocmConfig: - kind: Repository apiVersion: delivery.ocm.software/v1alpha1 name: my-repositoryThe
Componentresource inherits credentials from theRepositoryresource namedmy-repository.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:58ZCredential propagation
- Credentials are propagated by default when referencing other OCM Controller resources
- You must still specify the
ocmConfigfield on each resource that needs credentials - Credentials are not automatically inherited across all resources in the cluster
Advanced: Prevent credential propagation
To prevent a resource from propagating its credentials to dependent resources, set the policy to DoNotPropagate:
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: 1m
ocmConfig:
- kind: Repository
apiVersion: delivery.ocm.software/v1alpha1
name: my-repository
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 ocmConfig is not specified or references a non-existent resource.
Fix:
Add the ocmConfig field to your Component resource:
spec:
# ...existing configuration...
ocmConfig:
- kind: Repository
apiVersion: delivery.ocm.software/v1alpha1
name: my-repositoryOr reference the secret directly:
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