Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cp3pt0-deployment/common/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,28 @@ function get_catalogsource() {
# Extracting the values using string manipulation
catalog_source=$(echo "$result" | awk -F': ' '{print $2}' | awk -F',' '{print $1}')
catalog_namespace=$(echo "$result" | awk -F': ' '{print $NF}')
elif [[ count -eq 2 ]]; then
# If there are two catalog sources,
# case 1: "catalog_source_1" and "catalog_source_2", we return both of them
# case 2: "certified-operators" and "catalog_source_2", we only return "catalog_source_2"
# Split the result into lines
IFS=$'\n' read -rd '' -a lines <<< "$result"

for ((i = 0; i < ${#lines[@]}; i+=2)); do
name_line=${lines[$i]}
ns_line=${lines[$i+1]}
name=$(echo "$name_line" | awk -F': ' '{print $2}')
ns=$(echo "$ns_line" | awk -F': ' '{print $2}')
# If the catalog source is not "certified-operators", we use it
if [[ "$name" != "certified-operators" ]]; then
catalog_source=$name
catalog_namespace=$ns
else
# If the catalog source is "certified-operators", we skip it
count=1
continue
fi
done
fi
echo "$count $catalog_source $catalog_namespace"
}
Expand Down
2 changes: 2 additions & 0 deletions velero/backup/common-service/label-bedrock-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ rules:
- roles
- rolebindings
- serviceaccount
- ibmusagemeterings
- ibmservicemeterdefinitions
#not necessary for cpd
#- ibmlicenseservicereporters.operator.ibm.com
38 changes: 35 additions & 3 deletions velero/backup/common-service/label-common-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ENABLE_PRIVATE_CATALOG=0
ENABLE_CERT_MANAGER=0
ENABLE_LICENSING=0
ENABLE_LSR=0
ENABLE_DEEFAULT_CS=0
ENABLE_DEFAULT_CS=0
CS_SOURCE_NS="openshift-marketplace"
CM_SOURCE_NS="openshift-marketplace"
LIS_SOURCE_NS="openshift-marketplace"
Expand All @@ -57,6 +57,7 @@ function main() {
if [[ $NO_OLM == "false" ]]; then
label_catalogsource
label_subscription
label_ums
else
label_helm_cluster_scope
label_helm_namespace_scope
Expand Down Expand Up @@ -162,7 +163,7 @@ function parse_arguments() {
ENABLE_PRIVATE_CATALOG=1
;;
--enable-default-catalog-ns)
ENABLE_DEEFAULT_CS=1
ENABLE_DEFAULT_CS=1
;;
--additional-catalog-sources)
shift
Expand Down Expand Up @@ -235,7 +236,7 @@ function label_catalogsource() {
label_ibm_catalogsources "$namespace"
done <<< "$private_namespaces"
fi
if [[ $ENABLE_DEEFAULT_CS -eq 1 ]]; then
if [[ $ENABLE_DEFAULT_CS -eq 1 ]]; then
label_ibm_catalogsources "$DEFAULT_SOURCE_NS"
fi
echo ""
Expand Down Expand Up @@ -414,6 +415,37 @@ function label_lsr() {
echo ""
}

function label_ums(){
ums_exists=$(${OC} get crd | grep ibmusagemeterings.operator.ibm.com)
if [[ -z $ums_exists ]]; then
info "No UMS CRD found on cluster, skipping..."
else
title "Start labeling Usage Metering Service resources..."
namespaces=$(${OC} get configmap namespace-scope -n $OPERATOR_NS -oyaml | awk '/^data:/ {flag=1; next} /^ namespaces:/ {print $2; next} flag && /^ [^ ]+: / {flag=0}')
namespaces=$(echo "$namespaces" | tr ',' '\n')

${OC} label customresourcedefinition ibmservicemeterdefinitions.operator.ibm.com ibmusagemeterings.operator.ibm.com foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null

#UMS resources since its possible they are present in namespaces other than the services namespace
while IFS= read -r namespace; do
${OC} label configmap ibm-usage-metering-events -n $namespace foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
service_meter_crs=$(${OC} get ibmservicemeterdefinitions.operator.ibm.com -n $namespace -o custom-columns=NAME:.metadata.name --no-headers)
while IFS= read -r servicemeterCR; do
${OC} label ibmservicemeterdefinitions.operator.ibm.com $servicemeterCR -n $namespace foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
done <<< "$service_meter_crs"
ums_cr=$(${OC} get ibmusagemeterings.operator.ibm.com -n $namespace -o custom-columns=NAME:.metadata.name --no-headers | awk '{print $1}')
if [[ ! -z $ums_cr ]]; then
${OC} label ibmusagemeterings.operator.ibm.com $ums_cr -n $namespace foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
fi
sub=$(${OC} get subscriptions.operators.coreos.com -n $namespace -o custom-columns=NAME:.spec.name --no-headers | grep ibm-usage-metering)
if [[ ! -z $sub ]]; then
${OC} label subscriptions.operators.coreos.com $sub -n $namespace foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
fi
done <<< "$namespaces"
success "UMS resources labeled successfully."
fi
}

function label_cs(){

title "Start to label the CommonService CR... "
Expand Down
2 changes: 2 additions & 0 deletions velero/restore/restore-cs-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
- roles.authorization.openshift.io
- rolebindings.authorization.openshift.io
hooks: {}
includedNamespaces:
- '*'
Expand Down
4 changes: 3 additions & 1 deletion velero/restore/restore-lsr-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ spec:
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
- roles.authorization.openshift.io
- rolebindings.authorization.openshift.io
hooks: {}
includedNamespaces:
- '*'
labelSelector:
matchLabels:
foundationservices.cloudpak.ibm.com: lsr-data
foundationservices.cloudpak.ibm.com: lsr-data
2 changes: 2 additions & 0 deletions velero/restore/restore-nss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
- roles.authorization.openshift.io
- rolebindings.authorization.openshift.io
hooks: {}
includedNamespaces:
- '*'
Expand Down
20 changes: 20 additions & 0 deletions velero/restore/restore-ums.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: velero.io/v1
kind: Restore
metadata:
name: restore-ums
namespace: velero
spec:
backupName: __BACKUP_NAME__
excludedResources:
- nodes
- events
- events.events.k8s.io
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
hooks: {}
includedNamespaces:
- '*'
labelSelector:
matchLabels:
foundationservices.cloudpak.ibm.com: ums
2 changes: 2 additions & 0 deletions velero/restore/restore-zen5-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
- backups.velero.io
- restores.velero.io
- resticrepositories.velero.io
- roles.authorization.openshift.io
- rolebindings.authorization.openshift.io
hooks: {}
includedNamespaces:
- '*'
Expand Down
1 change: 1 addition & 0 deletions velero/schedule/schedule-common-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ spec:
- lsr-cluster
- lsr-chart
- ibm-cm-chart
- ums
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
timeout: 600
name: nss-check
nameSelector: ibm-namespace-scope-operator
namespace: cs-op
namespace: <child recipe namespace>
onError: fail
selectResource: deployment
timeout: 600
Expand All @@ -42,4 +42,4 @@ spec:
# nss
- group: nss-resources
- hook: nss-check/podReady


Loading