Add eviction-pressure-transition-period flag to kubelet

This commit is contained in:
derekwaynecarr 2016-05-10 17:12:01 -04:00
parent 08440b5dcc
commit 2c01edf9ea
8 changed files with 55 additions and 33 deletions

View File

@ -237,6 +237,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
3*time.Second, /* NodeStatusUpdateFrequency */ 3*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */ 10*time.Second, /* SyncFrequency */
10*time.Second, /* OutOfDiskTransitionFrequency */ 10*time.Second, /* OutOfDiskTransitionFrequency */
10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */ 40, /* MaxPods */
cm, net.ParseIP("127.0.0.1")) cm, net.ParseIP("127.0.0.1"))
@ -269,8 +270,8 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
3*time.Second, /* NodeStatusUpdateFrequency */ 3*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */ 10*time.Second, /* SyncFrequency */
10*time.Second, /* OutOfDiskTransitionFrequency */ 10*time.Second, /* OutOfDiskTransitionFrequency */
10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */ 40, /* MaxPods */
cm, cm,
net.ParseIP("127.0.0.1")) net.ParseIP("127.0.0.1"))

View File

@ -117,30 +117,31 @@ func NewKubeletServer() *KubeletServer {
OOMScoreAdj: int32(qos.KubeletOOMScoreAdj), OOMScoreAdj: int32(qos.KubeletOOMScoreAdj),
LockFilePath: "", LockFilePath: "",
PodInfraContainerImage: GetDefaultPodInfraContainerImage(), PodInfraContainerImage: GetDefaultPodInfraContainerImage(),
Port: ports.KubeletPort, Port: ports.KubeletPort,
ReadOnlyPort: ports.KubeletReadOnlyPort, ReadOnlyPort: ports.KubeletReadOnlyPort,
RegisterNode: true, // will be ignored if no apiserver is configured RegisterNode: true, // will be ignored if no apiserver is configured
RegisterSchedulable: true, RegisterSchedulable: true,
RegistryBurst: 10, RegistryBurst: 10,
RegistryPullQPS: 5.0, RegistryPullQPS: 5.0,
KubeletCgroups: "", KubeletCgroups: "",
ResolverConfig: kubetypes.ResolvConfDefault, ResolverConfig: kubetypes.ResolvConfDefault,
RktPath: "", RktPath: "",
RktAPIEndpoint: rkt.DefaultRktAPIServiceEndpoint, RktAPIEndpoint: rkt.DefaultRktAPIServiceEndpoint,
RktStage1Image: "", RktStage1Image: "",
RootDirectory: defaultRootDir, RootDirectory: defaultRootDir,
RuntimeCgroups: "", RuntimeCgroups: "",
SerializeImagePulls: true, SerializeImagePulls: true,
StreamingConnectionIdleTimeout: unversioned.Duration{Duration: 4 * time.Hour}, StreamingConnectionIdleTimeout: unversioned.Duration{Duration: 4 * time.Hour},
SyncFrequency: unversioned.Duration{Duration: 1 * time.Minute}, SyncFrequency: unversioned.Duration{Duration: 1 * time.Minute},
SystemCgroups: "", SystemCgroups: "",
ReconcileCIDR: true, ReconcileCIDR: true,
KubeAPIQPS: 5.0, KubeAPIQPS: 5.0,
KubeAPIBurst: 10, KubeAPIBurst: 10,
ExperimentalFlannelOverlay: experimentalFlannelOverlay, ExperimentalFlannelOverlay: experimentalFlannelOverlay,
OutOfDiskTransitionFrequency: unversioned.Duration{Duration: 5 * time.Minute}, OutOfDiskTransitionFrequency: unversioned.Duration{Duration: 5 * time.Minute},
HairpinMode: componentconfig.PromiscuousBridge, HairpinMode: componentconfig.PromiscuousBridge,
BabysitDaemons: false, BabysitDaemons: false,
EvictionPressureTransitionPeriod: unversioned.Duration{Duration: 5 * time.Minute},
}, },
} }
} }
@ -255,4 +256,5 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.EvictionHard, "eviction-hard", s.EvictionHard, "A set of eviction thresholds (e.g. memory.available<1Gi) that if met would trigger a pod eviction.") fs.StringVar(&s.EvictionHard, "eviction-hard", s.EvictionHard, "A set of eviction thresholds (e.g. memory.available<1Gi) that if met would trigger a pod eviction.")
fs.StringVar(&s.EvictionSoft, "eviction-soft", s.EvictionSoft, "A set of eviction thresholds (e.g. memory.available<1.5Gi) that if met over a corresponding grace period would trigger a pod eviction.") fs.StringVar(&s.EvictionSoft, "eviction-soft", s.EvictionSoft, "A set of eviction thresholds (e.g. memory.available<1.5Gi) that if met over a corresponding grace period would trigger a pod eviction.")
fs.StringVar(&s.EvictionSoftGracePeriod, "eviction-soft-grace-period", s.EvictionSoftGracePeriod, "A set of eviction grace periods (e.g. memory.available=1m30s) that correspond to how long a soft eviction threshold must hold before triggering a pod eviction.") fs.StringVar(&s.EvictionSoftGracePeriod, "eviction-soft-grace-period", s.EvictionSoftGracePeriod, "A set of eviction grace periods (e.g. memory.available=1m30s) that correspond to how long a soft eviction threshold must hold before triggering a pod eviction.")
fs.DurationVar(&s.EvictionPressureTransitionPeriod.Duration, "eviction-pressure-transition-period", s.EvictionPressureTransitionPeriod.Duration, "Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.")
} }

View File

@ -188,6 +188,10 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
evictionConfig := eviction.Config{
PressureTransitionPeriod: s.EvictionPressureTransitionPeriod.Duration,
Thresholds: thresholds,
}
return &KubeletConfig{ return &KubeletConfig{
Address: net.ParseIP(s.Address), Address: net.ParseIP(s.Address),
@ -267,8 +271,8 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
HairpinMode: s.HairpinMode, HairpinMode: s.HairpinMode,
BabysitDaemons: s.BabysitDaemons, BabysitDaemons: s.BabysitDaemons,
ExperimentalFlannelOverlay: s.ExperimentalFlannelOverlay, ExperimentalFlannelOverlay: s.ExperimentalFlannelOverlay,
NodeIP: net.ParseIP(s.NodeIP), NodeIP: net.ParseIP(s.NodeIP),
Thresholds: thresholds, EvictionConfig: evictionConfig,
}, nil }, nil
} }
@ -513,7 +517,7 @@ func SimpleKubelet(client *clientset.Clientset,
configFilePath string, configFilePath string,
cloud cloudprovider.Interface, cloud cloudprovider.Interface,
osInterface kubecontainer.OSInterface, osInterface kubecontainer.OSInterface,
fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency time.Duration, fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency, evictionPressureTransitionPeriod time.Duration,
maxPods int, maxPods int,
containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig { containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig {
imageGCPolicy := kubelet.ImageGCPolicy{ imageGCPolicy := kubelet.ImageGCPolicy{
@ -524,7 +528,9 @@ func SimpleKubelet(client *clientset.Clientset,
DockerFreeDiskMB: 256, DockerFreeDiskMB: 256,
RootFreeDiskMB: 256, RootFreeDiskMB: 256,
} }
evictionConfig := eviction.Config{
PressureTransitionPeriod: evictionPressureTransitionPeriod,
}
kcfg := KubeletConfig{ kcfg := KubeletConfig{
Address: net.ParseIP(address), Address: net.ParseIP(address),
CAdvisorInterface: cadvisorInterface, CAdvisorInterface: cadvisorInterface,
@ -582,6 +588,7 @@ func SimpleKubelet(client *clientset.Clientset,
VolumePlugins: volumePlugins, VolumePlugins: volumePlugins,
Writer: &io.StdWriter{}, Writer: &io.StdWriter{},
OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency, OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency,
EvictionConfig: evictionConfig,
} }
return &kcfg return &kcfg
} }
@ -783,7 +790,7 @@ type KubeletConfig struct {
Writer io.Writer Writer io.Writer
VolumePlugins []volume.VolumePlugin VolumePlugins []volume.VolumePlugin
OutOfDiskTransitionFrequency time.Duration OutOfDiskTransitionFrequency time.Duration
Thresholds []eviction.Threshold EvictionConfig eviction.Config
ExperimentalFlannelOverlay bool ExperimentalFlannelOverlay bool
NodeIP net.IP NodeIP net.IP
@ -880,7 +887,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
kc.ContainerRuntimeOptions, kc.ContainerRuntimeOptions,
kc.HairpinMode, kc.HairpinMode,
kc.BabysitDaemons, kc.BabysitDaemons,
kc.Thresholds, kc.EvictionConfig,
kc.Options, kc.Options,
) )

View File

@ -121,6 +121,7 @@ event-ttl
eviction-hard eviction-hard
eviction-soft eviction-soft
eviction-soft-grace-period eviction-soft-grace-period
eviction-pressure-transition-period
executor-bindall executor-bindall
executor-logv executor-logv
executor-path executor-path

View File

@ -349,6 +349,8 @@ type KubeletConfiguration struct {
EvictionSoft string `json:"evictionSoft,omitempty"` EvictionSoft string `json:"evictionSoft,omitempty"`
// Comma-delimeted list of grace periods for each soft eviction signal. For example, 'memory.available=30s'. // Comma-delimeted list of grace periods for each soft eviction signal. For example, 'memory.available=30s'.
EvictionSoftGracePeriod string `json:"evictionSoftGracePeriod,omitempty"` EvictionSoftGracePeriod string `json:"evictionSoftGracePeriod,omitempty"`
// Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.
EvictionPressureTransitionPeriod unversioned.Duration `json:"evictionPressureTransitionPeriod,omitempty"`
} }
type KubeSchedulerConfiguration struct { type KubeSchedulerConfiguration struct {

View File

@ -38,6 +38,14 @@ const (
OpLessThan ThresholdOperator = "LessThan" OpLessThan ThresholdOperator = "LessThan"
) )
// Config holds information about how eviction is configured.
type Config struct {
// PressureTransitionPeriod is duration the kubelet has to wait before transititioning out of a pressure condition.
PressureTransitionPeriod time.Duration
// Thresholds define the set of conditions monitored to trigger eviction.
Thresholds []Threshold
}
// Threshold defines a metric for when eviction should occur. // Threshold defines a metric for when eviction should occur.
type Threshold struct { type Threshold struct {
// Signal defines the entity that was measured. // Signal defines the entity that was measured.

View File

@ -223,7 +223,7 @@ func NewMainKubelet(
containerRuntimeOptions []kubecontainer.Option, containerRuntimeOptions []kubecontainer.Option,
hairpinMode string, hairpinMode string,
babysitDaemons bool, babysitDaemons bool,
thresholds []eviction.Threshold, evictionConfig eviction.Config,
kubeOptions []Option, kubeOptions []Option,
) (*Kubelet, error) { ) (*Kubelet, error) {
if rootDirectory == "" { if rootDirectory == "" {

View File

@ -72,6 +72,7 @@ func NewHollowKubelet(
10*time.Second, /* NodeStatusUpdateFrequency */ 10*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */ 10*time.Second, /* SyncFrequency */
5*time.Minute, /* OutOfDiskTransitionFrequency */ 5*time.Minute, /* OutOfDiskTransitionFrequency */
5*time.Minute, /* EvictionPressureTransitionPeriod */
maxPods, maxPods,
containerManager, containerManager,
nil, nil,