Using cert-operator
Use the cert-operator add-on to pull images from container registries that have self-signed certificates. The add-on automatically makes the registry a trusted one.
-
Create a Kubernetes cluster of the latest version, if not done so already.
-
Make sure that you can connect to the cluster with
kubectl. -
Install the cert-operator add-on, if not done so already.
-
Get the CA certificate of the registry in PEM format. To use a certificate chain, put the certificates one after another.
The add-on works only with CA certificates and certificate chains. It does not use client certificates, private keys, or mutual TLS (mTLS) authentication.
-
Create the
registry-certificate.yamlmanifest with aRegistryCertificateobject for the CA certificate of the registry:apiVersion: crio.registry/v1alpha1kind: RegistryCertificatemetadata:name: <OBJECT_NAME>spec:host: <REGISTRY_ADDRESS>certificate: |-----BEGIN CERTIFICATE-----<CERTIFICATE_CONTENT>-----END CERTIFICATE-----Here:
-
<OBJECT_NAME>— a unique name. The object is for the whole cluster, so do not specify a namespace. -
<REGISTRY_ADDRESS>— the address of the registry in thehost[:port]format, for example,registry.example.com:5000.If you create several objects for one registry address, the add-on applies the first object in alphabetical order. If the registry address in an object is not valid, the add-on does not apply this object.
-
<CERTIFICATE_CONTENT>— the content of the CA certificate.If the certificate in an object is not valid, the add-on does not apply it. If the add-on applied a CA certificate for this registry before, this certificate does not change.
-
-
Apply the manifest to the cluster:
kubectl apply -f registry-certificate.yamlThe add-on transfers the CA certificate to all worker nodes. By default, this takes up to 30 seconds. If you change the CA certificate in the object later, the add-on replaces the old certificate on the nodes with the new one.
To check that the add-on applied the CA certificate, run the command:
kubectl describe regcert <OBJECT_NAME>
The State field shows the status of the CA certificate for each worker node:
Synced— the add-on applied the CA certificate.Failed— the add-on did not apply the CA certificate. TheMessagefield shows the reason.
For more details about how cert-operator works and its limits, see the Add-ons section.
A running cluster is billed and consumes computing resources. If you no longer need the Kubernetes resources that you created to test the cert-operator add-on, delete them:
-
Delete the
RegistryCertificateobject:kubectl delete regcert <OBJECT_NAME>The add-on removes the CA certificate from the worker nodes. The add-on does not apply this certificate anymore, and the registry is not trusted.
-
(Optional) Delete the add-on.
The CA certificates that are already on the nodes stay there, but the add-on stops the synchronization of
RegistryCertificateobjects. To resume the synchronization, install the add-on again. -
Stop the cluster you created to use it later or delete it permanently.