Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

66195 #2460

Open
wants to merge 12 commits into
base: scripts-dev
Choose a base branch
from
61 changes: 48 additions & 13 deletions velero/backup/common-service/label-common-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -164,7 +161,6 @@ function parse_arguments() {
ADDITIONAL_SOURCES=$1
;;
--no-olm)
shift
NO_OLM="true"
;;
-h | --help)
Expand Down Expand Up @@ -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=licensing-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=licensing-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=licensing-cluster --overwrite=true 2>/dev/null

${OC} label ibmlicensing instance -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=licensing-chart --overwrite=true 2>/dev/null
${OC} label deployment ibm-licensing-operator -n $LICENSING_NAMESPACE foundationservices.cloudpak.ibm.com=licensing-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=licensing-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=licensing-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=licensing-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=licensing-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() {
Expand Down
26 changes: 26 additions & 0 deletions velero/restore/no-olm/restore-licensing-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: velero.io/v1
kind: Restore
metadata:
name: restore-licensing-charts
namespace: velero
spec:
backupName: __BACKUP_NAME__
excludedResources:
- nodes
- events
- events.events.k8s.io
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
hooks: {}
includedNamespaces:
- '*'
includedResources:
- '*'
orLabelSelectors:
- matchExpressions:
- key: foundationservices.cloudpak.ibm.com
operator: In
values:
- licensing-cluster
- licensing-chart
11 changes: 8 additions & 3 deletions velero/restore/restore-lsr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ spec:
hooks: {}
includedNamespaces:
- '*'
labelSelector:
matchLabels:
foundationservices.cloudpak.ibm.com: lsr
orLabelSelectors:
- matchExpressions:
- key: foundationservices.cloudpak.ibm.com
operator: In
values:
- lsr-cluster
- lsr-chart
- lsr
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions velero/schedule/schedule-common-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ spec:
- iam-chart
- iam-cluster
- nss-cluster
- licensing-cluster
- licensing-chart
- lsr-cluster
- lsr-chart
Loading