Skip to content

Latest commit

 

History

History
182 lines (156 loc) · 6.76 KB

images-configuration-registry-mirror.adoc

File metadata and controls

182 lines (156 loc) · 6.76 KB

Configuring image registry repository mirroring

  • Configure your {product-title} 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.

Here are some of the attributes of repository mirroring in {product-title}:

  • Image pulls are resilient to registry downtimes

  • Clusters in restricted networks can request to 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 /etc/containers/registries.conf file on every node in the {product-title} cluster.

  • 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. Upon success, the image is pulled to the node.

Setting up repository mirroring can be done in the following ways:

  • At {product-title} installation time: By pulling container images needed by {product-title} and then bringing those images behind your company’s firewall, you can install {product-title} into a datacenter that is in a restricted network. See Mirroring the {product-title} image repository for details.

  • After {product-title} installation time: Even if you don’t configure mirroring during {product-title} installation, you can do so later using the ImageContentSourcePolicy object.

The following procedure provides a post-installation mirror configuration, where you create an ImageContentSourcePolicy object that identifies:

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

Prerequisites
  • Access to the cluster as a user with the cluster-admin role.

Procedure
  1. Configure mirrored repositories. To do that, you can either:

    • Set 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.

    • Use a tool such as skopeo to copy images manually from the source directory to the mirrored repository.

      For example, after installing the skopeo RPM package on a Red Hat Enterprise Linux (RHEL 7 or RHEL 8) system, use the skopeo command as shown in this example:

      $ skopeo copy \
         docker://registry.access.redhat.com/ubi8/ubi-minimal@sha256:c505667389712dc337986e29ffcb65116879ef27629dc3ce6e1b17727c06e78f \
         docker://example.io/ubi8/ubi-minimal

      In this example, you have a container image registry that is named example.io with an image repository named example to which you want to copy the ubi8/ubi-minimal image from registry.access.redhat.com. After you create the registry, you can configure your {product-title} cluster to redirect requests made of the source repository to the mirrored repository.

  2. Log in to your {product-title} cluster.

  3. Create an ImageContentSourcePolicy file (for example, registryrepomirror.yaml), replacing the source and mirrors with those of your own registry and repository pairs and images:

    apiVersion: operator.openshift.io/v1alpha1
    kind: ImageContentSourcePolicy
    metadata:
      name: ubi8repo
    spec:
      repositoryDigestMirrors:
      - mirrors:
        - example.io/example/ubi-minimal(1)
        source: registry.access.redhat.com/ubi8/ubi-minimal(2)
      - mirrors:
        - example.com/example/ubi-minimal
        source: registry.access.redhat.com/ubi8/ubi-minimal
    ~
    1. Indicates the name of the image registry and repository

    2. Indicates the registry and repository containing the content that is mirrored

  4. Create the new ImageContentSourcePolicy:

    $ oc create -f registryrepomirror.yaml

    After the ImageContentSourcePolicy is created, the new settings are deployed to each node and shortly start using the mirrored repository for requests to the source repository.

  5. To check that the mirrored configuration worked, go to one of your nodes. For example:

    1. List your nodes:

      $ oc get node
      NAME                           STATUS                     ROLES    AGE  VERSION
      ip-10-0-137-44.ec2.internal    Ready                      worker   7m   v1.17.1
      ip-10-0-138-148.ec2.internal   Ready                      master   11m  v1.17.1
      ip-10-0-139-122.ec2.internal   Ready                      master   11m  v1.17.1
      ip-10-0-147-35.ec2.internal    Ready,SchedulingDisabled   worker   7m   v1.17.1
      ip-10-0-153-12.ec2.internal    Ready                      worker   7m   v1.17.1
      ip-10-0-154-10.ec2.internal    Ready                      master   11m  v1.17.1

      You can see that scheduling on each worker node is disabled as the change is being applied.

    2. Check the /etc/containers/registries.conf file to make sure the changes were made:

      $ oc debug node/ip-10-0-147-35.ec2.internal
      Starting pod/ip-10-0-147-35ec2internal-debug ...
      To use host binaries, run `chroot /host`
      
      sh-4.3# chroot /host
      sh-4.3# cat /etc/containers/registries
      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 = false
    3. Pull an image to the node from the source and check if it is actually resolved by the mirror.

      sh-4.3# podman pull --log-level=debug registry.access.redhat.com/ubi8/ubi-minimal
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 will only be used if no other mirror works.

  • From the system context, the Insecure flags are used as fallback.

  • The format of the /etc/containers/registries file has changed recently. It is now version 2 and in TOML format. *