|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * post_installation_configuration/connected-to-disconnected.adoc |
| 4 | + |
| 5 | +[id="connected-to-disconnected-config-registry_{context}"] |
| 6 | += Configuring the cluster for the mirror registry |
| 7 | + |
| 8 | +After creating and mirroring the images to the mirror registry, you must modify your cluster so that pods can pull images from the mirror registry. |
| 9 | + |
| 10 | +You must: |
| 11 | + |
| 12 | +* Add the mirror registry credentials to the global pull secret. |
| 13 | +* Add the mirror registry server certificate to the cluster. |
| 14 | +* Create an `ImageContentSourcePolicy` custom resource (ICSP), which associates the mirror registry with the source registry. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +. Add mirror registry credential to the cluster global pull-secret: |
| 19 | ++ |
| 20 | +[source,terminal] |
| 21 | +---- |
| 22 | +$ oc set data secret/pull-secret -n openshift-config --from-file=.dockerconfigjson=<pull_secret_location> <1> |
| 23 | +---- |
| 24 | +<1> Provide the path to the new pull secret file. |
| 25 | ++ |
| 26 | +For example: |
| 27 | ++ |
| 28 | +[source,terminal] |
| 29 | +---- |
| 30 | +$ oc set data secret/pull-secret -n openshift-config --from-file=.dockerconfigjson=.mirrorsecretconfigjson |
| 31 | +---- |
| 32 | + |
| 33 | +. Add the CA-signed mirror registry server certificate to the nodes in the cluster: |
| 34 | + |
| 35 | +.. Create a config map that includes the server certificate for the mirror registry |
| 36 | ++ |
| 37 | +[source,terminal] |
| 38 | +---- |
| 39 | +$ oc create configmap <config_map_name> --from-file=<mirror_address_host>..<port>=$path/ca.crt -n openshift-config |
| 40 | +---- |
| 41 | ++ |
| 42 | +For example: |
| 43 | ++ |
| 44 | +[source,terminal] |
| 45 | +---- |
| 46 | +S oc create configmap registry-config --from-file=mirror.registry.com..443=/root/certs/ca-chain.cert.pem -n openshift-config |
| 47 | +---- |
| 48 | + |
| 49 | +.. Use the config map to update the `image.config.openshift.io/cluster` custom resource (CR). {product-title} applies the changes to this CR to all nodes in the cluster: |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"<config_map_name>"}}}' --type=merge |
| 54 | +---- |
| 55 | ++ |
| 56 | +For example: |
| 57 | ++ |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +$ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"registry-config"}}}' --type=merge |
| 61 | +---- |
| 62 | + |
| 63 | +. Create an ICSP to redirect container pull requests from the online registries to the mirror registry: |
| 64 | + |
| 65 | +.. Create the `ImageContentSourcePolicy` custom resource: |
| 66 | ++ |
| 67 | +[source,yaml] |
| 68 | +---- |
| 69 | +apiVersion: operator.openshift.io/v1alpha1 |
| 70 | +kind: ImageContentSourcePolicy |
| 71 | +metadata: |
| 72 | + name: mirror-ocp |
| 73 | +spec: |
| 74 | + repositoryDigestMirrors: |
| 75 | + - mirrors: |
| 76 | + - mirror.registry.com:443/ocp/release <1> |
| 77 | + source: quay.io/openshift-release-dev/ocp-release <2> |
| 78 | + - mirrors: |
| 79 | + - mirror.registry.com:443/ocp/release |
| 80 | + source: quay.io/openshift-release-dev/ocp-v4.0-art-dev |
| 81 | +---- |
| 82 | +<1> Specifies the name of the mirror image registry and repository. |
| 83 | +<2> Specifies the online registry and repository containing the content that is mirrored. |
| 84 | + |
| 85 | +.. Create the ICSP object: |
| 86 | ++ |
| 87 | +[source,terminal] |
| 88 | +---- |
| 89 | +$ oc create -f registryrepomirror.yaml |
| 90 | +---- |
| 91 | ++ |
| 92 | +.Example output |
| 93 | +[source,terminal] |
| 94 | +---- |
| 95 | +imagecontentsourcepolicy.operator.openshift.io/mirror-ocp created |
| 96 | +---- |
| 97 | ++ |
| 98 | +{product-title} applies the changes to this CR to all nodes in the cluster. |
| 99 | + |
| 100 | +. Verify that the credentials, CA, and ICSP for mirror registry were added: |
| 101 | + |
| 102 | +.. Log into a node: |
| 103 | ++ |
| 104 | +[source,terminal] |
| 105 | +---- |
| 106 | +$ oc debug node/<node_name> |
| 107 | +---- |
| 108 | + |
| 109 | +.. Set `/host` as the root directory within the debug shell: |
| 110 | ++ |
| 111 | +[source,terminal] |
| 112 | +---- |
| 113 | +sh-4.4# chroot /host |
| 114 | +---- |
| 115 | + |
| 116 | +.. Check the `config.json` file for the credentials: |
| 117 | ++ |
| 118 | +[source,terminal] |
| 119 | +---- |
| 120 | +sh-4.4# cat /var/lib/kubelet/config.json |
| 121 | +---- |
| 122 | ++ |
| 123 | +.Example output |
| 124 | +[source,terminal] |
| 125 | +---- |
| 126 | +{"auths":{"brew.registry.redhat.io":{"xx=="},"brewregistry.stage.redhat.io":{"auth":"xxx=="},"mirror.registry.com:443":{"auth":"xx="}}} <1> |
| 127 | +---- |
| 128 | +<1> Ensure that the mirror registry and credentials are present. |
| 129 | + |
| 130 | +.. Change to the `certs.d` directory |
| 131 | ++ |
| 132 | +[source,terminal] |
| 133 | +---- |
| 134 | +sh-4.4# cd /etc/docker/certs.d/ |
| 135 | +---- |
| 136 | + |
| 137 | +.. List the certificates in the `certs.d` directory: |
| 138 | ++ |
| 139 | +[source,terminal] |
| 140 | +---- |
| 141 | +sh-4.4# ls |
| 142 | +---- |
| 143 | ++ |
| 144 | +.Example output |
| 145 | +---- |
| 146 | +image-registry.openshift-image-registry.svc.cluster.local:5000 |
| 147 | +image-registry.openshift-image-registry.svc:5000 |
| 148 | +mirror.registry.com:443 <1> |
| 149 | +---- |
| 150 | +<1> Ensure that the mirror registry is in the list. |
| 151 | + |
| 152 | +.. Check that the ICSP added the mirror registry to the `registries.conf` file: |
| 153 | ++ |
| 154 | +[source,terminal] |
| 155 | +---- |
| 156 | +sh-4.4# cat /etc/containers/registries.conf |
| 157 | +---- |
| 158 | ++ |
| 159 | +.Example output |
| 160 | ++ |
| 161 | +[source,terminal] |
| 162 | +---- |
| 163 | +unqualified-search-registries = ["registry.access.redhat.com", "docker.io"] |
| 164 | +
|
| 165 | +[[registry]] |
| 166 | + prefix = "" |
| 167 | + location = "quay.io/openshift-release-dev/ocp-release" |
| 168 | + mirror-by-digest-only = true |
| 169 | +
|
| 170 | + [[registry.mirror]] |
| 171 | + location = "mirror.registry.com:443/ocp/release" |
| 172 | +
|
| 173 | +[[registry]] |
| 174 | + prefix = "" |
| 175 | + location = "quay.io/openshift-release-dev/ocp-v4.0-art-dev" |
| 176 | + mirror-by-digest-only = true |
| 177 | +
|
| 178 | + [[registry.mirror]] |
| 179 | + location = "mirror.registry.com:443/ocp/release" |
| 180 | +---- |
| 181 | ++ |
| 182 | +The `registry.mirror` parameters indicate that the mirror registry is searched before the original registry. |
| 183 | + |
| 184 | +.. Exit the node. |
| 185 | ++ |
| 186 | +[source,terminal] |
| 187 | +---- |
| 188 | +sh-4.4# exit |
| 189 | +---- |
| 190 | + |
0 commit comments