File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ REFERENCED_RUNTIMES=" referenced_runtimes.txt"
4+ DEPRECATED_RUNTIMES=" deprecated_runtimes.txt"
5+
6+ kubectl get devbox -A -o json | jq -r ' .items[].spec.runtimeRef.name' | sort | uniq > " $REFERENCED_RUNTIMES "
7+ kubectl get runtime -A -o json | jq -r ' .items[] | select(.spec.state == "deprecated") | .metadata.name' | sort | uniq > " $DEPRECATED_RUNTIMES "
8+
9+ UNREFERENCED_RUNTIMES=$( comm -13 " $REFERENCED_RUNTIMES " " $DEPRECATED_RUNTIMES " )
10+
11+ echo " 未被引用的 deprecated runtime:"
12+ echo " $UNREFERENCED_RUNTIMES "
13+
14+ if [ ! -z " $UNREFERENCED_RUNTIMES " ]; then
15+ echo " 正在删除未被引用的 deprecated runtime..."
16+ for runtime in $UNREFERENCED_RUNTIMES ; do
17+ kubectl delete runtime " $runtime " --all-namespaces
18+ done
19+ else
20+ echo " 没有未被引用的 deprecated runtime 需要删除。"
21+ fi
22+
23+ rm " $REFERENCED_RUNTIMES " " $DEPRECATED_RUNTIMES "
You can’t perform that action at this time.
0 commit comments