zncdatadev / trino-operator

Operator for Trino, the distributed SQL query engine for big data
Apache License 2.0
3 stars 5 forks source link

[Feature]: Use default affinity Rules if none specified #82

Closed lwpk110 closed 1 month ago

lwpk110 commented 1 month ago

Duplicates

Summary 💡

  1. When creating workload resources (e.g. Deployment, StatefulSet etc.), default affinity rules will be used for scheduling if no affinity or anti-affinity rules are specified.
  2. The default affinity rules will group nodes and schedule pods to different nodes within the same group, avoiding putting everything on one machine. The default number of groups can be configured but no more than half the total number of machines.
  3. Users can still specify their own detailed affinity rules if needed. The system will ignore the default affinity rules if any rules are specified.

Examples 🌈

    spec:
      affinity:
        podAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/Name: trinocluster-sample
              topologyKey: kubernetes.io/hostname
            weight: 20
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/Name: trinocluster-sample
                  app.kubernetes.io/component: coordinator
              topologyKey: kubernetes.io/hostname
            weight: 70

Motivation 🔦

Currently when creating workload resources like Deployments without specifying any affinity rules, it may lead to unbalanced resource distribution or difficulty in tracking resources. Adding default affinity rules can reduce user errors and better manage resource allocation.