Skip to content

Commit cc90ca6

Browse files
authored
feat: Create a convenience script to uninstall Dynamo Deploy CRDs (#1933)
1 parent 267b422 commit cc90ca6

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

deploy/cloud/helm/uninstall.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
trap 'echo "Error at line $LINENO. Exiting."' ERR
19+
20+
read -p "Are you sure you want to delete ALL Dynamo CRDs and their instances? (y/N): " confirm
21+
if [[ "$confirm" != "y" ]]; then
22+
echo "Aborting."
23+
exit 1
24+
fi
25+
26+
# Step 1: Get all CRDs with the prefix
27+
DYNAMO_CRDS="$(kubectl get crds -o name | grep 'nvidia.com' | grep 'dynamo' | cut -d'/' -f2)"
28+
29+
if [ -z "${DYNAMO_CRDS}" ]; then
30+
echo "Dynamo CRDs not found"
31+
exit 1
32+
fi
33+
34+
# Step 2: Delete all custom resource instances for each CRD
35+
for CRD in ${DYNAMO_CRDS}; do
36+
SCOPE=$(kubectl get crd "${CRD}" -o jsonpath='{.spec.scope}')
37+
38+
if [ "$SCOPE" == "Namespaced" ]; then
39+
echo "Deleting all namespaced instances of ${CRD}..."
40+
kubectl get "${CRD}" --all-namespaces -o name | xargs -r kubectl delete --wait=false
41+
else
42+
echo "Skipping cluster-scoped CRD: ${CRD}"
43+
fi
44+
done
45+
46+
47+
# Step 3: Wait for the Operator to handle finalizer removal
48+
echo "Waiting for Dynamo Operator to handle the finalizer removal (30 seconds)..."
49+
sleep 30
50+
51+
# Step 4: Verify all Custom Resources have been removed
52+
for CRD in ${DYNAMO_CRDS}; do
53+
# Check CRs
54+
55+
echo "Checking instances of ${CRD}"
56+
kubectl get "${CRD}" --all-namespaces -o name
57+
done
58+
59+
# Step 5: Delete the CRDs themselves
60+
echo "Deleting CRDs..."
61+
62+
for CRD in ${DYNAMO_CRDS}; do
63+
# Delete all CRD's
64+
65+
echo "Deleting CRD: ${CRD}..."
66+
kubectl delete crd "${CRD}"
67+
done
68+
69+

docs/guides/dynamo_deploy/quickstart.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ helm install dynamo-platform ./platform/ \
140140

141141
[More on Deploying to Dynamo Cloud](./dynamo_cloud.md)
142142

143+
## Uninstall CRDs for a clean start
144+
145+
We provide a script to uninstall CRDs should you need a clean start.
146+
147+
```bash
148+
./uninstall.sh
149+
```
143150

144151
## Explore Examples
145152

0 commit comments

Comments
 (0)