Juju does not add pod affinity to pods when specifying tags in constraints

Bug #1970991 reported by Stone Preston
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Ian Booth

Bug Description

According to this post: https://discourse.charmhub.io/t/pod-priority-and-affinity-in-juju-charms/4091/6, juju should add node affinities to pods when specifying tags in the constraints in the form of node.key=value. This does not happen:

$ juju deploy hello-kubecon --constraints "tags=node.some-label=some-value"`

$ kubectl get -o json statefulset.apps/hello-kubecon -n repro-model | jq .spec.template.spec.affinity

The above was tested on juju 2.9.28 and k8s 1.23 and 1.24 clusters.

The spec template does not have any affinity. I really need to be able to deploy a charm to a specific k8s node, either via node affinity or node selector. Is there another way for juju to accomplish this?

description: updated
description: updated
description: updated
Revision history for this message
Stone Preston (stonepreston) wrote :

A workaround for this issue is to patch the statefulset with a node-selector (or nodeAffinity depending on how complex the rules required are for scheduling).

$ kubectl patch statefulset hello-kubecon -p '{"spec": {"template": {"spec": {"nodeSelector": {"some-label": "some-value"}}}}}' -n repro-model

Revision history for this message
Ian Booth (wallyworld) wrote :

I think the affinity constraints only work with the original podspec charms and the implementation needs to be ported across to sidecar charms.

Changed in juju:
importance: Undecided → High
status: New → Triaged
milestone: none → 2.9-next
Ian Booth (wallyworld)
Changed in juju:
milestone: 2.9-next → none
Revision history for this message
Ian Booth (wallyworld) wrote :

Just a follow up on this, support for affinity with sidecar charms landed a while back.
It's in juju 3.3 and later.

Changed in juju:
assignee: nobody → Ian Booth (wallyworld)
status: Triaged → Fix Committed
milestone: none → 3.3.5
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.