charts icon indicating copy to clipboard operation
charts copied to clipboard

[common] Add affinity to common chart

Open alexmorbo opened this issue 1 year ago • 11 comments

Is your feature request related to a problem?

I use some charts from truecharts in my home k8s cluster with some nodes. I need not to schedule some apps to nodes, which got gpu. So affinity is the best way to do this.

Describe the solution you'd like

  {{- with .Values.affinity }}
  affinity:
    {{- toYaml . | nindent 8 }}
  {{- end }}

And in chart something like this:

affinity = {
      nodeAffinity = {
        requiredDuringSchedulingIgnoredDuringExecution = {
          nodeSelectorTerms = [
            {
              matchExpressions = [
                {
                  key = "node.home.lab/capability"
                  operator = "NotIn"
                  values = ["gpu"]
                },
                {
                  key = "home.lab/proxmox-node"
                  operator = "In"
                  values = ["r730xd-1"]
                }
              ]
            }
          ]
        }
      }
    }

Describe alternatives you've considered

I tried:

node_selector = {
    "home.lab/proxmox-node" = "r730xd-1",
    "home.lab/has-gpu-node" = "false"
  }

but got error:

json: cannot unmarshal bool into Go struct field PodSpec.spec.template.spec.nodeSelector of type string

Additional context

I found, that it was in plan, but not realized in https://github.com/truecharts/charts/issues/2266

Thanks

I've read and agree with the following

  • [X] I've checked all open and closed issues and my request is not there.
  • [X] I've checked all open and closed pull requests and my request is not there.

alexmorbo avatar Jun 06 '24 19:06 alexmorbo