Skip to content

feat(helm): add more specificity to affinity and topology spread constraints (#17404) - #19061

Merged
JStickler merged 3 commits into
grafana:mainfrom
TomHellier:17404-add-more-specificity-to-affinity-and-topology-spread-constraints
Sep 3, 2025
Merged

feat(helm): add more specificity to affinity and topology spread constraints (#17404)#19061
JStickler merged 3 commits into
grafana:mainfrom
TomHellier:17404-add-more-specificity-to-affinity-and-topology-spread-constraints

Conversation

@TomHellier

@TomHellier TomHellier commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

This commit allows templating in the affinity and topology spread constraints, and updates the values to be more specific about the app.kubernetes.io/instance and app.kubernetes.io/name kubernetes recommended labels.

When deploying into a cluster with a low number of nodes, or a cluster with the app.kubernetes.io/component label already used extensively, you cannot place these pods. If we want them to be scheduled apart, we should be more specific with the label selector.

This follows on from the draft PR #17405

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #17404

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR
@TomHellier
TomHellier requested a review from a team as a code owner August 29, 2025 09:13
@CLAassistant

CLAassistant commented Aug 29, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch from f271766 to b459b42 Compare August 29, 2025 09:17
@TomHellier TomHellier changed the title fix: add more specificity to affinity and topology spread constraints (#17404) Aug 29, 2025
@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch from b459b42 to 00a8f8c Compare August 29, 2025 09:27
@TomHellier

Copy link
Copy Markdown
Contributor Author

Hi @jkroepke - would you mind reviewing this please :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- tpl (.Values.adminApi.topologySpreadConstraints | toYaml) . | nindent 8 }}
{{- tpl (. | toYaml) $ | nindent 8 }}

this should work, too and we can keep the with. Right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkroepke - yeah thats much better than what I've done initially, thanks, I've updated the PR

@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch 2 times, most recently from 5889619 to ed3c4ef Compare August 29, 2025 13:54
@JStickler JStickler changed the title feat: add more specificity to affinity and topology spread constraints (#17404) Aug 29, 2025
@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch from ed3c4ef to 6d9beba Compare August 29, 2025 19:40
Comment thread production/helm/loki/Chart.yaml Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry - I don't know if I should update this or whether you should do it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI automation updates the version, you don't need to do it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've reverted this change (and associated doc change).

@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch from 6d9beba to 2c92c25 Compare August 29, 2025 20:00

@jkroepke jkroepke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomHellier

Copy link
Copy Markdown
Contributor Author

I'm not convinced that failing test is related to this PR, it passed last time.

@jkroepke

jkroepke commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

try update from main @TomHellier

grafana#17404)

This commit allows templating in the affinity and topology spread constraints, and updates the values to be more specific about the app.kubernetes.io/instance and app.kubernetes.io/name kubernetes recommended label.

When deploying into a cluster with a low number of nodes, or a cluster with the app.kubernetes.io/component label already used extensively, you cannot place these pods. If we want them to be scheduled apart, we should be more specific with the label selector.

This follows on from the draft PR grafana#17405
@TomHellier
TomHellier force-pushed the 17404-add-more-specificity-to-affinity-and-topology-spread-constraints branch from 2c92c25 to 28627d5 Compare September 2, 2025 19:47
@TomHellier

Copy link
Copy Markdown
Contributor Author

@jkroepke I've rebased onto main

…opology-spread-constraints

Signed-off-by: Jay Clifford <45856600+Jayclifford345@users.noreply.github.com>

@Jayclifford345 Jayclifford345 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

…opology-spread-constraints

Signed-off-by: J Stickler <julie.stickler@grafana.com>
@JStickler
JStickler merged commit 0819e48 into grafana:main Sep 3, 2025
80 checks passed
@eraac

eraac commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Great feature, but it seems the memcached template didn't include the necessary changes to use the syntax '{{ .Release.Name }}' within the topologySpreadConstraints/affinity. Is this intentional?

@TomHellier

Copy link
Copy Markdown
Contributor Author

@eraac, it was missed unintentionally. I've disabled memcached in my instances of loki, and the helm charts are structured slightly differently so didn't come up when I grepped the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6 participants