You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Support the scale sub-resource for Clusters #2574
We would like to utilize the vertical pod autoscaler to automatically scale the PG pods in the Cluster. The VPA can support managing pods of custom resources as long as they implement the scale sub-resource. It would be great to have that for the Cluster CRD.
Cannot get target selector from VPA's targetRef. Reason: Unhandled targetRef postgresql.cnpg.io/v1 / Cluster / primary-api-pg, last error Resource primary-api/primary-api-pg has an empty selector for scale sub-resource
I finally had problem caused by this issue: #3753 so I reactived webhook and removed a part using the following manual patch
and after upgraded cnpg to latest version the kyverno policy part that update the crd didn't work anymore, so
here is my tricky solution for now
To follow up on @devthejo 's solution, you can use patchesJson6902 in the kyverno policy instead of using kubectl to patch. I wasn't able to get patchStrategicMerge to work.
Additionally, as @devthejo has called out, removing the second webhook from cnpg-mutating-webhook-configuration is required. Otherwise, the selector will not show up on the Cluster spec (the CNPG webhook overwrites it).
Finally, using "cnpg.io/cluster={{{{ request.object.metadata.name }}}}" as the selector is bad as this will also select any Pooler pods you are running. The role of the pod should be added also.
I have included our Kyverno policy to work around this limitation below:
@gbartolini I want to present a case for getting this into the roadmap for 1.25:
Vertical autoscaling is a really powerful feature, especially for databases where horizontal scaling isn't possible / practical. This would help CNPG reach parity with other operators and managed postgres services. This issue is in the top 10 most requested features (by 👍🏻 ) for CNPG currently.
The level of effort for the change should be low. This really only impacts the CRDs (though some logic will need to be added to keep the .spec.selector in sync).
This update is 100% backwards compatible.
Both @devthejo and I have verified that with the changes outlined above, the VPA integrates well.
Happy to take a crack at it but also want to get directional sign-off from a maintainer first.
@fullykubed I'd say just open a PR and reference this issue. I'm pretty sure the maintainers will be happy with the contribution 😊 And if they require any change you can always address it in the PR.
Activity
fullykubed commentedon Aug 12, 2023
More info on the implementation spec here.
phisco commentedon Aug 12, 2023
Good point! Looks like the only thing we are missing is the
selectorpathdevthejo commentedon Jun 7, 2024
Need this also. Can I propose a PR ?
devthejo commentedon Jun 7, 2024
Here is my workaround:
and my vpa:
and I can see the provided recommendations from the vpa
tada !!!
devthejo commentedon Jun 10, 2024
I finally had problem caused by this issue: #3753 so I reactived webhook and removed a part using the following manual patch
and after upgraded cnpg to latest version the kyverno policy part that update the crd didn't work anymore, so
here is my tricky solution for now
patches/cluster-crd.patch.yaml:[ { "op": "add", "path": "/spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/selector", "value": { "type": "string" }, }, { "op": "add", "path": "/spec/versions/0/subresources/scale/labelSelectorPath", "value": ".spec.selector", }, ]patches/webhook.patch.yaml:[{ "op": "remove", "path": "/webhooks/1" }]and in argocd applicationset set.templatate.spec:
and the new kyverno policy:
fullykubed commentedon Oct 26, 2024
@gbartolini Are you open to a PR here? I think above demonstrates this is just a small config change.
fullykubed commentedon Nov 13, 2024
To follow up on @devthejo 's solution, you can use
patchesJson6902in the kyverno policy instead of usingkubectlto patch. I wasn't able to getpatchStrategicMergeto work.Additionally, as @devthejo has called out, removing the second webhook from
cnpg-mutating-webhook-configurationis required. Otherwise, the selector will not show up on the Cluster spec (the CNPG webhook overwrites it).Finally, using
"cnpg.io/cluster={{{{ request.object.metadata.name }}}}"as the selector is bad as this will also select any Pooler pods you are running. The role of the pod should be added also.I have included our Kyverno policy to work around this limitation below:
fullykubed commentedon Nov 29, 2024
@gbartolini I want to present a case for getting this into the roadmap for 1.25:
Vertical autoscaling is a really powerful feature, especially for databases where horizontal scaling isn't possible / practical. This would help CNPG reach parity with other operators and managed postgres services. This issue is in the top 10 most requested features (by 👍🏻 ) for CNPG currently.
The level of effort for the change should be low. This really only impacts the CRDs (though some logic will need to be added to keep the
.spec.selectorin sync).This update is 100% backwards compatible.
Both @devthejo and I have verified that with the changes outlined above, the VPA integrates well.
Happy to take a crack at it but also want to get directional sign-off from a maintainer first.
fullykubed commentedon Dec 21, 2024
@gbartolini Wanted to circle back here to see if there were any thoughts here from the project maintainers.
I am happy to implement this if given the OK.
kaisoz commentedon Jan 7, 2025
@fullykubed I'd say just open a PR and reference this issue. I'm pretty sure the maintainers will be happy with the contribution 😊 And if they require any change you can always address it in the PR.
github-actions commentedon Mar 26, 2025
This issue is stale because it has been open for 60 days with no activity.
fullykubed commentedon Mar 26, 2025
Not stale
github-actions commentedon May 29, 2025
This issue is stale because it has been open for 60 days with no activity.
26 remaining items
sebv004 commentedon Jun 4, 2026
@Dosub
it's still revelant in v1.29.1.
feat: add label selector to the Cluster scale subresource (#8996)
feat: add label selector to the Cluster scale subresource (#8996)
feat: add label selector to the Cluster scale subresource (#8996)
feat: add label selector to the Cluster scale subresource (#8996)