From ef9ca69250ca41210768450966f9c354cc69bf69 Mon Sep 17 00:00:00 2001 From: Oleg Matskiv Date: Tue, 26 Mar 2019 15:56:07 +0200 Subject: [PATCH] Add parameter for namespace prefix --- image/tools/lib/component/3scale-redis.sh | 4 ++-- image/tools/lib/component/codeready_pv.sh | 4 ++-- image/tools/lib/component/enmasse_pv.sh | 4 ++-- templates/openshift/backup-cronjob-template.yaml | 5 +++++ templates/openshift/backup-job-template.yaml | 5 +++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/image/tools/lib/component/3scale-redis.sh b/image/tools/lib/component/3scale-redis.sh index be37474..716d1cd 100644 --- a/image/tools/lib/component/3scale-redis.sh +++ b/image/tools/lib/component/3scale-redis.sh @@ -4,6 +4,6 @@ function component_dump_data { dump_rdb_path="/var/lib/redis/data/dump.rdb" oc projects - redis_pod_name=$(oc get pods -l deploymentConfig=backend-redis -o name -n 3scale | sed -e 's/^pod\///') - cp_pod_data "3scale/${redis_pod_name}:${dump_rdb_path}" "${dest_file}" + redis_pod_name=$(oc get pods -l deploymentConfig=backend-redis -o name -n ${PRODUCT_NAMESPACE_PREFIX}3scale | sed -e 's/^pod\///') + cp_pod_data "${PRODUCT_NAMESPACE_PREFIX}3scale/${redis_pod_name}:${dump_rdb_path}" "${dest_file}" } \ No newline at end of file diff --git a/image/tools/lib/component/codeready_pv.sh b/image/tools/lib/component/codeready_pv.sh index e9128c4..88110f9 100755 --- a/image/tools/lib/component/codeready_pv.sh +++ b/image/tools/lib/component/codeready_pv.sh @@ -4,11 +4,11 @@ function dump_pod_data { workspace_pod_name=$1 dump_dest=$2 workspace_id=$(echo ${workspace_pod_name} | awk -F"." '{ print $1}') - cp_pod_data "codeready/${workspace_pod_name}:/projects" "${dump_dest}/${workspace_id}" + cp_pod_data "${PRODUCT_NAMESPACE_PREFIX}codeready/${workspace_pod_name}:/projects" "${dump_dest}/${workspace_id}" } function component_dump_data { - workspace_pods=$(oc get pods -n codeready | grep workspace | awk '{print $1}') + workspace_pods=$(oc get pods -n ${PRODUCT_NAMESPACE_PREFIX}codeready | grep workspace | awk '{print $1}') if [ ${#workspace_pods} = 0 ] then diff --git a/image/tools/lib/component/enmasse_pv.sh b/image/tools/lib/component/enmasse_pv.sh index 7f0442a..b7d0b0b 100644 --- a/image/tools/lib/component/enmasse_pv.sh +++ b/image/tools/lib/component/enmasse_pv.sh @@ -2,7 +2,7 @@ # Brokered pods have a storage PV attached. They are labelled with role=broker function get_broker_pods { - echo "`oc get pods --selector='role=broker' -n enmasse -o jsonpath='{.items[*].metadata.name}'`" + echo "`oc get pods --selector='role=broker' -n ${PRODUCT_NAMESPACE_PREFIX}enmasse -o jsonpath='{.items[*].metadata.name}'`" } function dump_pod_data { @@ -12,7 +12,7 @@ function dump_pod_data { # Create a backup directory for every pod with the same name # as the pod - cp_pod_data "enmasse/${pod}:${data_dir}" "${dest}/${pod}" + cp_pod_data "${PRODUCT_NAMESPACE_PREFIX}enmasse/${pod}:${data_dir}" "${dest}/${pod}" } function component_dump_data { local archive_path="$1/archives" diff --git a/templates/openshift/backup-cronjob-template.yaml b/templates/openshift/backup-cronjob-template.yaml index 8cf57d0..589edc9 100644 --- a/templates/openshift/backup-cronjob-template.yaml +++ b/templates/openshift/backup-cronjob-template.yaml @@ -54,6 +54,8 @@ objects: value: "${COMPONENT_SECRET_NAMESPACE}" - name: PRODUCT_NAME value: "${PRODUCT_NAME}" + - name: PRODUCT_NAMESPACE_PREFIX + value: "${PRODUCT_NAMESPACE_PREFIX}" restartPolicy: Never parameters: - name: NAME @@ -65,6 +67,9 @@ parameters: - name: COMPONENT description: Component name to run the backup required: true + - name: PRODUCT_NAMESPACE_PREFIX + description: Namespace prefix for individual product namespaces. Empty by default. Planned to be 'openshift-' for RHMI. + value: '' - name: BACKEND description: Backend engine to upload the component archive value: s3 diff --git a/templates/openshift/backup-job-template.yaml b/templates/openshift/backup-job-template.yaml index 22292aa..a1b41cb 100644 --- a/templates/openshift/backup-job-template.yaml +++ b/templates/openshift/backup-job-template.yaml @@ -51,6 +51,8 @@ objects: value: "${COMPONENT_SECRET_NAMESPACE}" - name: PRODUCT_NAME value: "${PRODUCT_NAME}" + - name: PRODUCT_NAMESPACE_PREFIX + value: "${PRODUCT_NAMESPACE_PREFIX}" restartPolicy: Never parameters: - name: NAME @@ -62,6 +64,9 @@ parameters: - name: COMPONENT description: Component name to run the backup required: true + - name: PRODUCT_NAMESPACE_PREFIX + description: Namespace prefix for individual product namespaces. Empty by default. Planned to be 'openshift-' for RHMI. + value: '' - name: BACKEND description: Backend engine to upload the component archive value: s3