Configuring the OpenShift Container Platform internal registry
OpenShift® Container Platform provides an internal registry that might or might not already be configured for external usage.
To allow the installation script to properly push images to the internal registry, perform the following steps:
Creating a route to expose the registry
Note: You can ignore this step if an existing Route exposes the internal registry and contains registry in the name.
If you are using OpenShift Container Platform 4.2 or 4.3, follow the instructions on Exposing the registry in the OpenShift Container Platform documentation.
If you are using OpenShift Container Platform 3.11, complete the following steps:
- In the OpenShift Container Platform web console, click your avatar in the upper right corner and then click Copy Login Command.
- In the terminal of your local machine, paste the copied command that is similar to the following example. You will log in as a cluster administrator and start to use one of the existing projects on the cluster.
oc login https://<ocp-address>:<ocp-port> --token=<token> -
Determine the project that the internal registry is running on and set the
occlient to use that project.- On OCP 3.11 - typically the
defaultproject - On OCP 4.2 or 4.3 - typically the
openshift-image-registryproject
oc project <project-name> - On OCP 3.11 - typically the
-
Identify the
servicename that is exposing the registry internally.oc get svcExample output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE image-registry ClusterIP 172.30.70.120 <none> 5000/TCP 43dNote: On OpenShift Container Platform v3.11, you can see a
docker-registryand aregistry-consoleservice. You must expose thedocker-registryservice. -
Create a secured route for the
image-registryservice that usesreencryptTLS termination. With re-encryption, the router terminates the TLS connection with a certificate, and then re-encrypts the connection to the internal registry with a different certificate. With this approach, the full path of the connection between the user and the internal registry is encrypted. To provide your own custom domain name, include the--hostnameflag.oc create route reencrypt --service=image-registryNote: The installation script requires that this route has
registryin its name. If that term is not present, or there are multiple routes that use the termregistry, the installation script might fail to load the docker images. -
Retrieve the hostname and port (HOST/PORT) that were assigned to the
image-registryroute. This will be needed to configure your docker CLI for secure authentication to this internal docker registry.oc get route image-registryExample output:
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD image-registry image-registry-openshift-image-registry.<cluster_domain> image-registry 5000-tcp reencrypt NoneNote: In the example output above, record
image-registry-openshift-image-registry.<cluster_domain>for future use.
Configure the Docker CLI to trust the registry
-
Retrieve the root CA certificate from the created route. This can be done in multiple ways, for example, use the
opensslcommand. Replace the<route_hostname>with the registry hostname that is previously recorded. This command creates a PEM encodedregistry_ca.crtfile in your current directory.openssl s_client -showcerts -connect <route_hostname>:443 < /dev/null | awk '/BEGIN/ {c=1; print >"registry_ca.crt"; next} /END/ {print >"registry_ca.crt"; exit}; c{print >"registry_ca.crt"}'Example output:
depth=1 CN = ingress-operator@1575523653 verify error:num=19:self signed certificate in certificate chain verify return:0Note: If a verify error is displayed, as seen in the example output above, this might safely be ignored. It is caused by the docker image registry route using a self-signed certificate.
-
Add the CA certificate of your cluster to your local machine's trust store.
-
Linux®
mkdir -p /etc/docker/certs.d/<route_hostname> cp registry_ca.crt /etc/docker/certs.d/<route_hostname>/ca.crt service docker restart docker login -u $(oc whoami) -p $(oc whoami -t) <route_hostname> -
macOS
mkdir -p ~/.docker/certs.d/<route_hostname> cp registry_ca.crt ~/.docker/certs.d/<route_hostname>/ca.crt sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.docker/certs.d/<route_hostname>/ca.crtOn the client computer, restart the docker service by selecting the Restart option in the Docker Desktop application. Then, attempt to log in with the following command:
docker login -u $(oc whoami) -p $(oc whoami -t) <route_hostname> -
Windows
- Select Start > Administrative Tools > Manage Computer Certificates.
- Right-click Trusted Root Certification Authorities, and select All tasks > Import.
- Navigate to find and select your
registry_ca.crtfile. - Complete the wizard to configure the certificate. The defaults are often acceptable.
- Restart Docker for Windows to apply the changes.
-