Skip to content

Commit

Permalink
Add eviction-pressure-transition-period flag to kubelet
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwaynecarr committed May 12, 2016
1 parent 08440b5 commit 2c01edf
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 33 deletions.
5 changes: 3 additions & 2 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
3*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */
10*time.Second, /* OutOfDiskTransitionFrequency */
10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */
cm, net.ParseIP("127.0.0.1"))

Expand Down Expand Up @@ -269,8 +270,8 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
3*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */
10*time.Second, /* OutOfDiskTransitionFrequency */

40, /* MaxPods */
10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */
cm,
net.ParseIP("127.0.0.1"))

Expand Down
50 changes: 26 additions & 24 deletions cmd/kubelet/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,31 @@ func NewKubeletServer() *KubeletServer {
OOMScoreAdj: int32(qos.KubeletOOMScoreAdj),
LockFilePath: "",
PodInfraContainerImage: GetDefaultPodInfraContainerImage(),
Port: ports.KubeletPort,
ReadOnlyPort: ports.KubeletReadOnlyPort,
RegisterNode: true, // will be ignored if no apiserver is configured
RegisterSchedulable: true,
RegistryBurst: 10,
RegistryPullQPS: 5.0,
KubeletCgroups: "",
ResolverConfig: kubetypes.ResolvConfDefault,
RktPath: "",
RktAPIEndpoint: rkt.DefaultRktAPIServiceEndpoint,
RktStage1Image: "",
RootDirectory: defaultRootDir,
RuntimeCgroups: "",
SerializeImagePulls: true,
StreamingConnectionIdleTimeout: unversioned.Duration{Duration: 4 * time.Hour},
SyncFrequency: unversioned.Duration{Duration: 1 * time.Minute},
SystemCgroups: "",
ReconcileCIDR: true,
KubeAPIQPS: 5.0,
KubeAPIBurst: 10,
ExperimentalFlannelOverlay: experimentalFlannelOverlay,
OutOfDiskTransitionFrequency: unversioned.Duration{Duration: 5 * time.Minute},
HairpinMode: componentconfig.PromiscuousBridge,
BabysitDaemons: false,
Port: ports.KubeletPort,
ReadOnlyPort: ports.KubeletReadOnlyPort,
RegisterNode: true, // will be ignored if no apiserver is configured
RegisterSchedulable: true,
RegistryBurst: 10,
RegistryPullQPS: 5.0,
KubeletCgroups: "",
ResolverConfig: kubetypes.ResolvConfDefault,
RktPath: "",
RktAPIEndpoint: rkt.DefaultRktAPIServiceEndpoint,
RktStage1Image: "",
RootDirectory: defaultRootDir,
RuntimeCgroups: "",
SerializeImagePulls: true,
StreamingConnectionIdleTimeout: unversioned.Duration{Duration: 4 * time.Hour},
SyncFrequency: unversioned.Duration{Duration: 1 * time.Minute},
SystemCgroups: "",
ReconcileCIDR: true,
KubeAPIQPS: 5.0,
KubeAPIBurst: 10,
ExperimentalFlannelOverlay: experimentalFlannelOverlay,
OutOfDiskTransitionFrequency: unversioned.Duration{Duration: 5 * time.Minute},
HairpinMode: componentconfig.PromiscuousBridge,
BabysitDaemons: false,
EvictionPressureTransitionPeriod: unversioned.Duration{Duration: 5 * time.Minute},
},
}
}
Expand Down Expand Up @@ -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.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.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.")
}
19 changes: 13 additions & 6 deletions cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
if err != nil {
return nil, err
}
evictionConfig := eviction.Config{
PressureTransitionPeriod: s.EvictionPressureTransitionPeriod.Duration,
Thresholds: thresholds,
}

return &KubeletConfig{
Address: net.ParseIP(s.Address),
Expand Down Expand Up @@ -267,8 +271,8 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
HairpinMode: s.HairpinMode,
BabysitDaemons: s.BabysitDaemons,
ExperimentalFlannelOverlay: s.ExperimentalFlannelOverlay,
NodeIP: net.ParseIP(s.NodeIP),
Thresholds: thresholds,
NodeIP: net.ParseIP(s.NodeIP),
EvictionConfig: evictionConfig,
}, nil
}

Expand Down Expand Up @@ -513,7 +517,7 @@ func SimpleKubelet(client *clientset.Clientset,
configFilePath string,
cloud cloudprovider.Interface,
osInterface kubecontainer.OSInterface,
fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency time.Duration,
fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency, evictionPressureTransitionPeriod time.Duration,
maxPods int,
containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig {
imageGCPolicy := kubelet.ImageGCPolicy{
Expand All @@ -524,7 +528,9 @@ func SimpleKubelet(client *clientset.Clientset,
DockerFreeDiskMB: 256,
RootFreeDiskMB: 256,
}

evictionConfig := eviction.Config{
PressureTransitionPeriod: evictionPressureTransitionPeriod,
}
kcfg := KubeletConfig{
Address: net.ParseIP(address),
CAdvisorInterface: cadvisorInterface,
Expand Down Expand Up @@ -582,6 +588,7 @@ func SimpleKubelet(client *clientset.Clientset,
VolumePlugins: volumePlugins,
Writer: &io.StdWriter{},
OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency,
EvictionConfig: evictionConfig,
}
return &kcfg
}
Expand Down Expand Up @@ -783,7 +790,7 @@ type KubeletConfig struct {
Writer io.Writer
VolumePlugins []volume.VolumePlugin
OutOfDiskTransitionFrequency time.Duration
Thresholds []eviction.Threshold
EvictionConfig eviction.Config

ExperimentalFlannelOverlay bool
NodeIP net.IP
Expand Down Expand Up @@ -880,7 +887,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
kc.ContainerRuntimeOptions,
kc.HairpinMode,
kc.BabysitDaemons,
kc.Thresholds,
kc.EvictionConfig,
kc.Options,
)

Expand Down
1 change: 1 addition & 0 deletions hack/verify-flags/known-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ event-ttl
eviction-hard
eviction-soft
eviction-soft-grace-period
eviction-pressure-transition-period
executor-bindall
executor-logv
executor-path
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/componentconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ type KubeletConfiguration struct {
EvictionSoft string `json:"evictionSoft,omitempty"`
// Comma-delimeted list of grace periods for each soft eviction signal. For example, 'memory.available=30s'.
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 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/kubelet/eviction/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ const (
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.
type Threshold struct {
// Signal defines the entity that was measured.
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func NewMainKubelet(
containerRuntimeOptions []kubecontainer.Option,
hairpinMode string,
babysitDaemons bool,
thresholds []eviction.Threshold,
evictionConfig eviction.Config,
kubeOptions []Option,
) (*Kubelet, error) {
if rootDirectory == "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/kubemark/hollow_kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func NewHollowKubelet(
10*time.Second, /* NodeStatusUpdateFrequency */
10*time.Second, /* SyncFrequency */
5*time.Minute, /* OutOfDiskTransitionFrequency */
5*time.Minute, /* EvictionPressureTransitionPeriod */
maxPods,
containerManager,
nil,
Expand Down

0 comments on commit 2c01edf

Please sign in to comment.