Skip to content

Commit 4e6a91c

Browse files
authored
Create Child recipe for UMS supported on Non-OLM to fusion BR process (#2625)
* Add UMS child recipe for no-OLM support Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * Add UMS labeling for CRDs and namespace resources Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * enhance UMS labeling for deployments, service accounts, roles, and role bindings Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * Add UMS labels for related resources in tethered ns Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * update child recipe to include additional resource types Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * add UMS labeling for configmaps and secrets related to metering Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * enhance UMS labeling to include configmaps Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * remove unnecessarily resources for ums br Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * remove labelling for secret, configmaps resources Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * remove UMS CR labeling and BR Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * labelling metering cr and br it Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> * change directory back to original name Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca> --------- Signed-off-by: YuChen <yuchen.shen@mail.utoronto.ca>
1 parent 93a19b5 commit 4e6a91c

File tree

3 files changed

+115
-7
lines changed

3 files changed

+115
-7
lines changed
170 KB
Binary file not shown.

velero/backup/common-service/label-common-service.sh

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ function label_helm_cluster_scope(){
546546
ui_release_namespace=$(${OC} get crd commonwebuis.operators.ibm.com -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-namespace}' --ignore-not-found)
547547
${OC} label secret sh.helm.release.v1.$ui_release_name.v1 -n $ui_release_namespace foundationservices.cloudpak.ibm.com=ui-cluster --overwrite=true 2>/dev/null
548548

549+
# UMS (crds)
550+
${OC} label crd ibmservicemeterdefinitions.operator.ibm.com ibmusagemeterings.operator.ibm.com foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
551+
ums_release_name=$(${OC} get crd ibmusagemeterings.operator.ibm.com -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-name}' --ignore-not-found)
552+
ums_release_namespace=$(${OC} get crd ibmusagemeterings.operator.ibm.com -o jsonpath='{.metadata.annotations.meta\.helm\.sh/release-namespace}' --ignore-not-found)
553+
${OC} label secret sh.helm.release.v1.$ums_release_name.v1 -n $ums_release_namespace foundationservices.cloudpak.ibm.com=ums --overwrite=true 2>/dev/null
554+
549555
#edb (crds, clusterrole, clusterrolebinding, webhooks)
550556
${OC} label crd backups.postgresql.k8s.enterprisedb.io clusters.postgresql.k8s.enterprisedb.io poolers.postgresql.k8s.enterprisedb.io scheduledbackups.postgresql.k8s.enterprisedb.io clusterimagecatalogs.postgresql.k8s.enterprisedb.io imagecatalogs.postgresql.k8s.enterprisedb.io publications.postgresql.k8s.enterprisedb.io subscriptions.postgresql.k8s.enterprisedb.io databases.postgresql.k8s.enterprisedb.io foundationservices.cloudpak.ibm.com=edb-cluster --overwrite=true 2>/dev/null
551557
#still need the final name value for these items, will likely match the deployment name
@@ -611,6 +617,30 @@ function label_helm_namespace_scope(){
611617
${OC} label role ibm-commonui-operator foundationservices.cloudpak.ibm.com=ui-chart -n $SERVICES_NS --overwrite=true 2>/dev/null
612618
${OC} label rolebinding ibm-commonui-operator foundationservices.cloudpak.ibm.com=ui-chart -n $OPERATOR_NS --overwrite=true 2>/dev/null
613619
${OC} label rolebinding ibm-commonui-operator foundationservices.cloudpak.ibm.com=ui-chart -n $SERVICES_NS --overwrite=true 2>/dev/null
620+
621+
# UMS (namespace resources: deployments, serviceaccounts, roles, rolebindings, configmaps, CRs)
622+
for ns in "$OPERATOR_NS" "$SERVICES_NS"; do
623+
# UMS operator deployment and serviceaccounts
624+
${OC} label deployment ibm-usage-metering-operator foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
625+
# UMS CR named ibmusagemetering-sample
626+
${OC} label ibmusagemeterings.operator.ibm.com ibmusagemetering-sample foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
627+
628+
for sa in ibm-usage-metering-operator ibm-usage-metering-instance; do
629+
${OC} label serviceaccount $sa foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
630+
done
631+
632+
# UMS roles (role name containing 'metering')
633+
metering_roles=$(${OC} get role -n $ns -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | tr ' ' '\n' | grep metering || true)
634+
for role in $metering_roles; do
635+
${OC} label role "$role" foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
636+
done
637+
638+
# UMS rolebindings (rolebinding name containing 'metering')
639+
metering_rbs=$(${OC} get rolebinding -n $ns -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | tr ' ' '\n' | grep metering || true)
640+
for rb in $metering_rbs; do
641+
${OC} label rolebinding "$rb" foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
642+
done
643+
done
614644

615645
#edb
616646
deploy=$(${OC} get deploy -n $OPERATOR_NS | grep postgresql-operator-controller-manager | awk '{print $1}')
@@ -658,13 +688,21 @@ function label_helm_namespace_scope(){
658688
${OC} label role ibm-commonui-operator foundationservices.cloudpak.ibm.com=ui-chart -n $namespace --overwrite=true 2>/dev/null
659689
${OC} label rolebinding ibm-commonui-operator foundationservices.cloudpak.ibm.com=ui-chart -n $namespace --overwrite=true 2>/dev/null
660690

661-
#edb
662-
${OC} label role postgresql-operator-controller-manager foundationservices.cloudpak.ibm.com=edb-chart -n $namespace --overwrite=true 2>/dev/null
663-
${OC} label rolebinding postgresql-operator-controller-manager foundationservices.cloudpak.ibm.com=edb-chart -n $namespace --overwrite=true 2>/dev/null
664-
665-
#zen
666-
${OC} label role ibm-zen-operator-role foundationservices.cloudpak.ibm.com=zen-chart -n $namespace --overwrite=true 2>/dev/null
667-
${OC} label rolebinding ibm-zen-operator-rolebinding foundationservices.cloudpak.ibm.com=zen-chart -n $namespace --overwrite=true 2>/dev/null
691+
# UMS (add deployment, serviceaccounts, roles, rolebindings, configmap, CRs)
692+
${OC} label deployment ibm-usage-metering-operator foundationservices.cloudpak.ibm.com=ums -n $namespace --overwrite=true 2>/dev/null || true
693+
# UMS CR named ibmusagemetering-sample
694+
${OC} label ibmusagemeterings.operator.ibm.com ibmusagemetering-sample foundationservices.cloudpak.ibm.com=ums -n $ns --overwrite=true 2>/dev/null || true
695+
for sa in ibm-usage-metering-operator ibm-usage-metering-instance; do
696+
${OC} label serviceaccount $sa foundationservices.cloudpak.ibm.com=ums -n $namespace --overwrite=true 2>/dev/null || true
697+
done
698+
metering_roles=$(${OC} get role -n $namespace -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | tr ' ' '\n' | grep metering || true)
699+
for role in $metering_roles; do
700+
${OC} label role "$role" foundationservices.cloudpak.ibm.com=ums -n $namespace --overwrite=true 2>/dev/null || true
701+
done
702+
metering_rbs=$(${OC} get rolebinding -n $namespace -o jsonpath='{.items[*].metadata.name}' 2>/dev/null | tr ' ' '\n' | grep metering || true)
703+
for rb in $metering_rbs; do
704+
${OC} label rolebinding "$rb" foundationservices.cloudpak.ibm.com=ums -n $namespace --overwrite=true 2>/dev/null || true
705+
done
668706
done
669707
fi
670708

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: spp-data-protection.isf.ibm.com/v1alpha1
2+
kind: Recipe
3+
metadata:
4+
labels:
5+
dp.isf.ibm.com/parent-recipe: cpfs-parent-recipe
6+
dp.isf.ibm.com/parent-recipe-namespace: <parent recipe namespace>
7+
name: ums-child-recipe
8+
namespace: <child recipe namespace>
9+
spec:
10+
appType: common-service
11+
groups:
12+
- includeClusterResources: true
13+
includedResourceTypes:
14+
- customresourcedefinitions.apiextensions.k8s.io
15+
labelSelector: foundationservices.cloudpak.ibm.com=ums
16+
name: ums-crd
17+
type: resource
18+
- includedResourceTypes:
19+
- serviceaccount
20+
- role
21+
- rolebinding
22+
- deployments
23+
- ibmusagemeterings.operator.ibm.com
24+
labelSelector: foundationservices.cloudpak.ibm.com=ums
25+
name: ums-resources
26+
type: resource
27+
- backupRef: ums-resources
28+
includedResourceTypes:
29+
- serviceaccount
30+
- role
31+
- rolebinding
32+
name: ums-rbac-resources
33+
type: resource
34+
- backupRef: ums-resources
35+
includedResourceTypes:
36+
- ibmusagemeterings.operator.ibm.com
37+
name: ums-cr
38+
type: resource
39+
- backupRef: ums-resources
40+
includedResourceTypes:
41+
- deployments
42+
name: ums-deployment
43+
type: resource
44+
hooks:
45+
- chks:
46+
- condition: '{$.status.phase} == {"Running"}'
47+
name: podReady
48+
onError: fail
49+
timeout: 300
50+
labelSelector: app.kubernetes.io/name=ibm-usage-metering
51+
name: ums-instance-check
52+
namespace: <service namespace> # namespace where the UMS instance CR is deployed
53+
onError: fail
54+
selectResource: pod
55+
timeout: 300
56+
type: check
57+
workflows:
58+
- name: chart-backup
59+
priority: 0
60+
sequence:
61+
- group: ums-crd
62+
- group: ums-resources
63+
- name: chart-restore
64+
priority: 6
65+
sequence:
66+
- group: ums-crd
67+
- group: ums-rbac-resources
68+
- group: ums-cr
69+
- group: ums-deployment
70+
- hook: ums-instance-check/podReady

0 commit comments

Comments
 (0)