Skip to content

Allow more comprehensive affinity config#5285

Merged
jsjoeio merged 2 commits into
coder:mainfrom
strowk:allow-affinity-config
Jul 18, 2022
Merged

Allow more comprehensive affinity config#5285
jsjoeio merged 2 commits into
coder:mainfrom
strowk:allow-affinity-config

Conversation

@strowk

@strowk strowk commented Jun 21, 2022

Copy link
Copy Markdown

This PR changes helm template to allow more comprehensive configuration in affinity. Instead of treating affinity as a static map, it expects a string passed there, which would be then processed as a template and therefore resolve any links, such as f.e. {{ include "code-server.name" . }} .
This then allows to configure something like this:

affinity: |
  podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: app.kubernetes.io/name
              operator: In
              values:
              - {{ include "code-server.name" . }}
          topologyKey: kubernetes.io/hostname

Above allows to properly spread pods over nodes without hardcoding any labels in values file.

This approach is somewhat common in helm ecosystem, f.e. see here:
https://github.com/codecentric/helm-charts/blob/31f44ca368cef7585760edc8f22c011cab1be284/charts/keycloakx/templates/statefulset.yaml#L184

The change is breaking though, so I am not 100 percent sure this has to be included, I am sending this as a suggestion and input for discussion.

@jsjoeio

jsjoeio commented Jun 21, 2022

Copy link
Copy Markdown
Contributor

cc @bpmct @Matthew-Beckett

@bpmct bpmct left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems good to me, I did some digging and this does indeed look like a common practice. I also think it's fine to push a breaking change given we don't publish our helm charts anywhere and they are manually pulled.

However, will defer to @Matthew-Beckett to review and approve.

@Matthew-Beckett Matthew-Beckett 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!

@jsjoeio jsjoeio enabled auto-merge (squash) July 18, 2022 19:00
@jsjoeio jsjoeio self-assigned this Jul 18, 2022
@jsjoeio jsjoeio added this to the 4.5.1 milestone Jul 18, 2022
@jsjoeio jsjoeio disabled auto-merge July 18, 2022 21:38
@jsjoeio jsjoeio merged commit de317a0 into coder:main Jul 18, 2022
@jsjoeio jsjoeio mentioned this pull request Jul 18, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants