mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Make Daemons tolerate NoExecute taints correctly
This commit is contained in:
		@@ -22,16 +22,37 @@ import (
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/v1"
 | 
			
		||||
	v1helper "k8s.io/kubernetes/pkg/api/v1/helper"
 | 
			
		||||
	podutil "k8s.io/kubernetes/pkg/api/v1/pod"
 | 
			
		||||
	extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
			
		||||
	labelsutil "k8s.io/kubernetes/pkg/util/labels"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GetPodTemplateWithHash returns copy of provided template with additional
 | 
			
		||||
// label which contains hash of provided template
 | 
			
		||||
// label which contains hash of provided template and sets default daemon tolerations.
 | 
			
		||||
func GetPodTemplateWithGeneration(template v1.PodTemplateSpec, generation int64) v1.PodTemplateSpec {
 | 
			
		||||
	obj, _ := api.Scheme.DeepCopy(template)
 | 
			
		||||
	newTemplate := obj.(v1.PodTemplateSpec)
 | 
			
		||||
	// DaemonSet pods shouldn't be deleted by NodeController in case of node problems.
 | 
			
		||||
	// Add infinite toleration for taint notReady:NoExecute here
 | 
			
		||||
	// to survive taint-based eviction enforced by NodeController
 | 
			
		||||
	// when node turns not ready.
 | 
			
		||||
	v1helper.AddOrUpdateTolerationInPodSpec(&newTemplate.Spec, &v1.Toleration{
 | 
			
		||||
		Key:      metav1.TaintNodeNotReady,
 | 
			
		||||
		Operator: v1.TolerationOpExists,
 | 
			
		||||
		Effect:   v1.TaintEffectNoExecute,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	// DaemonSet pods shouldn't be deleted by NodeController in case of node problems.
 | 
			
		||||
	// Add infinite toleration for taint unreachable:NoExecute here
 | 
			
		||||
	// to survive taint-based eviction enforced by NodeController
 | 
			
		||||
	// when node turns unreachable.
 | 
			
		||||
	v1helper.AddOrUpdateTolerationInPodSpec(&newTemplate.Spec, &v1.Toleration{
 | 
			
		||||
		Key:      metav1.TaintNodeUnreachable,
 | 
			
		||||
		Operator: v1.TolerationOpExists,
 | 
			
		||||
		Effect:   v1.TaintEffectNoExecute,
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	templateGenerationStr := fmt.Sprint(generation)
 | 
			
		||||
	newTemplate.ObjectMeta.Labels = labelsutil.CloneAndAddLabel(
 | 
			
		||||
		template.ObjectMeta.Labels,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user