diff --git a/velero/backup/common-service/label-common-service.sh b/velero/backup/common-service/label-common-service.sh index d3c869d01..d02452c62 100755 --- a/velero/backup/common-service/label-common-service.sh +++ b/velero/backup/common-service/label-common-service.sh @@ -57,27 +57,24 @@ function main() { label_catalogsource label_subscription else - #TODO create function(s) to label chart resources label_helm_cluster_scope label_helm_namespace_scope - #charts to label - #odlm - #cs operator - #ibm iam operator - #common ui - #edb - #zen? - #nss already covered in the label_nss function + if [[ $ENABLE_LICENSING -eq 1 ]]; then + label_helm_licensing + fi + if [[ $ENABLE_LSR -eq 1 ]]; then + label_helm_lsr + fi fi label_ns_and_related label_configmap - if [[ $ENABLE_LSR -eq 1 ]]; then - label_lsr - fi label_cs if [[ $SERVICES_NS != "" ]]; then label_nss fi + if [[ $ENABLE_LSR -eq 1 ]]; then + label_lsr + fi label_mcsp success "Successfully labeled all the resources" } @@ -164,7 +161,6 @@ function parse_arguments() { ADDITIONAL_SOURCES=$1 ;; --no-olm) - shift NO_OLM="true" ;; -h | --help) @@ -616,6 +612,45 @@ function label_helm_namespace_scope(){ success "Namespace scoped charts labeled." } +function label_helm_licensing() { + title "Labeling Licensing cluster and namespace resources..." + ${OC} label clusterrole ibm-license-service ibm-license-service-restricted ibm-licensing-default-reader ibm-licensing-operator foundationservices.cloudpak.ibm.com=ls-cluster --overwrite=true 2>/dev/null + ${OC} label clusterrolebinding ibm-license-service ibm-license-service-restricted ibm-licensing-default-reader ibm-licensing-operator ibm-license-service-cluster-monitoring-view foundationservices.cloudpak.ibm.com=ls-cluster --overwrite=true 2>/dev/null + ${OC} label customresourcedefinition ibmlicensingdefinitions.operator.ibm.com ibmlicensingquerysources.operator.ibm.com ibmlicensings.operator.ibm.com foundationservices.cloudpak.ibm.com=ls-cluster --overwrite=true 2>/dev/null + + ${OC} label ibmlicensing instance -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + ${OC} label deployment ibm-licensing-operator -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + ${OC} label role ibm-license-service ibm-license-service-restricted ibm-licensing-operator -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + ${OC} label rolebinding ibm-license-service ibm-license-service-restricted ibm-licensing-operator -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + ${OC} label serviceaccount ibm-license-service ibm-license-service-restricted ibm-licensing-default-reader ibm-licensing-operator -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + + lis_release_name=$(${OC} get deploy ibm-licensing-operator -n $LICENSING_NAMESPACE -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-name}' --ignore-not-found) + lis_release_namespace=$(${OC} get deploy ibm-licensing-operator -n $LICENSING_NAMESPACE -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-namespace}' --ignore-not-found) + ${OC} label secret sh.helm.release.v1.$lis_release_name.v1 -n $lis_release_namespace foundationservices.cloudpak.ibm.com=ls-chart --overwrite=true 2>/dev/null + + success "Licensing resources labeled" + +} + +function label_helm_lsr() { + title "Labeling License Service Reporter cluster and namespace resources..." + ${OC} label clusterrole manager-role foundationservices.cloudpak.ibm.com=lsr-cluster --overwrite=true 2>/dev/null + ${OC} label clusterrolebinding manager-rolebinding foundationservices.cloudpak.ibm.com=lsr-cluster --overwrite=true 2>/dev/null + ${OC} label customresourcedefinition ibmlicenseservicereporters.operator.ibm.com foundationservices.cloudpak.ibm.com=lsr-cluster --overwrite=true 2>/dev/null + + ${OC} label ibmlicenseservicereporters.operator.ibm.com instance -n $LSR_NAMESPACE foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + ${OC} label deployment ibm-license-service-reporter-operator -n $LSR_NAMESPACE foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + ${OC} label role ibm-license-service-reporter leader-election-role manager-role -n $LSR_NAMESPACE foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + ${OC} label rolebinding ibm-license-service-reporter leader-election-rolebinding manager-rolebinding -n $LSR_NAMESPACE foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + ${OC} label serviceaccount ibm-license-service-reporter ibm-license-service-reporter-operator -n $LSR_NAMESPACE foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + + lsr_release_name=$(${OC} get deploy ibm-license-service-reporter-operator -n $LSR_NAMESPACE -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-name}' --ignore-not-found) + lsr_release_namespace=$(${OC} get deploy ibm-license-service-reporter-operator -n $LSR_NAMESPACE -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-namespace}' --ignore-not-found) + ${OC} label secret sh.helm.release.v1.$lsr_release_name.v1 -n $lsr_release_namespace foundationservices.cloudpak.ibm.com=lsr-chart --overwrite=true 2>/dev/null + + success "LSR resources labeled" +} + # ---------- Info functions ----------# function msg() { diff --git a/velero/restore/restore-licensing.yaml b/velero/restore/restore-licensing.yaml index 74ecd7c22..121b2e230 100644 --- a/velero/restore/restore-licensing.yaml +++ b/velero/restore/restore-licensing.yaml @@ -15,6 +15,11 @@ spec: hooks: {} includedNamespaces: - '*' - labelSelector: - matchLabels: - foundationservices.cloudpak.ibm.com: licensing + orLabelSelectors: + - matchExpressions: + - key: foundationservices.cloudpak.ibm.com + operator: In + values: + - ls-cluster + - ls-chart + - licensing diff --git a/velero/restore/restore-lsr.yaml b/velero/restore/restore-lsr.yaml index 593b028f7..24652f5ee 100644 --- a/velero/restore/restore-lsr.yaml +++ b/velero/restore/restore-lsr.yaml @@ -15,6 +15,11 @@ spec: hooks: {} includedNamespaces: - '*' - labelSelector: - matchLabels: - foundationservices.cloudpak.ibm.com: lsr \ No newline at end of file + orLabelSelectors: + - matchExpressions: + - key: foundationservices.cloudpak.ibm.com + operator: In + values: + - lsr-cluster + - lsr-chart + - lsr \ No newline at end of file diff --git a/velero/schedule/license_service_reporter/lsr-br-scripts-cm.yaml b/velero/schedule/license_service_reporter/lsr-br-scripts-cm.yaml index 33c0da9f4..5ac56cc6e 100644 --- a/velero/schedule/license_service_reporter/lsr-br-scripts-cm.yaml +++ b/velero/schedule/license_service_reporter/lsr-br-scripts-cm.yaml @@ -32,7 +32,7 @@ data: info "Mode set to backup, beginning backup process." backup success "Backup completed successfully." - else if [[ $MODE == "restore" ]] + elif [[ $MODE == "restore" ]]; then info "Mode is set to restore, beginning restore process." restore success "Restore completed successfully." diff --git a/velero/schedule/schedule-common-services.yaml b/velero/schedule/schedule-common-services.yaml index 825c12a62..5c4453bcc 100644 --- a/velero/schedule/schedule-common-services.yaml +++ b/velero/schedule/schedule-common-services.yaml @@ -58,3 +58,7 @@ spec: - iam-chart - iam-cluster - nss-cluster + - licensing-cluster + - licensing-chart + - lsr-cluster + - lsr-chart