-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_odh.sh
executable file
·140 lines (122 loc) · 3.79 KB
/
remove_odh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
install_odh(){
oc apply -k https://github.com/redhat-cop/gitops-catalog/opendatahub-operator/operator/overlays/stable
# new project
oc new-project odh-testing
sleep 60
# default kfdef
cat << YAML | oc apply -f -
kind: KfDef
apiVersion: kfdef.apps.kubeflow.org/v1
metadata:
name: opendatahub
spec:
applications:
- kustomizeConfig:
repoRef:
name: manifests
path: odh-common
name: odh-common
- kustomizeConfig:
repoRef:
name: manifests
path: odh-dashboard
name: odh-dashboard
- kustomizeConfig:
repoRef:
name: manifests
path: prometheus/cluster
name: prometheus-cluster
- kustomizeConfig:
repoRef:
name: manifests
path: prometheus/operator
name: prometheus-operator
- kustomizeConfig:
repoRef:
name: manifests
path: grafana/cluster
name: grafana-cluster
- kustomizeConfig:
repoRef:
name: manifests
path: grafana/grafana
name: grafana-instance
- kustomizeConfig:
repoRef:
name: manifests
path: odh-notebook-controller
name: odh-notebook-controller
- kustomizeConfig:
repoRef:
name: manifests
path: notebook-images
name: notebook-images
- kustomizeConfig:
overlays:
- odh-model-controller
repoRef:
name: manifests
path: model-mesh
name: model-mesh
- kustomizeConfig:
overlays:
- metadata-store-mariadb
- ds-pipeline-ui
- object-store-minio
- default-configs
repoRef:
name: manifests
path: data-science-pipelines
name: data-science-pipelines
repos:
- name: manifests
uri: 'https://github.com/opendatahub-io/odh-manifests/tarball/v1.4.1'
YAML
}
remove_odh(){
# run the uninstall wizard (may fail)
# NOTE: crd named `odhquickstarts.console.openshift.io` does not follow the same domain `opendatahub.io`
# NOTE: inconsistency in api use: `odhquickstarts console.openshift.io/v1 true OdhQuickStart`
# NOTE: grafana dependencies not removed
# removing finalizers for kfdefs
# BUG: odh operator doesn't consistently remove kfdefs
oc get kfdef -A
oc get kfdef -A | grep -v NAME | while read -r NAMESPACE NAME JUNK
do
oc -n "${NAMESPACE}" patch kfdef "${NAME}" --type merge -p '{"metadata": {"finalizers": null}}'
done
# removing related crds
BASIC_INFO="NAMESPACE:.metadata.namespace"
BASIC_INFO="${BASIC_INFO},NAME:.metadata.name"
for crd in $(oc get crd -o name | egrep 'odh|kfdef' | sed 's@custom.*k8s.io/@@')
do
echo "Searching for CR: $crd"
oc get $crd --no-headers -o custom-columns="${BASIC_INFO}" -A | while read -r NAMESPACE NAME
do
oc delete -n "${NAMESPACE}" "$crd" "${NAME}"
done
done
# removing related crds - hope you weren't using grafana
for crd in $(oc get crd -o name | egrep 'integreatly.org' | sed 's@custom.*k8s.io/@@')
do
echo "Searching for CR: $crd"
oc delete $crd --all -A
oc delete crd $crd
done
# what an uninstall does in the ocp console
# delete csv,sub = uninstall
# BUG: odh operator does not remove csv
oc delete -n openshift-operators csv opendatahub-operator.v1.4.1
oc delete -n openshift-operators sub opendatahub-operator
# BUG: the odh operator created a redundant operator group in openshift-operators
# kfctl.kubeflow.io/kfdef-instance: opendatahub.openshift-operators
# oc get operatorgroup -l opendatahub.io/component -A
oc -n openshift-operators delete operatorgroup opendatahub
# INFO: additional namespaces created
# oc get ns -l opendatahub.io/component
oc delete ns anonymous system
echo "delete the project / namespace where you deployed your original kfdefs"
echo "oc delete <project>"
}
# remove_odh