postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Scaling in k8s cloud.

Open Menzorg opened this issue 4 years ago • 6 comments

Hello. Thanks a lot for this pretty operator.

I could not find info about scaling pods with a postgres operator! I have operator in my k8s cluster and CRD postgres, configured to be 3-instancies pg-cluster. So, if I want to enable autoscaling, what shall i do? Is it built in? I meen to auto-scale statefulset pod count.

I know, that k8s have a HPA for example, but... postgres operator has some checking feature to "repare" pg-cluster and if i change statefulset pods count manualy, then operator will "fix" to mainfest default value = 3. What do i need to do? Create pg-cluster with some other way that crd? Or maybe some patrony configuration? Maybe will find answer soon and will close issue, but i think, it may be question that interests not only me.

best regards, Piter.

Menzorg avatar Apr 24 '21 02:04 Menzorg

What is your expectation on autoscaling though?

For a database setup, autoscaling up and down doesn't make much sense as it takes time and resources from your existing databases due to your new instance syncing up.

For bigger databases, that can take hours or days.

Sicaine avatar Jun 06 '21 09:06 Sicaine

What is your expectation on autoscaling though? ... For bigger databases, that can take hours or days.

So, if i understood correctly, it is not inbox functional. My expectation is using HPA. Our DB is small (about 300mb), and it will not be much bigger for a long time. We have configured in crd count of instances, but we want to increase the number not manually when we have highload. In our case, when we increase count manually - every new instance starts for minute. To my mind it is good solution to have autoscaling ability in this scenario.

Menzorg avatar Jun 08 '21 01:06 Menzorg

I think, it may be good solution, if we could tell confguration checker to check or not to check number of instancies, for example

apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
  name: test-pg-cluster
  namespace: test-namespace
spec:
  dockerImage: registry.opensource.zalan.do/acid/spilo-13:2.0-p6
  teamId: "test"
  numberOfInstances: 3
  checkNumberOfInstances: true

So, when it is false - operator will not force change statefullSet replica count. Then we can create HPA with some logic. Maybe usefull will be to more update postgresql CRD to configure HPA, if we want to have ability to create it with creating pg cluster.

Menzorg avatar Jun 08 '21 01:06 Menzorg

@Menzorg this open will be helpful as I have read-only replicas and sometimes I want them to scale up based on the load.

sarmadali20 avatar Nov 01 '21 21:11 sarmadali20

I would like to have this feature. FYI - how configure autoscaling of db on Amazon - https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.AutoScaling.html

baznikin avatar Feb 19 '25 13:02 baznikin

I postgresqls.acid.zalan.do had /scale subresource, then he would automatically be supported by HorizontalPodAutoscaler... Then one can add custom metrics to HPA and scale based on replica sets CPU utlization or connections number. Just give us this possibility

PS: found 'guide' by adding scale support to CRD resource - https://medium.com/@thescott111/autoscaling-kubernetes-custom-resource-using-the-hpa-957d00bb7993. On first glance it doesn't looks too scary. Anyone with Go knowledge here willing to implement?

baznikin avatar Feb 19 '25 14:02 baznikin