Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow matchExpressions as part of podSelector when defining scheduling policies #74

Closed
ashwani2k opened this issue Oct 1, 2024 · 1 comment
Labels
kind/enhancement Enhancement, improvement, extension status/closed Issue is closed (either delivered or triaged)

Comments

@ashwani2k
Copy link
Contributor

What would you like to be added:
We would like Kupid to support matching Expressions along with matchLables in the podSelector for apply the scheduling policies.

Why is this needed:
Sometimes the podSelector is not sufficient and would like to give an expression to match.
Currently its not possible to achieve this as Kupid templates only parse podLabels as described in the template.

Proposal is to allow matching of expressions as well which can be defined in a section named podExpressions as described below:

     etcd-main:
        namespaceLabels: {}
        podLabels:
          app: etcd-statefulset
          role: main
        podExpressions:
        - key: networking.resources.gardener.cloud/to-etcd-main-client-tcp-2379
          operator: DoesNotExist
        nodeLabels:
          pool.worker.gardener.cloud/dedicated-for: etcd
        tolerations:
        - key: pool.worker.gardener.cloud/dedicated-for
          operator: Equal
          value: etcd
          effect: NoExecute       

This gets realized the policy as following:

apiVersion: kupid.gardener.cloud/v1alpha1
kind: ClusterPodSchedulingPolicy
metadata:
  annotations:
    resources.gardener.cloud/description: |-
      DO NOT EDIT - This resource is managed by gardener-resource-manager.
      Any modifications are discarded and the resource is returned to the original state.
    resources.gardener.cloud/origin: garden/kupid-55stp
  creationTimestamp: "2024-10-01T02:37:26Z"
  generation: 1
  labels:
    app.kubernetes.io/instance: kupid
    app.kubernetes.io/name: kupid-policy-etcd-main
    resources.gardener.cloud/managed-by: gardener
  name: kupid-policy-etcd-main
  resourceVersion: "9659305"
  uid: bbbdcb47-3ad3-4232-911c-c0efa72f56d8
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: pool.worker.gardener.cloud/dedicated-for
            operator: In
            values:
            - etcd
  namespaceSelector: {}
  podSelector:
    matchExpressions:
    - key: networking.resources.gardener.cloud/to-etcd-main-client-tcp-2379
      operator: DoesNotExist
    matchLabels:
      app: etcd-statefulset
      role: main
  tolerations:
  - effect: NoExecute
    key: pool.worker.gardener.cloud/dedicated-for
    operator: Equal
    value: etcd
@ashwani2k ashwani2k added the kind/enhancement Enhancement, improvement, extension label Oct 1, 2024
@shreyas-s-rao
Copy link
Contributor

/close with merge of #73

@gardener-robot gardener-robot added the status/closed Issue is closed (either delivered or triaged) label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancement, improvement, extension status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

No branches or pull requests

3 participants