Dynatrace / dynatrace-operator

Automate Kubernetes observability with Dynatrace
https://www.dynatrace.com
Apache License 2.0
168 stars 136 forks source link

Add affinity support for DT oneAgent #2427

Open a7vicky opened 10 months ago

a7vicky commented 10 months ago

Is your feature request related to a problem? Please describe.

Since oneAgent is daemonset and daemonset supports affinity for pod's scheduling constraints, This would be nice to give users the flexibility to use matchExpressions to schedule pods on the desired nodes.

→ kubectl explain ds.spec.template.spec.affinity --recursive

KIND:     DaemonSet
VERSION:  apps/v1

RESOURCE: affinity <Object>

DESCRIPTION:
     If specified, the pod's scheduling constraints

     Affinity is a group of affinity scheduling rules.

FIELDS:
   nodeAffinity <Object>
      preferredDuringSchedulingIgnoredDuringExecution   <[]Object>
         preference <Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchFields <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
         weight <integer>
      requiredDuringSchedulingIgnoredDuringExecution    <Object>
         nodeSelectorTerms  <[]Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchFields <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
   podAffinity  <Object>
      preferredDuringSchedulingIgnoredDuringExecution   <[]Object>
         podAffinityTerm    <Object>
            labelSelector   <Object>
               matchExpressions <[]Object>
                  key   <string>
                  operator  <string>
                  values    <[]string>
               matchLabels  <map[string]string>
            namespaceSelector   <Object>
               matchExpressions <[]Object>
                  key   <string>
                  operator  <string>
                  values    <[]string>
               matchLabels  <map[string]string>
            namespaces  <[]string>
            topologyKey <string>
         weight <integer>
      requiredDuringSchedulingIgnoredDuringExecution    <[]Object>
         labelSelector  <Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchLabels <map[string]string>
         namespaceSelector  <Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchLabels <map[string]string>
         namespaces <[]string>
         topologyKey    <string>
   podAntiAffinity  <Object>
      preferredDuringSchedulingIgnoredDuringExecution   <[]Object>
         podAffinityTerm    <Object>
            labelSelector   <Object>
               matchExpressions <[]Object>
                  key   <string>
                  operator  <string>
                  values    <[]string>
               matchLabels  <map[string]string>
            namespaceSelector   <Object>
               matchExpressions <[]Object>
                  key   <string>
                  operator  <string>
                  values    <[]string>
               matchLabels  <map[string]string>
            namespaces  <[]string>
            topologyKey <string>
         weight <integer>
      requiredDuringSchedulingIgnoredDuringExecution    <[]Object>
         labelSelector  <Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchLabels <map[string]string>
         namespaceSelector  <Object>
            matchExpressions    <[]Object>
               key  <string>
               operator <string>
               values   <[]string>
            matchLabels <map[string]string>
         namespaces <[]string>
         topologyKey    <string>

Describe the solution you'd like Extend dynakube CRD fields to add affinity for oneAgnet daemonset and the dynatrace-operator creates daemonset using these fields.

Describe alternatives you've considered nodeSelector: This is not a solution in our case because the label we want to use is dynamically added by the controller and the value for that label is not constant.

mfabricanti commented 7 months ago

Up!

I need to monitor only a few nodes of a cluster. It would be nice to have the hability to use nodeAfinity for OneAgent.