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

Enforce same node when turning K8s Scheduler on for Workflow Pods #201

Open
BerndFarkaDyna opened this issue Jan 22, 2025 · 2 comments
Open

Comments

@BerndFarkaDyna
Copy link

What would you like added?

As described here: #111 (comment), a workflow pod can currently be placed on any Node of the given K8s cluster. I want to enforce having the pod scheduled via K8s Schedule on the same node.

Why is this needed?

Currently, there are 2 Options with various downsides:

I suggest extending the "useK8sScheduler" option to generate podAfinities into this functionality. It should be rather straightforward to force the K8s Scheduler the pod on the same Node. The benefit is that if there are not enough resources on this node (at the moment of pod creation), the pod will go into a Pending state and will not fail.

Additional context

This could be easily achieved via a PodAfinity on the "hostname" label, which should be available by default on all K8s Distributions.

@BerndFarkaDyna
Copy link
Author

BerndFarkaDyna commented Jan 22, 2025

I would be open to contributing something similar like that snipplet to https://github.com/actions/runner-container-hooks/blob/main/packages/k8s/src/k8s/index.ts#L98

  if (useKubeScheduler()) {
    const affinity = new k8s.V1Affinity()
    affinity.nodeAffinity = new k8s.V1NodeAffinity()
    const nodeSelector = new k8s.V1NodeSelector()

    const term = new k8s.V1NodeSelectorTerm()
    const req = new k8s.V1NodeSelectorRequirement()
    req.key = 'kubernetes.io/hostname'
    req.values = [await getCurrentNodeName()]
    req.operator = 'IN'
    term.matchExpressions = [req]
    nodeSelector.nodeSelectorTerms = [term]
    affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution =
      nodeSelector
    appPod.spec.affinity = affinity
  } else {
    appPod.spec.nodeName = await getCurrentNodeName()
  }

Please share some feedback or ideas on that problem; Thanks a lot in advance

@BerndFarkaDyna
Copy link
Author

BerndFarkaDyna commented Jan 27, 2025

@mzagozen / @pje / @chrispat / @DanRigby / @joshmgross : may I kindly ask you for feedback on this Feature Request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant