
The subfeature was a cool idea, but in the end it is very complex to separate Kubelet restarts into crash-loops caused by config vs. crash-loops caused by other phenomena, like admin-triggered node restarts, kernel panics, and and process babysitter behavior. Dynamic kubelet config will be better off without the potential for false positives here. Removing this subfeature also simplifies dynamic configuration by reducing persistent state: - we no longer need to track bad config in a file - we no longer need to track kubelet startups in a file
47 lines
1.7 KiB
Go
47 lines
1.7 KiB
Go
/*
|
|
Copyright 2017 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package validation
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
|
containermanager "k8s.io/kubernetes/pkg/kubelet/cm"
|
|
)
|
|
|
|
// ValidateKubeletConfiguration validates `kc` and returns an error if it is invalid
|
|
func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
|
|
if !kc.CgroupsPerQOS && len(kc.EnforceNodeAllocatable) > 0 {
|
|
return fmt.Errorf("node allocatable enforcement is not supported unless Cgroups Per QOS feature is turned on")
|
|
}
|
|
if kc.SystemCgroups != "" && kc.CgroupRoot == "" {
|
|
return fmt.Errorf("invalid configuration: system container was specified and cgroup root was not specified")
|
|
}
|
|
for _, val := range kc.EnforceNodeAllocatable {
|
|
switch val {
|
|
case containermanager.NodeAllocatableEnforcementKey:
|
|
case containermanager.SystemReservedEnforcementKey:
|
|
case containermanager.KubeReservedEnforcementKey:
|
|
continue
|
|
default:
|
|
return fmt.Errorf("invalid option %q specified for EnforceNodeAllocatable setting. Valid options are %q, %q or %q",
|
|
val, containermanager.NodeAllocatableEnforcementKey, containermanager.SystemReservedEnforcementKey, containermanager.KubeReservedEnforcementKey)
|
|
}
|
|
}
|
|
return nil
|
|
}
|