From d26e906191c5d91c89cc6b4ed09d2ef11d222235 Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Tue, 14 Mar 2017 17:46:16 -0700 Subject: [PATCH 1/2] Apply taint tolerations for NoExecute for all static pods. --- pkg/kubelet/config/common.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/kubelet/config/common.go b/pkg/kubelet/config/common.go index d53751bf3ad..ae594fec221 100644 --- a/pkg/kubelet/config/common.go +++ b/pkg/kubelet/config/common.go @@ -73,6 +73,15 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName types.Node // The generated UID is the hash of the file. pod.Annotations[kubetypes.ConfigHashAnnotationKey] = string(pod.UID) + if isFile { + // Applying the default Taint tolerations to static pods, + // so they are not evicted when there are node problems. + api.AddOrUpdateTolerationInPod(pod, &api.Toleration{ + Operator: "Exists", + Effect: api.TaintEffectNoExecute, + }) + } + // Set the default status to pending. pod.Status.Phase = api.PodPending return nil From d419efbe7186a2c0fcb6c4a056794a7b137cde5d Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Fri, 17 Mar 2017 14:06:34 -0700 Subject: [PATCH 2/2] Fix unittest reflecting the default taint tolerations change for static pods. --- pkg/kubelet/config/file_linux_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/kubelet/config/file_linux_test.go b/pkg/kubelet/config/file_linux_test.go index eae27c4660d..387c112c6a8 100644 --- a/pkg/kubelet/config/file_linux_test.go +++ b/pkg/kubelet/config/file_linux_test.go @@ -208,6 +208,10 @@ func getTestCases(hostname types.NodeName) []*testCase { RestartPolicy: v1.RestartPolicyAlways, DNSPolicy: v1.DNSClusterFirst, TerminationGracePeriodSeconds: &grace, + Tolerations: []v1.Toleration{{ + Operator: "Exists", + Effect: "NoExecute", + }}, Containers: []v1.Container{{ Name: "image", Image: "test/image",