From 59c4f003a53ca600afe5eba99ae47c5074cb6676 Mon Sep 17 00:00:00 2001 From: Lockszmith Date: Mon, 29 Apr 2024 23:26:36 -0400 Subject: [PATCH] Added nameupdate.sh script for TrueCharts --- nameupdate.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 nameupdate.sh diff --git a/nameupdate.sh b/nameupdate.sh new file mode 100755 index 0000000..a1e08ef --- /dev/null +++ b/nameupdate.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Update train from 'enterprise' to 'premium' and 'operators' to 'system' +# Loop through all namespaces prefixed by "ix-" +for ns in $(k3s kubectl get ns --no-headers | grep "^ix-" | awk '{print $1}' ORS=' '); do + # Check if the namespace has "catalog_train" label set to "enterprise" or "operators" + catalog_train_label=$(k3s kubectl get namespace "$ns" -o jsonpath='{.metadata.labels.catalog_train}') + if [[ "$catalog_train_label" == "enterprise" ]]; then + # Patch the namespace to change the "catalog_train" label to "premium" + k3s kubectl patch namespace "$ns" -p '{"metadata":{"labels":{"catalog_train":"premium"}}}' + echo "Namespace $ns updated from enterprise to premium." + elif [[ "$catalog_train_label" == "operators" ]]; then + # Patch the namespace to change the "catalog_train" label to "system" + k3s kubectl patch namespace "$ns" -p '{"metadata":{"labels":{"catalog_train":"system"}}}' + echo "Namespace $ns updated from operators to system." + fi +done +