Configure CRI-O to use a registry mirror for Operators
To use a registry mirror for Operators with MicroShift, you must transform the ImageDigestMirrorSet YAML file created by the oc-mirror plugin into a format that is compatible with the MicroShift CRI-O container runtime configuration.
.Prerequisites
-
The OpenShift CLI (
oc) is installed. -
You installed Operator Lifecycle Manager (OLM).
-
You installed the oc-mirror plugin.
-
You installed the
yqbinary. -
The
ImageDigestMirrorSetandCatalogSourceYAML files are available in thecluster-resourcessubdirectory.
-
Confirm the contents of the
ImageDigestMirrorSetYAML file by running the following command:$ cat <v2_workspace>/working-dir/cluster-resources/imagedigestmirrorset.yamlReplace <v2_workspace> with the directory name that you used when you generated mirroring resources.
Example outputapiVersion: config.openshift.io/v1 kind: ImageDigestMirrorSet metadata: labels: operators.openshift.org/catalog: "true" name: operator-0 spec: imageDigestMirrors: - mirrors: - registry.example.com/amq7 source: registry.redhat.io/amq7 -
Transform the
imagedigestmirrorset.yamlinto a format ready for CRI-O configuration by running the following command:$ yq '.spec.imageDigestMirrors[] as $item ireduce([]; . + [{"mirror": $item.mirrors[], "source": ($item | .source)}]) | .[] | "[[registry]] prefix = \"" + .source + "\" location = \"" + .mirror + "\" mirror-by-digest-only = true insecure = true "' ./mirror1/working-dir/cluster-resources/imagedigestmirrorset.yamlExample output[[registry]] prefix = "registry.redhat.io/amq7" location = "registry.example.com/amq7" mirror-by-digest-only = true insecure = true -
Add the output to the CRI-O configuration file in the
/etc/containers/registries.conf.d/directory:Examplecrio-config.yamlmirror configuration file[[registry]] prefix = "registry.redhat.io/amq7" location = "registry.example.com/amq7" mirror-by-digest-only = true insecure = true [[registry]] prefix = "" location = "quay.io" mirror-by-digest-only = true [[registry.mirror]] location = "<registry_host>:<port>" insecure = falsewhere
registry.mirror.location-
Specifies the hostname and port of your mirror registry server, for example
microshift-quay:8443.
-
Apply the CRI-O configuration changes by restarting MicroShift with the following command:
$ sudo systemctl restart crio