Skip to content

feat: support customizable pod patches via annotations - #6323

Merged
mnencia merged 6 commits into
mainfrom
dev/json-patch-pod
Jan 31, 2025
Merged

mnencia merged 6 commits into
mainfrom
dev/json-patch-pod

Conversation

@armru

@armru armru commented Dec 12, 2024 •

Copy link
Copy Markdown
Member

This patch enables precise customization of pod specifications through the cnpg.io/podPatch annotation on clusters. By applying valid JSON patches, users can fine-tune pod configurations, including areas not directly configurable within the Cluster resource, offering greater flexibility for advanced use cases.

⚠️ WARNING: This feature may introduce discrepancies between the operator’s expectations and Kubernetes behavior. Use with caution and only as a last resort.

Closes #6234

Release notes

Added support for custom pod patches using the cnpg.io/podPatch annotation, enabling user-defined pod adjustments.

@armru armru added no-issue do not backport This PR must not be backported - it will be in the next minor release labels Dec 12, 2024
@armru
armru marked this pull request as ready for review December 18, 2024 16:42
@armru
armru requested a review from a team December 18, 2024 16:42
@armru
armru force-pushed the dev/json-patch-pod branch 2 times, most recently from 824e27b to 9d1187c Compare December 18, 2024 16:50
@armru armru changed the title wip: add pod jsonpatch capabilities feat: add pod jsonpatch capabilities Dec 18, 2024
@armru
armru force-pushed the dev/json-patch-pod branch from fd683c9 to bf524bc Compare January 7, 2025 13:48
@leonardoce

Copy link
Copy Markdown
Contributor

@leonardoce

Copy link
Copy Markdown
Contributor

E2e tests are green, this PR is fine to me!

@leonardoce leonardoce removed their assignment Jan 8, 2025
@mnencia
mnencia force-pushed the dev/json-patch-pod branch 2 times, most recently from 8fb1e7a to 868252f Compare January 31, 2025 08:44
@mnencia

mnencia commented Jan 31, 2025

Copy link
Copy Markdown
Member

/test d=push tl=4

@github-actions

Copy link
Copy Markdown
Contributor

@mnencia
mnencia force-pushed the dev/json-patch-pod branch from 868252f to 8e8f83d Compare January 31, 2025 08:46
@mnencia
mnencia force-pushed the dev/json-patch-pod branch from 8e8f83d to 94821fa Compare January 31, 2025 09:56
@mnencia mnencia changed the title feat: add pod jsonpatch capabilities feat: support customizable pod patches via annotations Jan 31, 2025
@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Jan 31, 2025
armru and others added 4 commits January 31, 2025 11:57
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
mnencia and others added 2 commits January 31, 2025 11:57
Signed-off-by: Gabriele Bartolini <[email protected]>
@mnencia
mnencia force-pushed the dev/json-patch-pod branch from b274a7a to 6d66ede Compare January 31, 2025 10:57
@mnencia
mnencia merged commit 02e4e4d into main Jan 31, 2025
@mnencia
mnencia deleted the dev/json-patch-pod branch January 31, 2025 11:00
usiegj00 added a commit to usiegj00/cloudnative-pg that referenced this pull request Oct 25, 2025
…list too long errors

This change sets enableServiceLinks to false in all bootstrap job pod specs
(initdb, join, recovery, etc.) to prevent the 'exec /manager: argument list
too long' error that occurs in namespaces with many services.

While PR cloudnative-pg#6323 fixed this issue for regular cluster instance pods by
introducing the cnpg.io/podPatch annotation, bootstrap jobs are created
separately and were not covered by that fix. Since these jobs use the same
bootstrap-controller init container that fails when receiving excessive
environment variables from Kubernetes service links, they experience the
same issue in high-density namespaces.

This issue was reported in a production environment with 465 PostgreSQL
databases in a single namespace, where the bootstrap controller in job pods
would fail to start during cluster initialization or when adding new replicas.

Bootstrap jobs do not require service discovery via environment variables
as they use DNS or explicit connection strings from secrets, making this
a safe default.

Fixes cloudnative-pg#6234

Signed-off-by: Jonathan Siegel <[email protected]>
usiegl00 pushed a commit to usiegl00/cloudnative-pg that referenced this pull request Nov 17, 2025
…list too long errors

This change sets enableServiceLinks to false in all bootstrap job pod specs
(initdb, join, recovery, etc.) to prevent the 'exec /manager: argument list
too long' error that occurs in namespaces with many services.

While PR cloudnative-pg#6323 fixed this issue for regular cluster instance pods by
introducing the cnpg.io/podPatch annotation, bootstrap jobs are created
separately and were not covered by that fix. Since these jobs use the same
bootstrap-controller init container that fails when receiving excessive
environment variables from Kubernetes service links, they experience the
same issue in high-density namespaces.

This issue was reported in a production environment with 465 PostgreSQL
databases in a single namespace, where the bootstrap controller in job pods
would fail to start during cluster initialization or when adding new replicas.

Bootstrap jobs do not require service discovery via environment variables
as they use DNS or explicit connection strings from secrets, making this
a safe default.

Fixes cloudnative-pg#6234

Signed-off-by: Jonathan Siegel <[email protected]>
mnencia pushed a commit to usiegj00/cloudnative-pg that referenced this pull request Jul 15, 2026
…list too long errors

This change sets enableServiceLinks to false in all bootstrap job pod specs
(initdb, join, recovery, etc.) to prevent the 'exec /manager: argument list
too long' error that occurs in namespaces with many services.

While PR cloudnative-pg#6323 fixed this issue for regular cluster instance pods by
introducing the cnpg.io/podPatch annotation, bootstrap jobs are created
separately and were not covered by that fix. Since these jobs use the same
bootstrap-controller init container that fails when receiving excessive
environment variables from Kubernetes service links, they experience the
same issue in high-density namespaces.

This issue was reported in a production environment with 465 PostgreSQL
databases in a single namespace, where the bootstrap controller in job pods
would fail to start during cluster initialization or when adding new replicas.

Bootstrap jobs do not require service discovery via environment variables
as they use DNS or explicit connection strings from secrets, making this
a safe default.

Fixes cloudnative-pg#6234

Signed-off-by: Jonathan Siegel <[email protected]>
usiegj00 added a commit to usiegj00/cloudnative-pg that referenced this pull request Jul 16, 2026
Extend the enableServiceLinks=false default from bootstrap jobs to the
PostgreSQL instance pods.

Setting EnableServiceLinks to false on the instance PodSpec built by
createClusterPodSpec prevents the "exec /manager: argument list too long"
error in namespaces with many services, without relying on the
cnpg.io/podPatch annotation workaround from cloudnative-pg#6323. Also aligns the
service-links field formatting in the bootstrap job spec.

Signed-off-by: Jonathan Siegel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release no-issue ok to merge 👌 This PR can be merged

Development

Successfully merging this pull request may close these issues.

[Bug]: "exec /manager: argument list too long" in bootstrap-controller

5 participants