diff --git a/pkg/kubelet/apis/config/fuzzer/fuzzer.go b/pkg/kubelet/apis/config/fuzzer/fuzzer.go index a230185bf2..1154789c42 100644 --- a/pkg/kubelet/apis/config/fuzzer/fuzzer.go +++ b/pkg/kubelet/apis/config/fuzzer/fuzzer.go @@ -81,12 +81,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { obj.KubeAPIQPS = 5 obj.KubeAPIBurst = 10 obj.HairpinMode = v1beta1.PromiscuousBridge - obj.EvictionHard = map[string]string{ - "memory.available": "100Mi", - "nodefs.available": "10%", - "nodefs.inodesFree": "5%", - "imagefs.available": "15%", - } + obj.EvictionHard = kubeletconfigv1beta1.DefaultEvictionHard obj.EvictionPressureTransitionPeriod = metav1.Duration{Duration: 5 * time.Minute} obj.MakeIPTablesUtilChains = true obj.IPTablesMasqueradeBit = kubeletconfigv1beta1.DefaultIPTablesMasqueradeBit diff --git a/pkg/kubelet/apis/config/v1beta1/BUILD b/pkg/kubelet/apis/config/v1beta1/BUILD index 74fb33a945..8ac93dc4d6 100644 --- a/pkg/kubelet/apis/config/v1beta1/BUILD +++ b/pkg/kubelet/apis/config/v1beta1/BUILD @@ -9,6 +9,8 @@ go_library( name = "go_default_library", srcs = [ "defaults.go", + "defaults_linux.go", + "defaults_others.go", "doc.go", "register.go", "zz_generated.conversion.go", diff --git a/pkg/kubelet/apis/config/v1beta1/defaults.go b/pkg/kubelet/apis/config/v1beta1/defaults.go index b6103d3db5..ca23a0b492 100644 --- a/pkg/kubelet/apis/config/v1beta1/defaults.go +++ b/pkg/kubelet/apis/config/v1beta1/defaults.go @@ -178,12 +178,7 @@ func SetDefaults_KubeletConfiguration(obj *kubeletconfigv1beta1.KubeletConfigura obj.SerializeImagePulls = utilpointer.BoolPtr(true) } if obj.EvictionHard == nil { - obj.EvictionHard = map[string]string{ - "memory.available": "100Mi", - "nodefs.available": "10%", - "nodefs.inodesFree": "5%", - "imagefs.available": "15%", - } + obj.EvictionHard = DefaultEvictionHard } if obj.EvictionPressureTransitionPeriod == zeroDuration { obj.EvictionPressureTransitionPeriod = metav1.Duration{Duration: 5 * time.Minute} diff --git a/pkg/kubelet/apis/config/v1beta1/defaults_linux.go b/pkg/kubelet/apis/config/v1beta1/defaults_linux.go new file mode 100644 index 0000000000..7e1060a03e --- /dev/null +++ b/pkg/kubelet/apis/config/v1beta1/defaults_linux.go @@ -0,0 +1,27 @@ +// +build linux + +/* +Copyright 2018 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 v1beta1 + +// DefaultEvictionHard includes default options for hard eviction. +var DefaultEvictionHard = map[string]string{ + "memory.available": "100Mi", + "nodefs.available": "10%", + "nodefs.inodesFree": "5%", + "imagefs.available": "15%", +} diff --git a/pkg/kubelet/apis/config/v1beta1/defaults_others.go b/pkg/kubelet/apis/config/v1beta1/defaults_others.go new file mode 100644 index 0000000000..74464a3c84 --- /dev/null +++ b/pkg/kubelet/apis/config/v1beta1/defaults_others.go @@ -0,0 +1,26 @@ +// +build !linux + +/* +Copyright 2018 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 v1beta1 + +// DefaultEvictionHard includes default options for hard eviction. +var DefaultEvictionHard = map[string]string{ + "memory.available": "100Mi", + "nodefs.available": "10%", + "imagefs.available": "15%", +} diff --git a/pkg/kubelet/dockershim/docker_image_windows.go b/pkg/kubelet/dockershim/docker_image_windows.go index 38fe998be0..8fd6d2c869 100644 --- a/pkg/kubelet/dockershim/docker_image_windows.go +++ b/pkg/kubelet/dockershim/docker_image_windows.go @@ -45,9 +45,8 @@ func (ds *dockerService) ImageFsInfo(_ context.Context, _ *runtimeapi.ImageFsInf filesystems := []*runtimeapi.FilesystemUsage{ { - Timestamp: time.Now().UnixNano(), - UsedBytes: &runtimeapi.UInt64Value{Value: fsinfo.Usage}, - InodesUsed: &runtimeapi.UInt64Value{Value: 0}, + Timestamp: time.Now().UnixNano(), + UsedBytes: &runtimeapi.UInt64Value{Value: fsinfo.Usage}, FsId: &runtimeapi.FilesystemIdentifier{ Mountpoint: info.DockerRootDir, }, diff --git a/pkg/kubelet/stats/cri_stats_provider.go b/pkg/kubelet/stats/cri_stats_provider.go index 1af0a0cbfb..6580f46ead 100644 --- a/pkg/kubelet/stats/cri_stats_provider.go +++ b/pkg/kubelet/stats/cri_stats_provider.go @@ -182,9 +182,11 @@ func (p *criStatsProvider) ImageFsStats() (*statsapi.FsStats, error) { // TODO(yguo0905): Support returning stats of multiple image filesystems. for _, fs := range resp { s := &statsapi.FsStats{ - Time: metav1.NewTime(time.Unix(0, fs.Timestamp)), - UsedBytes: &fs.UsedBytes.Value, - InodesUsed: &fs.InodesUsed.Value, + Time: metav1.NewTime(time.Unix(0, fs.Timestamp)), + UsedBytes: &fs.UsedBytes.Value, + } + if fs.InodesUsed != nil { + s.InodesUsed = &fs.InodesUsed.Value } imageFsInfo := p.getFsInfo(fs.GetFsId()) if imageFsInfo != nil {