diff --git a/internal/postgres/config.go b/internal/postgres/config.go index 3538c40ff3..2d2917767d 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) @@ -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 fb6bc6f35a..8014c18488 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) @@ -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