|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * openshift_images/image-configuration.adoc |
| 4 | +// * post_installation_configuration/preparing-for-users.adoc |
| 5 | + |
| 6 | +[id="images-configuration-shortname_{context}"] |
| 7 | += Adding registries that allow image short names |
| 8 | + |
| 9 | +You can add registries to search for an image short name by editing the `image.config.openshift.io/cluster` custom resource (CR). {product-title} applies the changes to this CR to all nodes in the cluster. |
| 10 | + |
| 11 | +An image short name enables you to search for images without including the fully qualified domain name in the pull spec. For example, you could use `rhel7/etcd` instead of `registry.access.redhat.com/rhe7/etcd`. |
| 12 | + |
| 13 | +You might use short names in situations where using the full path is not practical. For example, if your cluster references multiple internal registries whose DNS changes frequently, you would need to update the fully qualified domain names in your pull specs with each change. In this case, using an image short name might be beneficial. |
| 14 | + |
| 15 | +When pulling or pushing images, the container runtime searches the registries listed under the `registrySources` parameter in the `image.config.openshift.io/cluster` CR. If you created a list of registries under the `containerRuntimeSearchRegistries` parameter, when pulling an image with a short name, the container runtime searches those registries. |
| 16 | + |
| 17 | +[WARNING] |
| 18 | +==== |
| 19 | +Using image short names with public registries is strongly discouraged. You should use image short names with only internal or private registries. |
| 20 | +
|
| 21 | +If you list public registries under the `containerRuntimeSearchRegistries` parameter, you expose your credentials to all the registries on the list and you risk network and registry attacks. You should always use fully-qualified image names with public registries. |
| 22 | +==== |
| 23 | + |
| 24 | +The Machine Config Operator (MCO) watches the `image.config.openshift.io/cluster` resource for any changes to the registries. When the MCO detects a change, it drains the nodes, applies the change, and uncordons the nodes. After the nodes return to the `Ready` state, if the `containerRuntimeSearchRegistries` parameter is added, the MCO creates a file in the `/etc/containers/registries.conf.d` directory on each node with the listed registries. The file overrides the default list of unqualified search registries in the `/host/etc/containers/registries.conf` file. There is no way to fall back to the default list of unqualified search registries. |
| 25 | + |
| 26 | +The `containerRuntimeSearchRegistries` parameter works only with the Podman and CRI-O container engines. The registries in the list can be used only in pod specs, not in builds and image streams. |
| 27 | + |
| 28 | +.Procedure |
| 29 | + |
| 30 | +. Edit the `image.config.openshift.io/cluster` custom resource: |
| 31 | ++ |
| 32 | +[source,terminal] |
| 33 | +---- |
| 34 | +$ oc edit image.config.openshift.io/cluster |
| 35 | +---- |
| 36 | ++ |
| 37 | +The following is an example `image.config.openshift.io/cluster` CR: |
| 38 | ++ |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +apiVersion: config.openshift.io/v1 |
| 42 | +kind: Image |
| 43 | +metadata: |
| 44 | + annotations: |
| 45 | + release.openshift.io/create-only: "true" |
| 46 | + creationTimestamp: "2019-05-17T13:44:26Z" |
| 47 | + generation: 1 |
| 48 | + name: cluster |
| 49 | + resourceVersion: "8302" |
| 50 | + selfLink: /apis/config.openshift.io/v1/images/cluster |
| 51 | + uid: e34555da-78a9-11e9-b92b-06d6c7da38dc |
| 52 | +spec: |
| 53 | + allowedRegistriesForImport: |
| 54 | + - domainName: quay.io |
| 55 | + insecure: false |
| 56 | + additionalTrustedCA: |
| 57 | + name: myconfigmap |
| 58 | + registrySources: |
| 59 | + containerRuntimeSearchRegistries: <1> |
| 60 | + - "reg1.io" |
| 61 | + - "reg2.io" |
| 62 | + - "reg3.io" |
| 63 | + allowedRegistries: <2> |
| 64 | + - example.com |
| 65 | + - quay.io |
| 66 | + - registry.redhat.io |
| 67 | + - "reg1.io" |
| 68 | + - "reg2.io" |
| 69 | + - "reg3.io" |
| 70 | +... |
| 71 | +status: |
| 72 | + internalRegistryHostname: image-registry.openshift-image-registry.svc:5000 |
| 73 | +---- |
| 74 | +<1> Specify registries to use with image short names. You should use image short names with only internal or private registries to reduce possible security risks. |
| 75 | +<2> Ensure that any registries listed under `containerRuntimeSearchRegistries` are included in the `allowedRegistries` list. |
| 76 | ++ |
| 77 | +[NOTE] |
| 78 | +==== |
| 79 | +When the `allowedRegistries` parameter is defined, all registries including the `registry.redhat.io` and `quay.io` registries are blocked unless explicitly listed. If you use this parameter, to prevent pod failure, add `registry.redhat.io` and `quay.io` to the `allowedRegistries` list, as they are required by payload images within your environment. |
| 80 | +==== |
| 81 | + |
| 82 | +. To check that the registries have been added, use the following command on a node: |
| 83 | ++ |
| 84 | +[source,terminal] |
| 85 | +---- |
| 86 | +$ cat /host/etc/containers/registries.conf.d/01-image-searchRegistries.conf |
| 87 | +---- |
| 88 | ++ |
| 89 | +.Example output |
| 90 | +[source,terminal] |
| 91 | +---- |
| 92 | +unqualified-search-registries = ['reg1.io', 'reg2.io', 'reg3.io'] |
| 93 | +---- |
| 94 | + |
0 commit comments