$ tar xvzf <file>
Before you install a cluster on infrastructure that you provision in a restricted network, you must mirror the required container images into that environment. Installations on a restricted network are supported on only infrastructure that you provision, not infrastructure that the installer provisions.
You must have access to the internet to obtain the necessary container images. In this procedure, you place the mirror registry on a mirror host that has access to both your network and the internet. If you do not have access to a mirror host, use the method that best fits your restrictions to bring the contents of the mirror registry into your restricted network. |
You can mirror the contents of the OpenShift Container Platform registry and the images that are required to generate the installation program.
The mirror registry is a key component that is required to complete an installation in a restricted network. You can create this mirror on a bastion host, which can access both the internet and your closed network, or by using other methods that meet your restrictions.
Because of the way that OpenShift Container Platform verifies integrity for the release payload, the image references in your local registry are identical to the ones that are hosted by Red Hat on Quay.io. During the bootstrapping process of installation, the images must have the same digests no matter which repository they are pulled from. To ensure that the release payload is identical, you mirror the images to your local repository.
Before you create the mirror registry, you must prepare the mirror host.
You can install the OpenShift CLI (oc
) in order to interact with OpenShift Container Platform from a
command-line interface. You can install oc
on Linux, Windows, or macOS.
If you installed an earlier version of |
You can install the OpenShift CLI (oc
) binary on Linux by using the following procedure.
Navigate to the Infrastructure Provider page on the Red Hat OpenShift Cluster Manager site.
Select your infrastructure provider, and, if applicable, your installation type.
In the Command-line interface section, select Linux from the drop-down menu and click Download command-line tools.
Unpack the archive:
$ tar xvzf <file>
Place the oc
binary in a directory that is on your PATH
.
To check your PATH
, execute the following command:
$ echo $PATH
After you install the CLI, it is available using the oc
command:
$ oc <command>
You can install the OpenShift CLI (oc
) binary on Windows by using the following procedure.
Navigate to the Infrastructure Provider page on the Red Hat OpenShift Cluster Manager site.
Select your infrastructure provider, and, if applicable, your installation type.
In the Command-line interface section, select Windows from the drop-down menu and click Download command-line tools.
Unzip the archive with a ZIP program.
Move the oc
binary to a directory that is on your PATH
.
To check your PATH
, open the command prompt and execute the following command:
C:\> path
After you install the CLI, it is available using the oc
command:
C:\> oc <command>
You can install the OpenShift CLI (oc
) binary on macOS by using the following procedure.
Navigate to the Infrastructure Provider page on the Red Hat OpenShift Cluster Manager site.
Select your infrastructure provider, and, if applicable, your installation type.
In the Command-line interface section, select MacOS from the drop-down menu and click Download command-line tools.
Unpack and unzip the archive.
Move the oc
binary to a directory on your PATH.
To check your PATH
, open a terminal and execute the following command:
$ echo $PATH
After you install the CLI, it is available using the oc
command:
$ oc <command>
Create a registry to host the mirrored content that you require for installing OpenShift Container Platform.
For installation in a restricted network, you can place the mirror registry on a host that can be accessed from both the your network and the internet. If you do not have access to such a host, use the method that best fits your restrictions to bring the contents of the mirror registry into your restricted network.
The following procedure creates a simple registry that stores data in the
|
You have a Red Hat Enterprise Linux (RHEL) server on your network to use as the registry host.
The registry host can access the internet.
On the mirror host, take the following actions:
Install the required packages:
# yum -y install podman httpd-tools
The podman
package provides the container package that you run the registry
in. The httpd-tools
package provides the htpasswd
utility, which
you use to create users.
Create folders for the registry:
# mkdir -p /opt/registry/{auth,certs,data}
These folders are mounted inside the registry container.
Provide a certificate for the registry. If you do not have an existing, trusted certificate authority, you can generate a self-signed certificate:
$ cd /opt/registry/certs # openssl req -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 365 -out domain.crt
At the prompts, provide the required values for the certificate:
Country Name (2 letter code) |
Specify the two-letter ISO country code for your location. See the ISO 3166 country codes standard. |
State or Province Name (full name) |
Enter the full name of your state or province. |
Locality Name (eg, city) |
Enter the name of your city. |
Organization Name (eg, company) |
Enter your company name. |
Organizational Unit Name (eg, section) |
Enter your department name. |
Common Name (eg, your name or your server’s hostname) |
Enter the host name for the registry host. Ensure that your hostname is in DNS and that it resolves to the expected IP address. |
Email Address |
Enter your email address. For more information, see the req description in the OpenSSL documentation. |
Generate a user name and a password for your registry that uses the bcrpt
format:
# htpasswd -bBc /opt/registry/auth/htpasswd <user_name> <password> (1)
1 | Replace <user_name> and <password> with a user name and a password. |
Create the mirror-registry
container to host your registry:
# podman run --name mirror-registry -p <local_registry_host_port>:5000 \ (1) -v /opt/registry/data:/var/lib/registry:z \ -v /opt/registry/auth:/auth:z \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ -v /opt/registry/certs:/certs:z \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ -e REGISTRY_COMPATIBILITY_SCHEMA1_ENABLED=true \ -d docker.io/library/registry:2
1 | For <local_registry_host_port> , specify the port that your mirror registry
uses to serve content. |
Open the required ports for your registry:
# firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=internal --permanent (1) # firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=public --permanent (1) # firewall-cmd --reload
1 | For <local_registry_host_port> , specify the port that your mirror registry
uses to serve content. |
Add the self-signed certificate to your list of trusted certificates:
# cp /opt/registry/certs/domain.crt /etc/pki/ca-trust/source/anchors/ # update-ca-trust
You must trust your certificate to log in to your registry during the mirror process.
Confirm that the registry is available:
$ curl -u <user_name>:<password> -k https://<local_registry_host_name>:<local_registry_host_port>/v2/_catalog (1) {"repositories":[]}
1 | For <user_name> and <password> , specify the user name and password
for your registry. For <local_registry_host_name> , specify the registry domain name
that you specified in your certificate, such as registry.example.com . For
<local_registry_host_port> , specify the port that your mirror registry uses to
serve content. |
If the command output displays an empty repository, your registry is available.
Modify your the pull secret for your OpenShift Container Platform cluster to describe your local registry before you install an OpenShift Container Platform cluster in a restricted network.
You configured a mirror registry to use in your restricted network.
Complete the following steps on the mirror host:
Download your registry.redhat.io
pull secret from the
Pull secret page on the Red Hat OpenShift Cluster Manager site.
Generate the base64-encoded user name and password or token for your mirror registry:
$ echo -n '<user_name>:<password>' | base64 -w0 (1) BGVtbYk3ZHAtqXs=
1 | For <user_name> and <password> , specify the user name and password that
you configured for your registry. |
Make a copy of your pull secret in JSON format:
$ cat ./pull-secret.text | jq . > <path>/<pull-secret-file>(1)
1 | Specify the path to the folder to store the pull secret in and a name for the JSON file that you create. |
The contents of the file resemble the following example:
{ "auths": { "cloud.openshift.com": { "auth": "b3BlbnNo...", "email": "you@example.com" }, "quay.io": { "auth": "b3BlbnNo...", "email": "you@example.com" }, "registry.connect.redhat.com": { "auth": "NTE3Njg5Nj...", "email": "you@example.com" }, "registry.redhat.io": { "auth": "NTE3Njg5Nj...", "email": "you@example.com" } } }
Edit the new file and add a section that describes your registry to it:
"auths": { ... "<mirror_registry>": { (1) "auth": "<credentials>", (2) "email": "you@example.com" }, ...
1 | For <mirror_registry> , specify the registry domain name, and optionally the
port, that your mirror registry uses to serve content. For example,
registry.example.com or registry.example.com:5000 |
2 | For <credentials> , specify the base64-encoded user name and password for
the mirror registry. |
The file resembles the following example:
{ "auths": { "cloud.openshift.com": { "auth": "b3BlbnNo...", "email": "you@example.com" }, "quay.io": { "auth": "b3BlbnNo...", "email": "you@example.com" }, "registry.connect.redhat.com": { "auth": "NTE3Njg5Nj...", "email": "you@example.com" }, "<mirror_registry>": { "auth": "<credentials>", "email": "you@example.com" }, "registry.redhat.io": { "auth": "NTE3Njg5Nj...", "email": "you@example.com" } } }
Mirror the OpenShift Container Platform image repository to use during cluster installation or upgrade.
You configured a mirror registry to use in your restricted network and can access the certificate and credentials that you configured.
You downloaded the pull secret from the Pull secret page on the Red Hat OpenShift Cluster Manager site and modified it to include authentication to your mirror repository.
Complete the following steps on a host that can access both quay.io and your mirror registry:
Review the OpenShift Container Platform downloads page to determine the version of OpenShift Container Platform that you want to install.
Set the required environment variables:
$ export OCP_RELEASE=<release_version> (1) $ export LOCAL_REGISTRY='<local_registry_host_name>:<local_registry_host_port>' (2) $ export LOCAL_REPOSITORY='<repository_name>' (3) $ export PRODUCT_REPO='openshift-release-dev' (4) $ export LOCAL_secret_JSON='<path_to_pull_secret>' (5) $ export RELEASE_NAME="ocp-release" (6)
1 | For <release_version> , specify the version number of OpenShift Container Platform to
install, such as 4.2.0 . |
2 | For <local_registry_host_name> , specify the registry domain name for your mirror
repository, and for <local_registry_host_port> , specify the port that it
serves content on. |
3 | For <repository_name> , specify the name of the repository to create in your
registry, such as ocp4/openshift4 . |
4 | The repository to mirror. For a production release, you must specify
openshift-release-dev . |
5 | For <path_to_pull_secret> , specify the absolute path to and file name of
the pull secret for your mirror registry that you created. |
6 | The release mirror. For a production release, you must specify
ocp-release . |
Mirror the repository:
$ oc adm -a ${LOCAL_secret_JSON} release mirror \ --from=quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE} \ --to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} \ --to-release-image=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}
This command pulls the release information as a digest, and its output includes
the imageContentSources
data that you require when you install your cluster.
Record the entire imageContentSources
section from the output of the previous
command. The information about your mirrors is unique to your mirrored repository, and you must add the imageContentSources
section to the install-config.yaml
file during installation.
To create the installation program that is based on the content that you mirrored, extract it and pin it to the release:
$ oc adm -a ${LOCAL_secret_JSON} release extract --command=openshift-install "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}"
To ensure that you use the correct images for the version of OpenShift Container Platform that you selected, you must extract the installation program from the mirrored content. You must perform this step on a machine with an active internet connection. |
Most imagestreams in the OpenShift namespace managed by the Samples Operator point to images located in the Red Hat registry at registry.redhat.io. Mirroring will not apply to these imagestreams.
The Setting the The Samples Operator prevents the use of the following registries for the Jenkins imagestreams: |
The |
Access to the cluster as a user with the cluster-admin
role.
Create a pull secret for your mirror registry.
Access the images of a specific imagestream to mirror, for example:
$ oc get is <imagestream> -n openshift -o json | jq .spec.tags[].from.name | grep registry.redhat.io
Mirror images from registry.redhat.io associated with any imagestreams you need in the restricted network environment into one of the defined mirrors, for example:
$ oc image mirror registry.redhat.io/rhscl/ruby-25-rhel7:latest ${MIRROR_ADDR}/rhscl/ruby-25-rhel7:latest
Add the required trusted CAs for the mirror in the cluster’s image configuration object:
$ oc create configmap registry-config --from-file=${MIRROR_ADDR_HOSTNAME}..5000=$path/ca.crt -n openshift-config $ oc patch image.config.openshift.io/cluster --patch '{"spec":{"additionalTrustedCA":{"name":"registry-config"}}}' --type=merge
Update the samplesRegistry
field in the Samples Operator configuration object
to contain the hostname
portion of the mirror location defined in the mirror
configuration:
$ oc get configs.samples.operator.openshift.io -n openshift-cluster-samples-operator
This is required because the imagestream import process does not use the mirror or search mechanism at this time. |
Add any imagestreams that are not mirrored into the skippedImagestreams
field
of the Samples Operator configuration object. Or if you do not want to support
any of the sample imagestreams, set the Samples Operator to Removed
in the
Samples Operator configuration object.
Any unmirrored imagestreams that are not skipped, or if the Samples Operator is
not changed to |
Many of the templates in the OpenShift namespace
reference the imagestreams. So using Removed
to purge both the imagestreams
and templates will eliminate the possibility of attempts to use them if they
are not functional because of any missing imagestreams.
Install a cluster on infrastructure that you provision in your restricted nework, such as on VMware vSphere, bare metal, or Amazon Web Services.