VK Cloud logo

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.

Before you start

  1. Create a Kubernetes cluster of the latest version, if not done so already.

  2. Make sure that you can connect to the cluster with kubectl.

  3. Install the cert-operator add-on, if not done so already.

  4. 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.

1. Create a RegistryCertificate object

  1. Create the registry-certificate.yaml manifest with a RegistryCertificate object 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 the host[: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.

  2. Apply the manifest to the cluster:

    kubectl apply -f registry-certificate.yaml

    The 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.

2. Check the add-on operation

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. The Message field shows the reason.

For more details about how cert-operator works and its limits, see the Add-ons section.

Delete unused resources

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:

  1. Delete the RegistryCertificate object:

    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.

  2. (Optional) Delete the add-on.

    The CA certificates that are already on the nodes stay there, but the add-on stops the synchronization of RegistryCertificate objects. To resume the synchronization, install the add-on again.

  3. Stop the cluster you created to use it later or delete it permanently.

Was this article helpful?