kubeadm: set priority for "system-node-critical" Pods

Priority is normally set by the admission controller when missing.
For static pods there seems to be some corner cases, as, if priority
is not explicitly set, Graceful Node Shutdown will shutdown
static pods with the other pods that have priority 0 or unset.

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
This commit is contained in:
Etienne Champetier 2022-12-07 10:24:48 -05:00
parent 4db6bde859
commit 64eef3e9fa
2 changed files with 6 additions and 0 deletions

View File

@ -56,6 +56,8 @@ var (
// ComponentPod returns a Pod object from the container, volume and annotations specifications // ComponentPod returns a Pod object from the container, volume and annotations specifications
func ComponentPod(container v1.Container, volumes map[string]v1.Volume, annotations map[string]string) v1.Pod { func ComponentPod(container v1.Container, volumes map[string]v1.Volume, annotations map[string]string) v1.Pod {
// priority value for system-node-critical class
priority := int32(2000001000)
return v1.Pod{ return v1.Pod{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
APIVersion: "v1", APIVersion: "v1",
@ -71,6 +73,7 @@ func ComponentPod(container v1.Container, volumes map[string]v1.Volume, annotati
}, },
Spec: v1.PodSpec{ Spec: v1.PodSpec{
Containers: []v1.Container{container}, Containers: []v1.Container{container},
Priority: &priority,
PriorityClassName: "system-node-critical", PriorityClassName: "system-node-critical",
HostNetwork: true, HostNetwork: true,
Volumes: VolumeMapToSlice(volumes), Volumes: VolumeMapToSlice(volumes),

View File

@ -392,6 +392,8 @@ func TestGetEtcdProbeEndpoint(t *testing.T) {
} }
func TestComponentPod(t *testing.T) { func TestComponentPod(t *testing.T) {
// priority value for system-node-critical class
priority := int32(2000001000)
var tests = []struct { var tests = []struct {
name string name string
expected v1.Pod expected v1.Pod
@ -419,6 +421,7 @@ func TestComponentPod(t *testing.T) {
Name: "foo", Name: "foo",
}, },
}, },
Priority: &priority,
PriorityClassName: "system-node-critical", PriorityClassName: "system-node-critical",
HostNetwork: true, HostNetwork: true,
Volumes: []v1.Volume{}, Volumes: []v1.Volume{},