Skip to content

Commit

Permalink
fix: prefer scheduling the csi controller on cloud nodes (#786)
Browse files Browse the repository at this point in the history
This is only a partial fix, but in clusters where the
`instance.hetzner.cloud/provided-by` label is present and set
accordingly for cloud nodes it prevents the controller from being
scheduled on non cloud nodes. We need this, as in our default behavior
for fetching the default volume location we rely on the node name being
a Hetzner cloud.
  • Loading branch information
lukasmetzner authored Nov 21, 2024
1 parent bb348f2 commit 63cd777
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions chart/.snapshots/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ spec:
spec:
serviceAccountName: hcloud-csi-controller

affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: instance.hetzner.cloud/provided-by
operator: In
values:
- cloud
weight: 1
securityContext:
fsGroup: 1001
initContainers:
Expand Down
9 changes: 9 additions & 0 deletions chart/.snapshots/example-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ spec:
serviceAccountName: hcloud-csi-controller

affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference:
matchExpressions:
- key: instance.hetzner.cloud/provided-by
operator: In
values:
- cloud
weight: 1
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
Expand Down
13 changes: 12 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,19 @@ controller:

## @param controller.affinity Affinity for controller pods assignment
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
## If not otherwise configured, we retrieve the default location for volumes by the location of the node where the controller is scheduled.
## For this reason we preferably want to schedule the controller on a cloud node.
##
affinity: {}
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: "instance.hetzner.cloud/provided-by"
operator: In
values:
- "cloud"

## @param controller.nodeSelector Node labels for controller pods assignment
## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
Expand Down
10 changes: 10 additions & 0 deletions deploy/kubernetes/hcloud-csi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 63cd777

Please sign in to comment.