mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #87871 from msau42/fix-hostexec
Use NodeSelector instead of NodeName in hostexec Pod
This commit is contained in:
commit
dc8208dddc
@ -79,3 +79,11 @@ func SetAffinity(nodeSelection *NodeSelection, nodeName string) {
|
||||
func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string) {
|
||||
setNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpNotIn, nodeName)
|
||||
}
|
||||
|
||||
// SetNodeAffinity modifies the given pod object with
|
||||
// NodeAffinity to the given node name.
|
||||
func SetNodeAffinity(pod *v1.Pod, nodeName string) {
|
||||
nodeSelection := &NodeSelection{}
|
||||
SetAffinity(nodeSelection, nodeName)
|
||||
pod.Spec.Affinity = nodeSelection.Affinity
|
||||
}
|
||||
|
@ -73,9 +73,14 @@ func (h *hostExecutor) launchNodeExecPod(node string) *v1.Pod {
|
||||
f := h.Framework
|
||||
cs := f.ClientSet
|
||||
ns := f.Namespace
|
||||
|
||||
hostExecPod := e2epod.NewExecPodSpec(ns.Name, "", true)
|
||||
hostExecPod.GenerateName = fmt.Sprintf("hostexec-%s-", node)
|
||||
hostExecPod.Spec.NodeName = node
|
||||
// Use NodeAffinity instead of NodeName so that pods will not
|
||||
// be immediately Failed by kubelet if it's out of space. Instead
|
||||
// Pods will be pending in the scheduler until there is space freed
|
||||
// up.
|
||||
e2epod.SetNodeAffinity(hostExecPod, node)
|
||||
hostExecPod.Spec.Volumes = []v1.Volume{
|
||||
{
|
||||
// Required to enter into host mount namespace via nsenter.
|
||||
|
Loading…
Reference in New Issue
Block a user