From 908f38190d810a0078878a310c92ff012f506a88 Mon Sep 17 00:00:00 2001 From: Senyo Simpson Date: Thu, 3 Jul 2025 19:21:39 +0200 Subject: [PATCH 1/3] use kubernetes service host env var --- internal/postgres/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/postgres/config.go b/internal/postgres/config.go index 3538c40ff3..c05987e854 100644 --- a/internal/postgres/config.go +++ b/internal/postgres/config.go @@ -216,7 +216,7 @@ done if post250 { script = fmt.Sprintf(` # Parameters for curl when managing autogrow annotation. -APISERVER="https://kubernetes.default.svc" +APISERVER="https://${KUBERNETES_SERVICE_HOST}" SERVICEACCOUNT="/var/run/secrets/kubernetes.io/serviceaccount" NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace) TOKEN=$(cat ${SERVICEACCOUNT}/token) From 19fd8827cddffa6d3392f719abd00c0b43f73d04 Mon Sep 17 00:00:00 2001 From: Senyo Simpson Date: Thu, 3 Jul 2025 19:39:16 +0200 Subject: [PATCH 2/3] fix test --- internal/postgres/reconcile_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go index fb6bc6f35a..c7f8bd0a9c 100644 --- a/internal/postgres/reconcile_test.go +++ b/internal/postgres/reconcile_test.go @@ -172,7 +172,7 @@ containers: - |- monitor() { # Parameters for curl when managing autogrow annotation. - APISERVER="https://kubernetes.default.svc" + APISERVER="https://${KUBERNETES_SERVICE_HOST}" SERVICEACCOUNT="/var/run/secrets/kubernetes.io/serviceaccount" NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace) TOKEN=$(cat ${SERVICEACCOUNT}/token) From 37f22318e586692740b00b6a7dbf08ade335330a Mon Sep 17 00:00:00 2001 From: Senyo Simpson Date: Fri, 4 Jul 2025 10:45:47 +0200 Subject: [PATCH 3/3] use custom hostname env var --- internal/postgres/config.go | 2 +- internal/postgres/reconcile_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/postgres/config.go b/internal/postgres/config.go index c05987e854..2d2917767d 100644 --- a/internal/postgres/config.go +++ b/internal/postgres/config.go @@ -246,7 +246,7 @@ while read -r -t 5 -u "${fd}" ||:; do newSize="$(((sizeInt / 2)+sizeInt))" newSizeMi="${newSize}Mi" d='[{"op": "add", "path": "/metadata/annotations/suggested-pgdata-pvc-size", "value": "'"$newSizeMi"'"}]' - curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -XPATCH "${APISERVER}/api/v1/namespaces/${NAMESPACE}/pods/${HOSTNAME}?fieldManager=kubectl-annotate" -H "Content-Type: application/json-patch+json" --data "$d" + curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -XPATCH "${APISERVER}/api/v1/namespaces/${NAMESPACE}/pods/${hostname}?fieldManager=kubectl-annotate" -H "Content-Type: application/json-patch+json" --data "$d" fi done `, diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go index c7f8bd0a9c..8014c18488 100644 --- a/internal/postgres/reconcile_test.go +++ b/internal/postgres/reconcile_test.go @@ -202,7 +202,7 @@ containers: newSize="$(((sizeInt / 2)+sizeInt))" newSizeMi="${newSize}Mi" d='[{"op": "add", "path": "/metadata/annotations/suggested-pgdata-pvc-size", "value": "'"$newSizeMi"'"}]' - curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -XPATCH "${APISERVER}/api/v1/namespaces/${NAMESPACE}/pods/${HOSTNAME}?fieldManager=kubectl-annotate" -H "Content-Type: application/json-patch+json" --data "$d" + curl --cacert ${CACERT} --header "Authorization: Bearer ${TOKEN}" -XPATCH "${APISERVER}/api/v1/namespaces/${NAMESPACE}/pods/${hostname}?fieldManager=kubectl-annotate" -H "Content-Type: application/json-patch+json" --data "$d" fi done }; export -f monitor; exec -a "$0" bash -ceu monitor