|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * installing/installing_restricted_networks/installing-restricted-networks-preparations.adoc |
| 4 | + |
| 5 | +ifeval::["{context}" == "installing-restricted-networks-preparations"] |
| 6 | +:restricted: |
| 7 | +endif::[] |
| 8 | + |
| 9 | +[id="installation-creating-mirror-registry_{context}"] |
| 10 | += Creating a mirror registry |
| 11 | + |
| 12 | +Create a registry to host the mirrored content that you require for installing |
| 13 | +{product-title}. |
| 14 | +ifdef::restricted[] |
| 15 | +For installation in a restricted network, you must place the mirror on your |
| 16 | +bastion host. |
| 17 | +endif::restricted[] |
| 18 | + |
| 19 | +[NOTE] |
| 20 | +==== |
| 21 | +The following procedure creates a simple registry that stores data in the |
| 22 | +`/opt/registry` folder and runs in a `podman` container. You can use a different |
| 23 | +registry solution, such as |
| 24 | +link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html-single/manage_red_hat_quay/index#repo-mirroring-in-red-hat-quay[Red Hat Quay]. |
| 25 | +Review the following procedure to ensure that your registry functions |
| 26 | +correctly. |
| 27 | +==== |
| 28 | + |
| 29 | +.Prerequisites |
| 30 | + |
| 31 | +* You have a Red Hat Enterprise Linux (RHEL) server on your network to use |
| 32 | +as the registry host. |
| 33 | +* The registry host can access the internet. |
| 34 | + |
| 35 | +.Procedure |
| 36 | + |
| 37 | +ifdef::restricted[] |
| 38 | +On the bastion host, take the following actions: |
| 39 | +endif::restricted[] |
| 40 | + |
| 41 | +. Install the required packages: |
| 42 | ++ |
| 43 | +---- |
| 44 | +# yum -y install podman httpd httpd-tools jq |
| 45 | +---- |
| 46 | ++ |
| 47 | +The `podman` package provides the container package that you run the registry |
| 48 | +in. The `httpd` and `httpd-tools` packages provide the `htpasswd` utility, which |
| 49 | +you use to create users. The `jq` package improves the display of JSON output |
| 50 | +on your command line. |
| 51 | + |
| 52 | +. Create folders for the registry: |
| 53 | ++ |
| 54 | +---- |
| 55 | +# mkdir -p /opt/registry/{auth,certs,data} |
| 56 | +---- |
| 57 | ++ |
| 58 | +These folders are mounted inside the registry container. |
| 59 | + |
| 60 | +. Provide a certificate for the registry. If you do not have an existing, trusted |
| 61 | +certificate authority, you can generate a self-signed certificate: |
| 62 | ++ |
| 63 | +---- |
| 64 | +$ cd /opt/registry/certs |
| 65 | +# openssl req -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 365 -out domain.crt |
| 66 | +---- |
| 67 | ++ |
| 68 | +At the prompts, provide the required values for the certificate: |
| 69 | +[horizontal] |
| 70 | +Country Name (2 letter code):: Specify the two-letter ISO country code for your location. |
| 71 | +See the link:https://www.iso.org/iso-3166-country-codes.html[ISO 3166 country codes] |
| 72 | +standard. |
| 73 | +State or Province Name (full name):: Enter the full name of your state or province. |
| 74 | +Locality Name (eg, city):: Enter the name of your city. |
| 75 | +Organization Name (eg, company):: Enter your company name. |
| 76 | +Organizational Unit Name (eg, section):: Enter your department name. |
| 77 | +Common Name (eg, your name or your server's hostname):: Enter the host name for |
| 78 | +the registry host. Ensure that your hostname is in DNS and that it resolves to |
| 79 | +the expected IP address. |
| 80 | +Email Address:: Enter your email address. |
| 81 | +For more information, see the |
| 82 | +link:https://www.openssl.org/docs/man1.1.1/man1/req.html[req] description in the |
| 83 | +OpenSSL documentation. |
| 84 | + |
| 85 | +. Generate a user name and a password for your registry that uses the `bcrpt` format: |
| 86 | ++ |
| 87 | +---- |
| 88 | +# htpasswd -bBc /opt/registry/auth/htpasswd <user_name> <password> <1> |
| 89 | +---- |
| 90 | +<1> Replace `<user_name>` and `<password>` with a user name and a password. |
| 91 | + |
| 92 | +. Create the `mirror-registry` container to host your registry: |
| 93 | ++ |
| 94 | +---- |
| 95 | +# podman run --name mirror-registry -p 5000:<local_registry_host_port> \ <1> |
| 96 | + -v /opt/registry/data:/var/lib/registry:z \ |
| 97 | + -v /opt/registry/auth:/auth:z \ |
| 98 | + -e "REGISTRY_AUTH=htpasswd" \ |
| 99 | + -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ |
| 100 | + -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ |
| 101 | + -v /opt/registry/certs:/certs:z \ |
| 102 | + -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ |
| 103 | + -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ |
| 104 | + docker.io/library/registry:2 |
| 105 | +---- |
| 106 | +<1> For `<local_registry_host_port>`, specify the port that your mirror registry |
| 107 | +uses to serve content. |
| 108 | + |
| 109 | +. Open the required ports for your registry: |
| 110 | ++ |
| 111 | +---- |
| 112 | +# firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=internal --permanent <1> |
| 113 | +# firewall-cmd --add-port=<local_registry_host_port>/tcp --zone=public --permanent <1> |
| 114 | +# firewall-cmd --reload |
| 115 | +---- |
| 116 | +<1> For `<local_registry_host_port>`, specify the port that your mirror registry |
| 117 | +uses to serve content. |
| 118 | + |
| 119 | +. Add the self-signed certificate to your list of trusted certificates: |
| 120 | ++ |
| 121 | +---- |
| 122 | +# cp /opt/registry/certs/domain.crt /etc/pki/ca-trust/source/anchors/ |
| 123 | +# update-ca-trust |
| 124 | +---- |
| 125 | ++ |
| 126 | +You must trust your certificate to log in to your registry during the mirror process. |
| 127 | + |
| 128 | +. Confirm that the registry is available: |
| 129 | ++ |
| 130 | +---- |
| 131 | +$ curl -u <user_name>:<password> -k https://<local_registry_host_name>:<local_registry_host_port>/v2/_catalog <1> |
| 132 | +
|
| 133 | +{"repositories":[]} |
| 134 | +---- |
| 135 | +<1> For `<user_name>` and `<password>`, specify the user name and password |
| 136 | +for your registry. For `<local_registry_host_name>`, specify the registry domain name |
| 137 | +that you specified in your certificate, such as `registry.example.com`. For |
| 138 | +`<local_registry_host_port>`, specify the port that your mirror registry uses to |
| 139 | +serve content. |
| 140 | ++ |
| 141 | +If the command output displays an empty repository, your registry is available. |
| 142 | + |
| 143 | +//// |
| 144 | +. To stop the registry:: |
| 145 | ++ |
| 146 | +---- |
| 147 | +# podman stop mirror-registry |
| 148 | +---- |
| 149 | +//// |
0 commit comments