mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	kubelet: introduce --protect-kernel-defaults to make the KernelTunableBehavior configurable
This commit is contained in:
		@@ -181,4 +181,5 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
 | 
			
		||||
	fs.Int32Var(&s.EvictionMaxPodGracePeriod, "eviction-max-pod-grace-period", s.EvictionMaxPodGracePeriod, "Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.  If negative, defer to pod specified value.")
 | 
			
		||||
	fs.StringVar(&s.EvictionMinimumReclaim, "eviction-minimum-reclaim", s.EvictionMinimumReclaim, "A set of minimum reclaims (e.g. imagefs.available=2Gi) that describes the minimum amount of resource the kubelet will reclaim when performing a pod eviction if that resource is under pressure.")
 | 
			
		||||
	fs.Int32Var(&s.PodsPerCore, "pods-per-core", s.PodsPerCore, "Number of Pods per core that can run on this Kubelet. The total number of Pods on this Kubelet cannot exceed max-pods, so max-pods will be used if this calculation results in a larger number of Pods allowed on the Kubelet. A value of 0 disables this limit.")
 | 
			
		||||
	fs.BoolVar(&s.ProtectKernelDefaults, "protect-kernel-defaults", s.ProtectKernelDefaults, "Default kubelet behaviour for kernel tuning. If set, kubelet errors if any of kernel tunables is different than kubelet defaults.")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -283,6 +283,7 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
 | 
			
		||||
		NodeIP:                net.ParseIP(s.NodeIP),
 | 
			
		||||
		EvictionConfig:        evictionConfig,
 | 
			
		||||
		PodsPerCore:           int(s.PodsPerCore),
 | 
			
		||||
		ProtectKernelDefaults: s.ProtectKernelDefaults,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -376,6 +377,7 @@ func run(s *options.KubeletServer, kcfg *KubeletConfig) (err error) {
 | 
			
		||||
			ContainerRuntime:      kcfg.ContainerRuntime,
 | 
			
		||||
			CgroupsPerQOS:         kcfg.CgroupsPerQOS,
 | 
			
		||||
			CgroupRoot:            kcfg.CgroupRoot,
 | 
			
		||||
			ProtectKernelDefaults: kcfg.ProtectKernelDefaults,
 | 
			
		||||
		})
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
@@ -624,6 +626,7 @@ func SimpleKubelet(client *clientset.Clientset,
 | 
			
		||||
		OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency,
 | 
			
		||||
		EvictionConfig:               evictionConfig,
 | 
			
		||||
		PodsPerCore:                  podsPerCore,
 | 
			
		||||
		ProtectKernelDefaults:        false,
 | 
			
		||||
	}
 | 
			
		||||
	return &kcfg
 | 
			
		||||
}
 | 
			
		||||
@@ -876,6 +879,8 @@ type KubeletConfig struct {
 | 
			
		||||
	HairpinMode                string
 | 
			
		||||
	BabysitDaemons             bool
 | 
			
		||||
	Options                    []kubelet.Option
 | 
			
		||||
 | 
			
		||||
	ProtectKernelDefaults bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.PodConfig, err error) {
 | 
			
		||||
 
 | 
			
		||||
@@ -369,6 +369,7 @@ portal-net
 | 
			
		||||
prepull-images
 | 
			
		||||
private-mountns
 | 
			
		||||
prom-push-gateway
 | 
			
		||||
protect-kernel-defaults
 | 
			
		||||
proto-import
 | 
			
		||||
proxy-bindall
 | 
			
		||||
proxy-kubeconfig
 | 
			
		||||
 
 | 
			
		||||
@@ -396,6 +396,8 @@ type KubeletConfiguration struct {
 | 
			
		||||
	// Currently only cpu and memory are supported. [default=none]
 | 
			
		||||
	// See http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md for more detail.
 | 
			
		||||
	KubeReserved utilconfig.ConfigurationMap `json:"kubeReserved"`
 | 
			
		||||
	// Default behaviour for kernel tuning
 | 
			
		||||
	ProtectKernelDefaults bool `json:"protectKernelDefaults"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type KubeSchedulerConfiguration struct {
 | 
			
		||||
 
 | 
			
		||||
@@ -451,4 +451,6 @@ type KubeletConfiguration struct {
 | 
			
		||||
	// Currently only cpu and memory are supported. [default=none]
 | 
			
		||||
	// See http://releases.k8s.io/HEAD/docs/user-guide/compute-resources.md for more detail.
 | 
			
		||||
	KubeReserved map[string]string `json:"kubeReserved"`
 | 
			
		||||
	// Default behaviour for kernel tuning
 | 
			
		||||
	ProtectKernelDefaults bool `json:"protectKernelDefaults"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ type NodeConfig struct {
 | 
			
		||||
	ContainerRuntime      string
 | 
			
		||||
	CgroupsPerQOS         bool
 | 
			
		||||
	CgroupRoot            string
 | 
			
		||||
	ProtectKernelDefaults bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Status struct {
 | 
			
		||||
 
 | 
			
		||||
@@ -199,7 +199,6 @@ func createManager(containerName string) *fs.Manager {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: plumb this up as a flag to Kubelet in a future PR
 | 
			
		||||
type KernelTunableBehavior string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -288,8 +287,11 @@ func (cm *containerManagerImpl) setupNode() error {
 | 
			
		||||
	if !f.cpuHardcapping {
 | 
			
		||||
		cm.status.SoftRequirements = fmt.Errorf("CPU hardcapping unsupported")
 | 
			
		||||
	}
 | 
			
		||||
	// TODO: plumb kernel tunable options into container manager, right now, we modify by default
 | 
			
		||||
	if err := setupKernelTunables(KernelTunableModify); err != nil {
 | 
			
		||||
	b := KernelTunableModify
 | 
			
		||||
	if cm.GetNodeConfig().ProtectKernelDefaults {
 | 
			
		||||
		b = KernelTunableError
 | 
			
		||||
	}
 | 
			
		||||
	if err := setupKernelTunables(b); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user