From 11c3b080742bdd674dd5c0a8e3439e41fb68e36d Mon Sep 17 00:00:00 2001 From: Drew Wells <dwells@infoblox.com> Date: Tue, 10 Dec 2024 00:22:02 -0600 Subject: [PATCH] patch databases to use implicit version 15.3 --- scripts/patch-databases.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 scripts/patch-databases.sh diff --git a/scripts/patch-databases.sh b/scripts/patch-databases.sh new file mode 100755 index 00000000..85513f03 --- /dev/null +++ b/scripts/patch-databases.sh @@ -0,0 +1,12 @@ +#!/bin/bash -x + +# This script performs a common maintenance operation of updating +# status fields to version "15.3" from "15". +# Usage: DRY_RUN="--dry-run=server" ./scripts/patch-databases.sh + +kubectl get databaseclaim -A -o json | jq -r '.items[] | select((.spec.dbVersion == null or .spec.dbVersion == "") and (.status.activeDB.dbversion != "15.3")) | [.metadata.namespace, .metadata.name] | @tsv' | while IFS=$'\t' read -r namespace name; do + kubectl get databaseclaim -n "$namespace" "$name" -ojsonpath='{.metadata.namespace}/{.metadata.name}:{.status.activeDB.dbversion}{"\n"}' + kubectl patch ${DRY_RUN} databaseclaim "$name" -n "$namespace" --type=merge --subresource=status -p '{"status":{"activeDB":{"dbversion":"15.3"}}}' + + kubectl patch ${DRY_RUN} databaseclaim "$name" -n "$namespace" --type=merge -p '{"metadata":{"annotations":{"reconcile-now":"true"}}}' +done