Pod Priority and Affinity in juju/charms

Hi,

I was wondering what the approach was with regards to affinity and anti-affinity of containers within juju. I had a couple of questions:

  • How can I set affinity/anti-affinity in juju?
  • How can I set pod priority in juju?
  • Would it be the charm a charm option or a juju option?
  • How can I create a charm which takes advantage these features?

Cheers for the help
Peter

One mechanism via which affinity/anti-affinity is currently supported via tag constraints.

juju deploy foo --constraints="tags=foo=a|b|c,^bar=d|e|f"

would result in a pod with an node selector expression of “foo in a|b|c” and "bar not in “d|e|f”.

Zone constraints, if specifed, map to a node selector with key
failure-domain.beta.kubernetes.io/zone

Currently, constraints are a deploy time option; Juju doesn’t support the concept of charm constraints as a thing (although we have talked about it at various times).

Pod priority is simply a vale in the pod spec

...
kubernetesResources:
  pod:
    priorityClassName: system-cluster-critical
    priority: 2000000000

Great thanks @wallyworld!