Is there a way to use HorizontalPodAutoscaler
and achieve scaling up/down and along with that update a value (either Helm Variable like .Values.foo
or an environemnt variable inside the running pod)?
Backround: I am looking for a Open Source Postgres installation that has the ability to Scale. I found a good once here https://github.com/bitnami/charts/tree/master/bitnami/postgresql-ha
This package has documentated manual way to scale, with a command like helm install/upgrade test . --set postgresql.replicaCount=1
I am trying to put a HorizontalPodAutoscaler
to this package.
Also read: https://github.com/bitnami/charts/issues/2931
Summary of Research:
REPMGR_PARTNER_NODES
APP_NAME-postgresql-ha-postgresql-REPLICA_NUM.APP_NAME-postgresql-ha-postgresql-headless.default.svc.cluster.local
templates/postgresql/statefulset.yaml
in its env sectionkubectl describe statefulset test-postgresql-ha-postgresql | grep Replicas:
Problem:
REPMGR_PARTNER_NODES
has a older value.apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: "test-hpa"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: StatefulSet
name: "test-postgresql-ha-postgresql"
minReplicas: 4
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 40