Este contenido no está disponible en el idioma seleccionado.
Chapter 9. Image configuration resources
Use the following procedure to configure image registries.
9.1. Image controller configuration parameters Copiar enlaceEnlace copiado en el portapapeles!
The
image.config.openshift.io/cluster
cluster
spec
Parameters such as
DisableScheduledImport
MaxImagesBulkImportedPerRepository
MaxScheduledImportsPerMinute
ScheduledImageImportMinimumIntervalSeconds
InternalRegistryHostname
| Parameter | Description |
|---|---|
|
| Limits the container image registries from which normal users can import images. Set this list to the registries that you trust to contain valid images, and that you want applications to be able to import from. Users with permission to create images or
Every element of this list contains a location of the registry specified by the registry domain name.
|
|
| A reference to a config map containing additional CAs that should be trusted during
The namespace for this config map is
|
|
| Provides the hostnames for the default external image registry. The external hostname should be set only when the image registry is exposed externally. The first value is used in
|
|
| Contains configuration that determines how the container runtime should treat individual registries when accessing images for builds and pods. For instance, whether or not to allow insecure access. It does not contain configuration for the internal cluster registry.
Either
|
When the
allowedRegistries
registry.redhat.io
quay.io
registry.redhat.io
quay.io
internalRegistryHostname
allowedRegistries
The
status
image.config.openshift.io/cluster
| Parameter | Description |
|---|---|
|
| Set by the Image Registry Operator, which controls the
|
|
| Set by the Image Registry Operator, provides the external hostnames for the image registry when it is exposed externally. The first value is used in
|
9.2. Configuring image registry settings Copiar enlaceEnlace copiado en el portapapeles!
You can configure image registry settings by editing the
image.config.openshift.io/cluster
image.config.openshift.io/cluster
Procedure
Edit the
custom resource:image.config.openshift.io/cluster$ oc edit image.config.openshift.io/clusterThe following is an example
CR:image.config.openshift.io/clusterapiVersion: config.openshift.io/v1 kind: Image1 metadata: annotations: release.openshift.io/create-only: "true" creationTimestamp: "2019-05-17T13:44:26Z" generation: 1 name: cluster resourceVersion: "8302" selfLink: /apis/config.openshift.io/v1/images/cluster uid: e34555da-78a9-11e9-b92b-06d6c7da38dc spec: allowedRegistriesForImport:2 - domainName: quay.io insecure: false additionalTrustedCA:3 name: myconfigmap registrySources:4 allowedRegistries: - example.com - quay.io - registry.redhat.io - image-registry.openshift-image-registry.svc:5000 - reg1.io/myrepo/myapp:latest insecureRegistries: - insecure.com status: internalRegistryHostname: image-registry.openshift-image-registry.svc:5000- 1
Image: Holds cluster-wide information about how to handle images. The canonical, and only valid name iscluster.- 2
allowedRegistriesForImport: Limits the container image registries from which normal users may import images. Set this list to the registries that you trust to contain valid images, and that you want applications to be able to import from. Users with permission to create images orImageStreamMappingsfrom the API are not affected by this policy. Typically only cluster administrators have the appropriate permissions.- 3
additionalTrustedCA: A reference to a config map containing additional certificate authorities (CA) that are trusted during image stream import, pod image pull,openshift-image-registrypullthrough, and builds. The namespace for this config map isopenshift-config. The format of the config map is to use the registry hostname as the key, and the PEM certificate as the value, for each additional registry CA to trust.- 4
registrySources: Contains configuration that determines whether the container runtime allows or blocks individual registries when accessing images for builds and pods. Either theallowedRegistriesparameter or theblockedRegistriesparameter can be set, but not both. You can also define whether or not to allow access to insecure registries or registries that allow registries that use image short names. This example uses theallowedRegistriesparameter, which defines the registries that are allowed to be used. The insecure registryinsecure.comis also allowed. TheregistrySourcesparamter does not contain configuration for the internal cluster registry.
NoteWhen the
parameter is defined, all registries, including the registry.redhat.io and quay.io registries and the default internal image registry, are blocked unless explicitly listed. If you use the parameter, to prevent pod failure, you must add theallowedRegistriesandregistry.redhat.ioregistries and thequay.ioto theinternalRegistryHostnamelist, as they are required by payload images within your environment. Do not add theallowedRegistriesandregistry.redhat.ioregistries to thequay.iolist.blockedRegistriesWhen using the
,allowedRegistries, orblockedRegistriesparameter, you can specify an individual repository within a registry. For example:insecureRegistries.reg1.io/myrepo/myapp:latestInsecure external registries should be avoided to reduce possible security risks.
To check that the changes are applied, list your nodes:
$ oc get nodesExample output
NAME STATUS ROLES AGE VERSION ci-ln-j5cd0qt-f76d1-vfj5x-master-0 Ready master 98m v1.19.0+7070803 ci-ln-j5cd0qt-f76d1-vfj5x-master-1 Ready,SchedulingDisabled master 99m v1.19.0+7070803 ci-ln-j5cd0qt-f76d1-vfj5x-master-2 Ready master 98m v1.19.0+7070803 ci-ln-j5cd0qt-f76d1-vfj5x-worker-b-nsnd4 Ready worker 90m v1.19.0+7070803 ci-ln-j5cd0qt-f76d1-vfj5x-worker-c-5z2gz NotReady,SchedulingDisabled worker 90m v1.19.0+7070803 ci-ln-j5cd0qt-f76d1-vfj5x-worker-d-stsjv Ready worker 90m v1.19.0+7070803
9.2.1. Adding specific registries Copiar enlaceEnlace copiado en el portapapeles!
You can add a list of registries, and optionally an individual repository within a registry, that are permitted for image pull and push actions by editing the
image.config.openshift.io/cluster
When pulling or pushing images, the container runtime searches the registries listed under the
registrySources
image.config.openshift.io/cluster
allowedRegistries
When the
allowedRegistries
registry.redhat.io
quay.io
registry.redhat.io
quay.io
internalRegistryHostname
allowedRegistries
Procedure
Edit the
CR:image.config.openshift.io/cluster$ oc edit image.config.openshift.io/clusterThe following is an example
CR with an allowed list:image.config.openshift.io/clusterapiVersion: config.openshift.io/v1 kind: Image metadata: annotations: release.openshift.io/create-only: "true" creationTimestamp: "2019-05-17T13:44:26Z" generation: 1 name: cluster resourceVersion: "8302" selfLink: /apis/config.openshift.io/v1/images/cluster uid: e34555da-78a9-11e9-b92b-06d6c7da38dc spec: registrySources:1 allowedRegistries:2 - example.com - quay.io - registry.redhat.io - reg1.io/myrepo/myapp:latest - image-registry.openshift-image-registry.svc:5000 status: internalRegistryHostname: image-registry.openshift-image-registry.svc:5000- 1
- Contains configurations that determine how the container runtime should treat individual registries when accessing images for builds and pods. It does not contain configuration for the internal cluster registry.
- 2
- Specify registries, and optionally a repository in that registry, to use for image pull and push actions. All other registries are blocked.
NoteEither the
parameter or theallowedRegistriesparameter can be set, but not both.blockedRegistriesThe Machine Config Operator (MCO) watches the
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 theimage.config.openshift.io/clusterstate, the allowed registries list is used to update the image signature policy in theReadyfile on each node./host/etc/containers/policy.jsonTo check that the registries have been added to the policy file, use the following command on a node:
$ cat /host/etc/containers/policy.jsonThe following policy indicates that only images from the example.com, quay.io, and registry.redhat.io registries are permitted for image pulls and pushes:
Example 9.1. Example image signature policy file
{ "default":[ { "type":"reject" } ], "transports":{ "atomic":{ "example.com":[ { "type":"insecureAcceptAnything" } ], "image-registry.openshift-image-registry.svc:5000":[ { "type":"insecureAcceptAnything" } ], "insecure.com":[ { "type":"insecureAcceptAnything" } ], "quay.io":[ { "type":"insecureAcceptAnything" } ], "reg4.io/myrepo/myapp:latest":[ { "type":"insecureAcceptAnything" } ], "registry.redhat.io":[ { "type":"insecureAcceptAnything" } ] }, "docker":{ "example.com":[ { "type":"insecureAcceptAnything" } ], "image-registry.openshift-image-registry.svc:5000":[ { "type":"insecureAcceptAnything" } ], "insecure.com":[ { "type":"insecureAcceptAnything" } ], "quay.io":[ { "type":"insecureAcceptAnything" } ], "reg4.io/myrepo/myapp:latest":[ { "type":"insecureAcceptAnything" } ], "registry.redhat.io":[ { "type":"insecureAcceptAnything" } ] }, "docker-daemon":{ "":[ { "type":"insecureAcceptAnything" } ] } } }
If your cluster uses the
registrySources.insecureRegistries
For example:
spec:
registrySources:
insecureRegistries:
- insecure.com
allowedRegistries:
- example.com
- quay.io
- registry.redhat.io
- insecure.com
- image-registry.openshift-image-registry.svc:5000
9.2.2. Blocking specific registries Copiar enlaceEnlace copiado en el portapapeles!
You can block any registry, and optionally an individual repository within a registry, by editing the
image.config.openshift.io/cluster
When pulling or pushing images, the container runtime searches the registries listed under the
registrySources
image.config.openshift.io/cluster
blockedRegistries
To prevent pod failure, do not add the
registry.redhat.io
quay.io
blockedRegistries
Procedure
Edit the
CR:image.config.openshift.io/cluster$ oc edit image.config.openshift.io/clusterThe following is an example
CR with a blocked list:image.config.openshift.io/clusterapiVersion: config.openshift.io/v1 kind: Image metadata: annotations: release.openshift.io/create-only: "true" creationTimestamp: "2019-05-17T13:44:26Z" generation: 1 name: cluster resourceVersion: "8302" selfLink: /apis/config.openshift.io/v1/images/cluster uid: e34555da-78a9-11e9-b92b-06d6c7da38dc spec: registrySources:1 blockedRegistries:2 - untrusted.com - reg1.io/myrepo/myapp:latest status: internalRegistryHostname: image-registry.openshift-image-registry.svc:5000- 1
- Contains configurations that determine how the container runtime should treat individual registries when accessing images for builds and pods. It does not contain configuration for the internal cluster registry.
- 2
- Specify registries, and optionally a repository in that registry, that should not be used for image pull and push actions. All other registries are allowed.
NoteEither the
registry or theblockedRegistriesregistry can be set, but not both.allowedRegistriesThe Machine Config Operator (MCO) watches the
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 theimage.config.openshift.io/clusterstate, changes to the blocked registries appear in theReadyfile on each node./etc/containers/registries.confTo check that the registries have been added to the policy file, use the following command on a node:
$ cat /host/etc/containers/registries.confThe following example indicates that images from the
registry are prevented for image pulls and pushes:untrusted.comExample output
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"] [[registry]] prefix = "" location = "untrusted.com" blocked = true
9.2.3. Allowing insecure registries Copiar enlaceEnlace copiado en el portapapeles!
You can add insecure registries, and optionally an individual repository within a registry, by editing the
image.config.openshift.io/cluster
Registries that do not use valid SSL certificates or do not require HTTPS connections are considered insecure.
Insecure external registries should be avoided to reduce possible security risks.
Procedure
Edit the
CR:image.config.openshift.io/cluster$ oc edit image.config.openshift.io/clusterThe following is an example
CR with an insecure registries list:image.config.openshift.io/clusterapiVersion: config.openshift.io/v1 kind: Image metadata: annotations: release.openshift.io/create-only: "true" creationTimestamp: "2019-05-17T13:44:26Z" generation: 1 name: cluster resourceVersion: "8302" selfLink: /apis/config.openshift.io/v1/images/cluster uid: e34555da-78a9-11e9-b92b-06d6c7da38dc spec: registrySources:1 insecureRegistries:2 - insecure.com - reg4.io/myrepo/myapp:latest allowedRegistries: - example.com - quay.io - registry.redhat.io - insecure.com3 - reg4.io/myrepo/myapp:latest - image-registry.openshift-image-registry.svc:5000 status: internalRegistryHostname: image-registry.openshift-image-registry.svc:5000- 1
- Contains configurations that determine how the container runtime should treat individual registries when accessing images for builds and pods. It does not contain configuration for the internal cluster registry.
- 2
- Specify an insecure registry. You can specify a repository in that registry.
- 3
- Ensure that any insecure registries are included in the
allowedRegistrieslist.
NoteWhen the
parameter is defined, all registries, including the registry.redhat.io and quay.io registries and the default internal image registry, are blocked unless explicitly listed. If you use the parameter, to prevent pod failure, add all registries including theallowedRegistriesandregistry.redhat.ioregistries and thequay.ioto theinternalRegistryHostnamelist, as they are required by payload images within your environment. For disconnected clusters, mirror registries should also be added.allowedRegistriesThe Machine Config Operator (MCO) watches the
CR for any changes to the registries, then drains and uncordons the nodes when it detects changes. After the nodes return to theimage.config.openshift.io/clusterstate, changes to the insecure and blocked registries appear in theReadyfile on each node./etc/containers/registries.confTo check that the registries have been added to the policy file, use the following command on a node:
$ cat /host/etc/containers/registries.confThe following example indicates that images from the
registry is insecure and is allowed for image pulls and pushes.insecure.comExample output
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"] [[registry]] prefix = "" location = "insecure.com" insecure = true
9.2.4. Adding registries that allow image short names Copiar enlaceEnlace copiado en el portapapeles!
You can add registries to search for an image short name by editing the
image.config.openshift.io/cluster
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
registry.access.redhat.com/rhe7/etcd
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.
When pulling or pushing images, the container runtime searches the registries listed under the
registrySources
image.config.openshift.io/cluster
containerRuntimeSearchRegistries
Using image short names with public registries is strongly discouraged. You should use image short names with only internal or private registries.
If you list public registries under the
containerRuntimeSearchRegistries
The Machine Config Operator (MCO) watches the
image.config.openshift.io/cluster
Ready
containerRuntimeSearchRegistries
/etc/containers/registries.conf.d
/host/etc/containers/registries.conf
The
containerRuntimeSearchRegistries
Procedure
Edit the
custom resource:image.config.openshift.io/cluster$ oc edit image.config.openshift.io/clusterThe following is an example
CR:image.config.openshift.io/clusterapiVersion: config.openshift.io/v1 kind: Image metadata: annotations: release.openshift.io/create-only: "true" creationTimestamp: "2019-05-17T13:44:26Z" generation: 1 name: cluster resourceVersion: "8302" selfLink: /apis/config.openshift.io/v1/images/cluster uid: e34555da-78a9-11e9-b92b-06d6c7da38dc spec: allowedRegistriesForImport: - domainName: quay.io insecure: false additionalTrustedCA: name: myconfigmap registrySources: containerRuntimeSearchRegistries:1 - reg1.io - reg2.io - reg3.io allowedRegistries:2 - example.com - quay.io - registry.redhat.io - reg1.io - reg2.io - reg3.io - image-registry.openshift-image-registry.svc:5000 ... status: internalRegistryHostname: image-registry.openshift-image-registry.svc:5000NoteWhen the
parameter is defined, all registries, including theallowedRegistriesandregistry.redhat.ioregistries and the default internal image registry, are blocked unless explicitly listed. If you use this parameter, to prevent pod failure, add all registries including thequay.ioandregistry.redhat.ioregistries and thequay.ioto theinternalRegistryHostnamelist, as they are required by payload images within your environment. For disconnected clusters, mirror registries should also be added.allowedRegistriesTo check that the registries have been added, when a node returns to the
state, use the following command on the node:Ready$ cat /host/etc/containers/registries.conf.d/01-image-searchRegistries.confExample output
unqualified-search-registries = ['reg1.io', 'reg2.io', 'reg3.io']
9.2.5. Configuring additional trust stores for image registry access Copiar enlaceEnlace copiado en el portapapeles!
The
image.config.openshift.io/cluster
Prerequisites
- The certificate authorities (CA) must be PEM-encoded.
Procedure
You can create a config map in the
openshift-config
AdditionalTrustedCA
image.config.openshift.io
The config map key is the hostname of a registry with the port for which this CA is to be trusted, and the base64-encoded certificate is the value, for each additional registry CA to trust.
Image registry CA config map example
apiVersion: v1
kind: ConfigMap
metadata:
name: my-registry-ca
data:
registry.example.com: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
registry-with-port.example.com..5000: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
- 1
- If the registry has the port, such as
registry-with-port.example.com:5000,:should be replaced with...
You can configure additional CAs with the following procedure.
To configure an additional CA:
$ oc create configmap registry-config --from-file=<external_registry_address>=ca.crt -n openshift-config$ oc edit image.config.openshift.io clusterspec: additionalTrustedCA: name: registry-config
9.2.6. Configuring image registry repository mirroring Copiar enlaceEnlace copiado en el portapapeles!
Setting up container registry repository mirroring enables you to do the following:
- Configure your OpenShift Container Platform cluster to redirect requests to pull images from a repository on a source image registry and have it resolved by a repository on a mirrored image registry.
- Identify multiple mirrored repositories for each target repository, to make sure that if one mirror is down, another can be used.
The attributes of repository mirroring in OpenShift Container Platform include:
- Image pulls are resilient to registry downtimes.
- Clusters in disconnected environments can pull images from critical locations, such as quay.io, and have registries behind a company firewall provide the requested images.
- A particular order of registries is tried when an image pull request is made, with the permanent registry typically being the last one tried.
-
The mirror information you enter is added to the file on every node in the OpenShift Container Platform cluster.
/etc/containers/registries.conf - When a node makes a request for an image from the source repository, it tries each mirrored repository in turn until it finds the requested content. If all mirrors fail, the cluster tries the source repository. If successful, the image is pulled to the node.
Setting up repository mirroring can be done in the following ways:
At OpenShift Container Platform installation:
By pulling container images needed by OpenShift Container Platform and then bringing those images behind your company’s firewall, you can install OpenShift Container Platform into a datacenter that is in a disconnected environment.
After OpenShift Container Platform installation:
Even if you don’t configure mirroring during OpenShift Container Platform installation, you can do so later using the
object.ImageContentSourcePolicy
The following procedure provides a post-installation mirror configuration, where you create an
ImageContentSourcePolicy
- The source of the container image repository you want to mirror.
- A separate entry for each mirror repository you want to offer the content requested from the source repository.
You can only configure global pull secrets for clusters that have an
ImageContentSourcePolicy
Prerequisites
-
Access to the cluster as a user with the role.
cluster-admin
Procedure
Configure mirrored repositories, by either:
- Setting up a mirrored repository with Red Hat Quay, as described in Red Hat Quay Repository Mirroring. Using Red Hat Quay allows you to copy images from one repository to another and also automatically sync those repositories repeatedly over time.
Using a tool such as
to copy images manually from the source directory to the mirrored repository.skopeoFor example, after installing the skopeo RPM package on a Red Hat Enterprise Linux (RHEL) 7 or RHEL 8 system, use the
command as shown in this example:skopeo$ skopeo copy \ docker://registry.access.redhat.com/ubi8/ubi-minimal@sha256:5cfbaf45ca96806917830c183e9f37df2e913b187adb32e89fd83fa455ebaa6 \ docker://example.io/example/ubi-minimalIn this example, you have a container image registry that is named
with an image repository namedexample.ioto which you want to copy theexampleimage fromubi8/ubi-minimal. After you create the registry, you can configure your OpenShift Container Platform cluster to redirect requests made of the source repository to the mirrored repository.registry.access.redhat.com
- Log in to your OpenShift Container Platform cluster.
Create an
file (for example,ImageContentSourcePolicy), replacing the source and mirrors with your own registry and repository pairs and images:registryrepomirror.yamlapiVersion: operator.openshift.io/v1alpha1 kind: ImageContentSourcePolicy metadata: name: ubi8repo spec: repositoryDigestMirrors: - mirrors: - example.io/example/ubi-minimal1 source: registry.access.redhat.com/ubi8/ubi-minimal2 - mirrors: - example.com/example/ubi-minimal source: registry.access.redhat.com/ubi8/ubi-minimal - mirrors: - mirror.example.com/redhat source: registry.redhat.io/openshift43 - 1
- Indicates the name of the image registry and repository.
- 2
- Indicates the registry and repository containing the content that is mirrored.
- 3
- You can configure a namespace inside a registry to use any image in that namespace. If you use a registry domain as a source, the
ImageContentSourcePolicyresource is applied to all repositories from the registry.
Create the new
object:ImageContentSourcePolicy$ oc create -f registryrepomirror.yamlAfter the
object is created, the new settings are deployed to each node and the cluster starts using the mirrored repository for requests to the source repository.ImageContentSourcePolicyTo check that the mirrored configuration settings, are applied, do the following on one of the nodes.
List your nodes:
$ oc get nodeExample output
NAME STATUS ROLES AGE VERSION ip-10-0-137-44.ec2.internal Ready worker 7m v1.21.0 ip-10-0-138-148.ec2.internal Ready master 11m v1.21.0 ip-10-0-139-122.ec2.internal Ready master 11m v1.21.0 ip-10-0-147-35.ec2.internal Ready,SchedulingDisabled worker 7m v1.21.0 ip-10-0-153-12.ec2.internal Ready worker 7m v1.21.0 ip-10-0-154-10.ec2.internal Ready master 11m v1.21.0You can see that scheduling on each worker node is disabled as the change is being applied.
Start the debugging process to access the node:
$ oc debug node/ip-10-0-147-35.ec2.internalExample output
Starting pod/ip-10-0-147-35ec2internal-debug ... To use host binaries, run `chroot /host`Change your root directory to
:/hostsh-4.2# chroot /hostCheck the
file to make sure the changes were made:/etc/containers/registries.confsh-4.2# cat /etc/containers/registries.confExample output
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"] [[registry]] location = "registry.access.redhat.com/ubi8/" insecure = false blocked = false mirror-by-digest-only = true prefix = "" [[registry.mirror]] location = "example.io/example/ubi8-minimal" insecure = false [[registry.mirror]] location = "example.com/example/ubi8-minimal" insecure = falsePull an image digest to the node from the source and check if it is resolved by the mirror.
objects support image digests only, not image tags.ImageContentSourcePolicysh-4.2# podman pull --log-level=debug registry.access.redhat.com/ubi8/ubi-minimal@sha256:5cfbaf45ca96806917830c183e9f37df2e913b187adb32e89fd83fa455ebaa6
Troubleshooting repository mirroring
If the repository mirroring procedure does not work as described, use the following information about how repository mirroring works to help troubleshoot the problem.
- The first working mirror is used to supply the pulled image.
- The main registry is only used if no other mirror works.
-
From the system context, the flags are used as fallback.
Insecure -
The format of the file has changed recently. It is now version 2 and in TOML format.
/etc/containers/registries.conf