|
This is unreleased documentation for SBOM Scanner 1.0-dev. |
Private Registries
Kubewarden SBOM Scanner supports private registries to scan for images. In order to make it work, please follow the steps listed below.
Create the Secret
Kubewarden SBOM Scanner relies on the docker config.json file to manage the authentication to the registries.
The first step to setup a private registry is to create a Secret with the config.json content, having the following structure:
apiVersion: v1
kind: Secret
metadata:
name: my-auth-secret
namespace: default
data:
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJkZXYtcmVnaXN0cnkuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDo1MDAwIjogewoJCQkiYXV0aCI6ICJkWE5sY2pwd1lYTnpkMjl5WkE9PSIKCQl9Cgl9Cn0KCg==
type: kubernetes.io/dockerconfigjson
The .dockerconfigjson field is a base64 value, with the config.json content.
Here’s an example:
{
"auths": {
"myprivateregistry.example": {
"auth": "dXNlcjpwYXNzd29yZA=="
}
}
}
For more info, please take a look to the Kubernetes documentation.
Create the Registry
Once your Secret is ready, you can reference it on the Registry configuration, specifying the name in the Registry field spec.authSecret.
apiVersion: sbomscanner.kubewarden.io/v1alpha1
kind: Registry
metadata:
name: my-first-registry
namespace: default
spec:
uri: dev-registry.default.svc.cluster.local:5000
scanInterval: 1h
authSecret: my-auth-secret
This will allow Kubewarden SBOM Scanner to scan for images from private registries.
Please, note:
The Secret and the Registry must be defined inside of the very same Namespace.
Registries with a private certificate authority
If the certificate of a registry comes from a private certificate authority (CA), SBOM Scanner needs the CA certificate to make sure that it connects to the correct registry.
Put the CA certificates in a ConfigMap or a Secret, in PEM format.
Then refer to the object in the spec.caBundleRef field of the Registry.
This example uses a ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: registry-ca
namespace: default
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
---
apiVersion: sbomscanner.kubewarden.io/v1alpha1
kind: Registry
metadata:
name: my-private-ca-registry
namespace: default
spec:
uri: dev-registry.default.svc.cluster.local:5000
scanInterval: 1h
caBundleRef:
configMap:
name: registry-ca
key: ca.crt
This example uses the ca.crt key of a Secret of type kubernetes.io/tls, for example a Secret that cert-manager creates:
apiVersion: sbomscanner.kubewarden.io/v1alpha1
kind: Registry
metadata:
name: my-private-ca-registry
namespace: default
spec:
uri: dev-registry.default.svc.cluster.local:5000
scanInterval: 1h
caBundleRef:
secret:
name: registry-tls
The caBundleRef field has these rules:
-
Set exactly one of
configMaporsecret. -
nameis the name of the ConfigMap or the Secret. -
keyis the key that holds the CA certificates. If you do not set it, SBOM Scanner usesca.crt. -
The ConfigMap or the Secret must be in the namespace of the
Registry. -
The value of the key can hold more than one certificate.
A Registry cannot set both caBundle and caBundleRef.
The API server rejects a Registry that sets both, with the message caBundle and caBundleRef are mutually exclusive.
The deprecated caBundle field
Earlier versions used the spec.caBundle field, which holds the CA certificates in the Registry itself.
This field still works, but it is deprecated, and a later version removes it.
When you create or update a resource that sets spec.caBundle, the API server returns this warning:
spec.caBundle is deprecated and will be removed in the following versions. Use spec.caBundleRef instead.
To move a resource to caBundleRef, see Move the CA bundles to caBundleRef.
CA bundle errors
If the CA bundle does not contain a valid PEM certificate, the scan fails with this error:
CA bundle does not contain any valid PEM-encoded certificate
This rule applies to caBundle and to caBundleRef.
Earlier versions ignored a CA bundle without a valid certificate, and used the trust store of the system.
The scan also fails when SBOM Scanner cannot read the CA bundle. See Common problems for each error and its fix.
CA bundles for workload scans
The workload scan creates and manages its own Registry resources.
Do not set caBundleRef on these resources.
Set caBundleRef on the WorkloadScanConfiguration instead.
The controller copies the value to the Registry resources that it manages.
For a workload scan, the ConfigMap or the Secret must be in the namespace where SBOM Scanner is installed.
The worker does not read it from the namespace of the Registry.
This example creates the ConfigMap in the sbomscanner namespace, and sets caBundleRef on the WorkloadScanConfiguration:
apiVersion: v1
kind: ConfigMap
metadata:
name: workload-scan-ca
namespace: sbomscanner
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
---
apiVersion: sbomscanner.kubewarden.io/v1alpha1
kind: WorkloadScanConfiguration
metadata:
name: default
spec:
namespaceSelector:
matchLabels:
sbomscanner.kubewarden.io/workloadscan: "true"
artifactsNamespace: sbomscanner
caBundleRef:
configMap:
name: workload-scan-ca
If you already have a WorkloadScanConfiguration, add caBundleRef to it and keep its other fields.
kubectl apply removes the fields that are not in the file.
The API server rejects a change of artifactsNamespace while the workload scan is enabled.
See Scanning Workloads.