Option 2: Mirroring images to a private registry with a portable compute or a storage device (file system)

If your cluster is not connected to the internet, you can install Automation Decision Services in your cluster by using a file system. The portable storage and compute scenarios are enabled with a file system.

Before you begin

Verify that you completed the prerequisites, prepared a host, set the environment variables, and created registry namespaces if the registry does not allow automatic creation of top-level namespaces.

Procedure

  1. Generate the required mirror manifests.
    1. Define the environment variable $TARGET_REGISTRY by running the following command.
      export TARGET_REGISTRY=<target-registry>

      The <target-registry> refers to the registry (hostname and port) where the images are mirrored to and accessed by the OCP cluster. For example: 172.16.0.10:5000.

    2. Create the following environment variables with the installer image name and the version.
      export CASE_NAME=ibm-ads
      export CASE_VERSION=1.1.0
      Note: Releases with interim fixes are packaged in archives with a new minor version. The version numbers follow the release.major.minor standard. For example, the first interim fix for 25.0.0 is packaged in the CASE version 1.1.1.
    3. Run the following command to generate mirror manifests to be used when mirroring the image to the target registry. The $TARGET_REGISTRY refers to the registry where the images are mirrored to and accessed by the OCP cluster.
      oc ibm-pak generate mirror-manifests $CASE_NAME file://ads-images \
         --version $CASE_VERSION \
         --final-registry $TARGET_REGISTRY/ads

      Where file://ads-images indicates to the plug-in that the images are first mirrored to a local file system (to the ads-images directory) on the machine that runs the oc image mirror command. The final-registry $TARGET_REGISTRY/ads argument generates a mapping file that is used by the oc image mirror commands. The final URL in your target registry includes the new ads namespace in the mirrored namespace path. The namespace path can be multi-level if your target registry supports it.

      Note: After an upgrade, you can remove images from the previous version from the local registry by using an alternative namespace to copy the images to. For example, to a locationX namespace.

      The generate mirror-manifests command generates the following files in ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION:

      • images-mapping-to-filesystem.txt
      • images-mapping-from-filesystem.txt
      • image-content-source-policy.yaml
      • catalog-sourcesxxx.yaml
    Tip: If you are using a Red Hat® Quay.io registry and need to mirror the images to a specific organization in the registry, you can set the target to that organization. Specify the organization name in the generate mirror-manifests command:
    export ORGANIZATION=<your-organization> \
    oc ibm-pak generate mirror-manifests $CASE_NAME file://ads-images \   
       --version $CASE_VERSION \
       --final-registry $TARGET_REGISTRY/$ORGANIZATION
    If you do not know the value of the final registry where the images are to be mirrored, you can provide a placeholder value of TARGET_REGISTRY. For example:
    oc ibm-pak generate mirror-manifests $CASE_NAME file://ads-images \
       --version $CASE_VERSION \
       --final-registry TARGET_REGISTRY
    Note: TARGET_REGISTRY used without any environment variable expansion is just a plain string that must be replaced later with the actual image registry URL when it is known to you.
    Restriction: Currently, you cannot select the images to mirror by their target architecture because image registries do not support sparse manifests (manifests that reference image digests outside of the package).

    The ~/.ibm-pak directory structure is built over time as you save CASEs and mirror. The following tree shows an example of the ~/.ibm-pak directory structure:

    /root/.ibm-pak
    ├── config
    │   └── config.yaml
    ├── data
    │   ├── cases
    │   │   └── ibm-ads
    │   │       └── 1.1.0
    │   │           ├── component-set-config.yaml
    │   │           ├── ibm-ads-1.1.0.tgz
    │   │           ├── xxxxxx
    │   └── mirror
    │       └── ibm-ads
    │           └── 1.1.0
    │               ├── catalog-sources.yaml
    │               ├── image-content-source-policy.yaml
    │               ├── images-mapping-from-filesystem.txt
    │               └── images-mapping-to-filesystem.txt
    └── logs
        └── oc-ibm_pak.log

    A new directory ~/.ibm-pak/mirror is created when you issue the oc ibm-pak generate mirror-manifests command. The mirror directory stores the image-content-source-policy.yaml and images-mapping.txt files.

    You can use the following command to list all the images in your mirror manifest and the publicly accessible registries from where the images are pulled from.

    oc ibm-pak describe $CASE_NAME \
       --version $CASE_VERSION \
       --list-mirror-images
    Tip: Make a note of the registries section at the end of output, so you can check that you can log in to the registries. You need to be able to log in to these registries to pull and mirror the images to your target registry.
  2. Authenticate the registries.

    You must store authentication credentials for all the Automation Decision Services source Docker registries. The following registries require authentication:

    • cp.icr.io
    • registry.redhat.io
    • registry.access.redhat.com

    Run the following command to configure credentials for all target registries that require authentication. You must run the command separately for each registry.

    export REGISTRY_AUTH_FILE=<path to the file that has the auth credentials generated on podman login>
    podman login cp.icr.io
    podman login <TARGET_REGISTRY>
    
    Important: When you log in to cp.icr.io, you must specify the user as cp and the IBM® entitlement key as the password. For example:
    podman login cp.icr.io
    Username: cp
    Password: xxxxxxxxxxxxxxxxxxxxx
    Login Succeeded!
    

    The password can be copied from the IBM container library External link opens a new window or tab.

    If you export REGISTRY_AUTH_FILE=~/.ibm-pak/auth.json, and then run the podman login command, you can see that the file is populated with registry credentials.

    If you use docker login, the authentication file is typically located in $HOME/.docker/config.json on Linux® or %USERPROFILE%/.docker/config.json on Windows. After you run the docker login command, you can export REGISTRY_AUTH_FILE to point to that location. For example, on Linux you can run the following command:

    export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
  3. Mirror the images to the file system.
    1. Mirror images to the TARGET_REGISTRY.
      oc image mirror \
        -f ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION/images-mapping-to-filesystem.txt \
        -a $REGISTRY_AUTH_FILE \
        --filter-by-os '.*' \
        --insecure \
        --skip-multiple-scopes \
        --max-per-registry=1

      The command creates a v2 folder in the current directory where all the images are copied. For example, if file://ads-images is used as the input to generate the mirror-manifests, then the command creates a subdirectory ads-images under v2 and copies the images in this folder.

      The following command can be used to see all the available options.

      oc image mirror --help

      You can use the continue-on-error parameter to continue the mirroring even if an error occurs.

      Based on the number and size of the images to mirror, the oc image mirror command can take a considerable amount of time. If you are running the command on a remote machine, run the command in the background with the nohup POSIX command so that it does not stop if the user logs out. The following command starts the mirroring process in the background and writes the log to a my-mirror-progress.txt file.

      nohup oc image mirror -f ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION/images-mapping-to-filesystem.txt \
        --filter-by-os '.*' -a $REGISTRY_AUTH_FILE \
        --insecure \
        --skip-multiple-scopes \
        --max-per-registry=1 \
        --continue-on-error=true > my-mirror-progress.txt 2>&1 &

      You can view the progress of the mirror command by running the following command on the remote machine:

      tail -f my-mirror-progress.txt
    2. Move the following items to your file system:
      • The v2 directory.
      • The auth file referred to by the $REGISTSRY_AUTH_FILE variable.
      • The ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION/images-mapping-from-filesystem.txt file.
  4. Mirror the images to the target registry from your file system.

    The following steps to copy the images from the file system to the $TARGET_REGISTRY must be completed on your file system. Your file system must be connected to both the local Docker registry and the OpenShift® Container Platform cluster.

    Important: If you used the placeholder value of TARGET_REGISTRY for the --final-registry parameter when you generated the mirror manifests, replace the string in the images-mapping-from-filesystem.txt file with the registry where you want to mirror the images. For example, if you want to mirror the images to myregistry.com/mynamespace then replace TARGET_REGISTRY with myregistry.com/mynamespace.
    1. Mirror the images from the v2 directory to the target registry by running the following command:
      oc image mirror \
        -f ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION/images-mapping-from-filesystem.txt \
        -a $REGISTRY_AUTH_FILE \
        --from-dir=${v2_dir} \
        --filter-by-os '.*' \
        --insecure \
        --skip-multiple-scopes \
        --max-per-registry=1 

      The $v2_dir refers to the parent directory on the file system where you copied the v2 directory. The command does not produce any console logs for about 6 - 8 minutes as it prepares the list from the CASE package. If you want, you can add verbose (-v) to the command with possible values of 3, 9, 99, and so on.

    2. Update the global image pull secret for your OpenShift cluster to have authentication credentials in place to pull images from your $TARGET_REGISTRY as specified in the image-content-source-policy.yaml file. For more information, see Updating the global cluster pull secret External link opens a new window or tab.
    3. Create the ImageContentsourcePolicy.
      Note: Before you run the command in this step, you must be logged in to your OpenShift cluster. You do not need to be a cluster administrator to run the mirroring commands. Using the oc login command, log in to the Red Hat OpenShift Container Platform cluster where you plan to pull the mirrored images. You can identify your specific oc login by clicking the user drop-down menu in the Red Hat OpenShift Container Platform console, then clicking Copy Login Command.

      Run the following command to create ImageContentsourcePolicy.

      oc apply -f ~/.ibm-pak/data/mirror/$CASE_NAME/$CASE_VERSION/image-content-source-policy.yaml
    4. Verify that the ImageContentsourcePolicy resource is created.
      oc get imageContentSourcePolicy
    5. Verify your cluster node status.
      oc get MachineConfigPool -w

      After the ImageContentsourcePolicy and global image pull secret are applied, the configuration of your nodes is updated sequentially. Wait until all the MachineConfigPools are updated before you move on to the next step.

    6. Create a project for the CASE commands (ads is an example) by running the following commands:
      Note: Before you run the command in this step, you must be logged in to your OpenShift cluster.
      export NAMESPACE=ads
      oc new-project $NAMESPACE
    7. Optional: If you use an insecure registry, you must add the target registry to the cluster insecureRegistries list.
      oc patch image.config.openshift.io/cluster /
        --type=merge -p '{"spec":{"registrySources":{"insecureRegistries":["'${TARGET_REGISTRY}'"]}}}' 

What to do next

You can now go ahead and install License Service and the certificate manager. For more information, see Installing License Service and the certificate manager.