Skip to content

Commit

Permalink
Make hypershift-kubevirt-baremetalds-redhat-operators generic in disc…
Browse files Browse the repository at this point in the history
…onnected

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
  • Loading branch information
tiraboschi committed Apr 16, 2024
1 parent 64d0e8a commit 3db995e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ set -o errexit
set -o pipefail
set -x

function mirror_odf() {
echo "### Mirroring ODF images"
function mirror_ccs() {
echo "### Mirroring the selected operators to the internal registry"
source "${SHARED_DIR}/packet-conf.sh"

echo "registry.redhat.io/redhat/redhat-operator-index:${REDHAT_OPERATORS_INDEX_TAG}" > /tmp/odf-catalog-image
scp "${SSHOPTS[@]}" "/tmp/odf-catalog-image" "root@${IP}:/home/odf-catalog-image"
echo "${REDHAT_OPERATORS_INDEX_TAG}" > /tmp/odf-version
scp "${SSHOPTS[@]}" "/tmp/odf-version" "root@${IP}:/home/odf-version"
echo "${ODF_OPERATOR_SUB_PACKAGE}" > /tmp/odf-package
scp "${SSHOPTS[@]}" "/tmp/odf-package" "root@${IP}:/home/odf-package"
echo "${ODF_OPERATOR_SUB_CHANNEL}" > /tmp/odf-channel
scp "${SSHOPTS[@]}" "/tmp/odf-channel" "root@${IP}:/home/odf-channel"
echo "registry.redhat.io/redhat/redhat-operator-index:${REDHAT_OPERATORS_INDEX_TAG}" > /tmp/ccs-catalog-image
scp "${SSHOPTS[@]}" "/tmp/ccs-catalog-image" "root@${IP}:/home/ccs-catalog-image"
echo "${REDHAT_OPERATORS_INDEX_TAG}" > /tmp/ccs-version
scp "${SSHOPTS[@]}" "/tmp/ccs-version" "root@${IP}:/home/ccs-version"
echo "${CCS_OPERATOR_PACKAGES}" > /tmp/ccs-packages
scp "${SSHOPTS[@]}" "/tmp/ccs-packages" "root@${IP}:/home/ccs-packages"
echo "${CCS_OPERATOR_CHANNELS}" > /tmp/ccs-channels
scp "${SSHOPTS[@]}" "/tmp/ccs-channels" "root@${IP}:/home/ccs-channels"

# shellcheck disable=SC2087
ssh "${SSHOPTS[@]}" "root@${IP}" bash - << EOF
set -xeo pipefail
ODF_CATALOG_IMAGE=\$(cat /home/odf-catalog-image)
ODF_VERSION=\$(cat /home/odf-version)
ODF_OPERATOR_SUB_PACKAGE=\$(cat /home/odf-package)
ODF_OPERATOR_SUB_CHANNEL=\$(cat /home/odf-channel)
CCS_CATALOG_IMAGE=\$(cat /home/ccs-catalog-image)
CCS_VERSION=\$(cat /home/ccs-version)
CCS_OPERATOR_PACKAGES=\$(cat /home/ccs-packages)
CCS_OPERATOR_CHANNELS=\$(cat /home/ccs-channels)
echo "1. Get mirror registry"
mirror_registry=\$(oc get imagecontentsourcepolicy -o json | jq -r '.items[].spec.repositoryDigestMirrors[0].mirrors[0]')
Expand All @@ -50,11 +50,11 @@ function mirror_odf() {
fi
/home/oc-mirror version
echo "3: skopeo copy docker://\${ODF_CATALOG_IMAGE} oci:///home/odf-local-catalog --remove-signatures"
skopeo copy "docker://\${ODF_CATALOG_IMAGE}" "oci:///home/odf-local-catalog" --remove-signatures
echo "3: skopeo copy docker://\${CCS_CATALOG_IMAGE} oci:///home/ccs-local-catalog --remove-signatures"
skopeo copy "docker://\${CCS_CATALOG_IMAGE}" "oci:///home/ccs-local-catalog" --remove-signatures
echo "4: oc-mirror"
catalog_image="odf-local-catalog/odf-local-catalog"
catalog_image="ccs-local-catalog/ccs-local-catalog"
cat <<END |tee "/home/registry.conf"
[[registry]]
Expand All @@ -75,34 +75,42 @@ function mirror_odf() {
insecure = true
END
cat <<END |tee "/home/imageset-config.yaml"
rm -rf /home/imageset-config.yaml
IFS=',' read -r -a p_array <<< "\$CCS_OPERATOR_PACKAGES"
IFS=',' read -r -a c_array <<< "\$CCS_OPERATOR_CHANNELS"
if [[ "\${#p_array[@]}" != "\${#c_array[@]}" ]];
then
echo "CCS_OPERATOR_PACKAGES and CCS_OPERATOR_CHANNELS don't contain the same number of items"
exit 1
fi
cat <<END >> "/home/imageset-config.yaml"
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
local:
path: mirror
mirror:
operators:
- catalog: "oci:///home/odf-local-catalog"
- catalog: "oci:///home/ccs-local-catalog"
targetCatalog: \${catalog_image}
targetTag: "\${ODF_VERSION}"
targetTag: "\${CCS_VERSION}"
packages:
- name: \${ODF_OPERATOR_SUB_PACKAGE}
channels:
- name: \${ODF_OPERATOR_SUB_CHANNEL}
- name: odf-operator
channels:
- name: \${ODF_OPERATOR_SUB_CHANNEL}
- name: ocs-operator
channels:
- name: \${ODF_OPERATOR_SUB_CHANNEL}
- name: mcg-operator
channels:
- name: \${ODF_OPERATOR_SUB_CHANNEL}
- name: odf-csi-addons-operator
END
for index in "\${!p_array[@]}"
do
cat <<END >> "/home/imageset-config.yaml"
- name: \${p_array[index]}
channels:
- name: \${ODF_OPERATOR_SUB_CHANNEL}
- name: \${c_array[index]}
END
done
cat /home/imageset-config.yaml
pushd /home
# try at least 3 times to be sure to get all the images...
Expand All @@ -125,7 +133,7 @@ EOF

if [[ "${DISCONNECTED}" == "true" ]];
then
mirror_odf
mirror_ccs
else
name="redhat-operators-$(echo $REDHAT_OPERATORS_INDEX_TAG| sed "s/[.]/-/g")"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ ref:
default: v4.14
- name: DISCONNECTED
default: "false"
- name: ODF_OPERATOR_SUB_PACKAGE
documentation: The package name of the ODF Operator to install.
default: odf-operator
- name: ODF_OPERATOR_SUB_CHANNEL
documentation: The channel from which to install the package.
default: stable-4.14
- name: CCS_OPERATOR_PACKAGES
documentation: comma separated package names of the operators to be mirrored and used with the custom catalog source, relevant only if DISCONNECTED=="true"
default: ""
- name: CCS_OPERATOR_CHANNELS
documentation: comma separated OLM channels for the operators to be mirrored and used with the custom catalog source in the same order of CCS_OPERATOR_PACKAGES, relevant only if DISCONNECTED=="true"
default: ""
documentation: |-
This step to deploy a specific redhat-operators catalog source
This step to deploy a specific redhat-operators catalog source, in disconnected mode a selected OLM channel for a selected operator can also be mirrored to the internal registry
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ workflow:
PersistentVolumes NFS when invoking the Recycle reclaim policy should test that a PV becomes Available and is clean after the PVC is deleted.
METALLB_OPERATOR_SUB_SOURCE: mirror-catalog-for-olm
LOCAL_STORAGE_OPERATOR_SUB_SOURCE: mirror-catalog-for-olm
ODF_OPERATOR_SUB_SOURCE: cs-odf-local-catalog
ODF_OPERATOR_SUB_SOURCE: cs-ccs-local-catalog
LVM_OPERATOR_SUB_CHANNEL: stable-4.14
LVM_OPERATOR_SUB_SOURCE: mirror-catalog-for-olm
LVM_OPERATOR_SUB_INSTALL_NAMESPACE: openshift-lvm-storage
CCS_OPERATOR_PACKAGES: odf-operator,ocs-operator,mcg-operator,odf-csi-addons-operator
CCS_OPERATOR_CHANNELS: stable-4.14,stable-4.14,stable-4.14,stable-4.14
ETCD_STORAGE_CLASS: lvms-vg1
DISCONNECTED: "true"
ENABLE_ICSP: "true"
Expand Down

0 comments on commit 3db995e

Please sign in to comment.