Skip to content

Commit 9383c2d

Browse files
committed
Use mirror-registry tool
1 parent 296c006 commit 9383c2d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

ci-operator/step-registry/openstack/provision/mirror/openstack-provision-mirror-commands.sh

+19-19
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sg_id="$(openstack security group create -f value -c id mirror-${CLUSTER_NAME}-$
5151
--description "Mirror security group for $CLUSTER_NAME")"
5252
>&2 echo "Created mirror security group for ${CLUSTER_NAME}: ${sg_id}"
5353
openstack security group rule create --ingress --protocol tcp --dst-port 22 --description "${CLUSTER_NAME} SSH" "$sg_id" >/dev/null
54-
openstack security group rule create --ingress --protocol tcp --ethertype IPv6 --remote-ip "::/0" --dst-port 5000 --description "${CLUSTER_NAME} mirror registry" "$sg_id" >/dev/null
54+
openstack security group rule create --ingress --protocol tcp --ethertype IPv6 --remote-ip "::/0" --dst-port 8443 --description "${CLUSTER_NAME} mirror registry" "$sg_id" >/dev/null
5555
>&2 echo "Created necessary security group rules in ${sg_id}"
5656

5757
server_params="--network $CONTROL_PLANE_NETWORK --image $BASTION_IMAGE --flavor $BASTION_FLAVOR \
@@ -99,10 +99,13 @@ if ! retry 60 5 ssh_via_proxy "uname -a"; then
9999
openstack console log show ${server_id}
100100
exit 1
101101
fi
102+
MIRROR_REGISTRY_CREDENTIALS=$(<"/var/run/vault/mirror-registry/registry_creds")
103+
USER="foo"
104+
PASSWORD="foo"
105+
#USER="$(echo $MIRROR_REGISTRY_CREDENTIALS | cut -d':' -f1 )"
106+
#PASSWORD="$(echo $MIRROR_REGISTRY_CREDENTIALS | cut -d':' -f2 )"
102107

103108
MIRROR_REGISTRY_DNS_NAME="mirror-registry.${CLUSTER_NAME}.${BASE_DOMAIN}"
104-
MIRROR_REGISTRY_CREDENTIALS=$(<"/var/run/vault/mirror-registry/registry_creds")
105-
scp_via_proxy "/var/run/vault/mirror-registry/registry_creds_encrypted_htpasswd" $BASTION_USER@$mirror_ipv4:/tmp/htpasswd
106109

107110
echo "Deploying the mirror registry"
108111
>&2 cat << EOF > $WORK_DIR/deploy_mirror.sh
@@ -111,30 +114,27 @@ set -e
111114
sudo mkfs.xfs /dev/vdc
112115
sudo mkdir -p /opt/registry/{auth,certs,data}
113116
sudo mount /dev/vdc /opt/registry/data
114-
sudo openssl req -newkey rsa:4096 -nodes -sha256 -keyout /opt/registry/certs/domain.key -x509 -days 1 -subj "/CN=mirror-$CLUSTER_NAME-${CONFIG_TYPE}" -addext "subjectAltName=DNS:$MIRROR_REGISTRY_DNS_NAME,DNS:mirror-$CLUSTER_NAME-${CONFIG_TYPE}" -out /opt/registry/certs/domain.crt
115-
sudo cp /opt/registry/certs/domain.crt /etc/pki/ca-trust/source/anchors/domain.crt
116-
sudo mv /tmp/htpasswd /opt/registry/auth/htpasswd
117+
openssl req -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 1 -subj "/CN=mirror-$CLUSTER_NAME-${CONFIG_TYPE}" -addext "subjectAltName=DNS:$MIRROR_REGISTRY_DNS_NAME,DNS:mirror-$CLUSTER_NAME-${CONFIG_TYPE}" -out domain.crt
118+
sudo cp domain.crt /opt/registry/certs/domain.crt
119+
sudo cp domain.key /opt/registry/certs/domain.key
120+
sudo cp /opt/registry/certs/domain.crt /etc/pki/ca-trust/source/anchors/domain.crt
117121
sudo update-ca-trust
118122
sudo dnf install -y podman
119-
sudo podman create --name registry -p 5000:5000 --net host \
120-
-e "REGISTRY_AUTH=htpasswd" \
121-
-e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \
122-
-e "REGISTRY_AUTH_HTPASSWD_REALM='Registry Realm'" \
123-
-v /opt/registry/auth:/auth:Z \
124-
-v /opt/registry/certs:/certs:Z \
125-
-v /opt/registry/data:/var/lib/registry:z \
126-
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
127-
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
128-
quay.io/libpod/registry:2.8.2
129-
sudo podman start registry
130-
curl -u "$MIRROR_REGISTRY_CREDENTIALS" --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 40 https://mirror-$CLUSTER_NAME-${CONFIG_TYPE}:5000/v2/_catalog
123+
curl -L -o mirror-registry.tar.gz https://mirror.openshift.com/pub/cgw/mirror-registry/latest/mirror-registry-amd64.tar.gz --retry 12
124+
tar -xzvf mirror-registry.tar.gz
125+
echo "Running the mirror registry"
126+
./mirror-registry install --sslCert domain.crt --sslKey domain.key --quayHostname mirror-$CLUSTER_NAME-${CONFIG_TYPE} --initPassword ${PASSWORD} --initUser ${USER} -v
127+
echo "Finished the mirror registry"
128+
podman login -u ${USER} -p ${PASSWORD} https://mirror-$CLUSTER_NAME-${CONFIG_TYPE}:8443"
131129
EOF
132130

133131
scp_via_proxy $WORK_DIR/deploy_mirror.sh $BASTION_USER@$mirror_ipv4:/tmp
134132
ssh_via_proxy "chmod +x /tmp/deploy_mirror.sh"
135133
ssh_via_proxy "bash -c /tmp/deploy_mirror.sh"
136134

137-
echo "${MIRROR_REGISTRY_DNS_NAME}:5000" >"${SHARED_DIR}/mirror_registry_url"
135+
echo "Finished running mirror"
136+
137+
echo "${MIRROR_REGISTRY_DNS_NAME}:8443" >"${SHARED_DIR}/mirror_registry_url"
138138
scp_via_proxy $BASTION_USER@$mirror_ipv4:/opt/registry/certs/domain.crt ${SHARED_DIR}/additional_trust_bundle
139139
echo $mirror_ipv4 > "${SHARED_DIR}/MIRROR_SSH_IP"
140140
echo $mirror_ipv6 > "${SHARED_DIR}/MIRROR_REGISTRY_IP"

0 commit comments

Comments
 (0)