mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Change our tests to ensure that critical system pods are created in the system namespace
This commit is contained in:
parent
28df1f0d0c
commit
0daedee0de
@ -47,6 +47,7 @@ var masterNodes sets.String
|
|||||||
|
|
||||||
type pausePodConfig struct {
|
type pausePodConfig struct {
|
||||||
Name string
|
Name string
|
||||||
|
Namespace string
|
||||||
Affinity *v1.Affinity
|
Affinity *v1.Affinity
|
||||||
Annotations, Labels, NodeSelector map[string]string
|
Annotations, Labels, NodeSelector map[string]string
|
||||||
Resources *v1.ResourceRequirements
|
Resources *v1.ResourceRequirements
|
||||||
@ -602,9 +603,11 @@ var _ = SIGDescribe("SchedulerPredicates [Serial]", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
func initPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
func initPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
||||||
|
var gracePeriod = int64(1)
|
||||||
pod := &v1.Pod{
|
pod := &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: conf.Name,
|
Name: conf.Name,
|
||||||
|
Namespace: conf.Namespace,
|
||||||
Labels: conf.Labels,
|
Labels: conf.Labels,
|
||||||
Annotations: conf.Annotations,
|
Annotations: conf.Annotations,
|
||||||
OwnerReferences: conf.OwnerReferences,
|
OwnerReferences: conf.OwnerReferences,
|
||||||
@ -622,6 +625,7 @@ func initPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
|||||||
Tolerations: conf.Tolerations,
|
Tolerations: conf.Tolerations,
|
||||||
NodeName: conf.NodeName,
|
NodeName: conf.NodeName,
|
||||||
PriorityClassName: conf.PriorityClassName,
|
PriorityClassName: conf.PriorityClassName,
|
||||||
|
TerminationGracePeriodSeconds: &gracePeriod,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if conf.Resources != nil {
|
if conf.Resources != nil {
|
||||||
@ -631,7 +635,11 @@ func initPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
func createPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
||||||
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(initPausePod(f, conf))
|
namespace := conf.Namespace
|
||||||
|
if len(namespace) == 0 {
|
||||||
|
namespace = f.Namespace.Name
|
||||||
|
}
|
||||||
|
pod, err := f.ClientSet.CoreV1().Pods(namespace).Create(initPausePod(f, conf))
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
@ -639,7 +647,7 @@ func createPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
|||||||
func runPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
func runPausePod(f *framework.Framework, conf pausePodConfig) *v1.Pod {
|
||||||
pod := createPausePod(f, conf)
|
pod := createPausePod(f, conf)
|
||||||
framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.ClientSet, pod))
|
framework.ExpectNoError(framework.WaitForPodRunningInNamespace(f.ClientSet, pod))
|
||||||
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(conf.Name, metav1.GetOptions{})
|
pod, err := f.ClientSet.CoreV1().Pods(pod.Namespace).Get(conf.Name, metav1.GetOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ var _ = SIGDescribe("SchedulerPreemption [Serial] [Feature:PodPreemption]", func
|
|||||||
// Create a critical pod and make sure it is scheduled.
|
// Create a critical pod and make sure it is scheduled.
|
||||||
runPausePod(f, pausePodConfig{
|
runPausePod(f, pausePodConfig{
|
||||||
Name: "critical-pod",
|
Name: "critical-pod",
|
||||||
|
Namespace: metav1.NamespaceSystem,
|
||||||
PriorityClassName: scheduling.SystemClusterCritical,
|
PriorityClassName: scheduling.SystemClusterCritical,
|
||||||
Resources: &v1.ResourceRequirements{
|
Resources: &v1.ResourceRequirements{
|
||||||
Requests: podRes,
|
Requests: podRes,
|
||||||
@ -183,6 +184,9 @@ var _ = SIGDescribe("SchedulerPreemption [Serial] [Feature:PodPreemption]", func
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
Expect(livePod.DeletionTimestamp).To(BeNil())
|
Expect(livePod.DeletionTimestamp).To(BeNil())
|
||||||
}
|
}
|
||||||
|
// Clean-up the critical pod
|
||||||
|
err = f.ClientSet.CoreV1().Pods(metav1.NamespaceSystem).Delete("critical-pod", metav1.NewDeleteOptions(0))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
// This test verifies that when a high priority pod is pending and its
|
// This test verifies that when a high priority pod is pending and its
|
||||||
@ -334,10 +338,14 @@ var _ = SIGDescribe("PodPriorityResolution [Serial] [Feature:PodPreemption]", fu
|
|||||||
for i, spc := range systemPriorityClasses {
|
for i, spc := range systemPriorityClasses {
|
||||||
pod := createPausePod(f, pausePodConfig{
|
pod := createPausePod(f, pausePodConfig{
|
||||||
Name: fmt.Sprintf("pod%d-%v", i, spc),
|
Name: fmt.Sprintf("pod%d-%v", i, spc),
|
||||||
|
Namespace: metav1.NamespaceSystem,
|
||||||
PriorityClassName: spc,
|
PriorityClassName: spc,
|
||||||
})
|
})
|
||||||
Expect(pod.Spec.Priority).NotTo(BeNil())
|
Expect(pod.Spec.Priority).NotTo(BeNil())
|
||||||
framework.Logf("Created pod: %v", pod.Name)
|
framework.Logf("Created pod: %v", pod.Name)
|
||||||
|
// Clean-up the pod.
|
||||||
|
err := f.ClientSet.CoreV1().Pods(pod.Namespace).Delete(pod.Name, metav1.NewDeleteOptions(0))
|
||||||
|
framework.ExpectNoError(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -60,7 +60,6 @@ spec:
|
|||||||
annotations:
|
annotations:
|
||||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||||
spec:
|
spec:
|
||||||
priorityClassName: system-cluster-critical
|
|
||||||
tolerations:
|
tolerations:
|
||||||
- key: "CriticalAddonsOnly"
|
- key: "CriticalAddonsOnly"
|
||||||
operator: "Exists"
|
operator: "Exists"
|
||||||
|
Loading…
Reference in New Issue
Block a user