summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorwujunyi <wu65830600@163.com>2023-09-20 16:36:45 +0800
committerwujunyi <wu65830600@163.com>2023-09-21 10:52:24 +0800
commit8a0d3f3e42ff5b393d2fec33e99f3c56abc06c65 (patch)
treed02b5205f117ecd4e39f34d4dcba4dd74fddc71a /pkg
parentchore: sort import (diff)
downloadkubeedge-8a0d3f3e42ff5b393d2fec33e99f3c56abc06c65.tar.gz
chore: avoid using 'if runtime.GOOS'
Signed-off-by: wujunyi <wu65830600@163.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/apis/componentconfig/edgecore/v1alpha2/default.go11
-rw-r--r--pkg/apis/componentconfig/edgecore/v1alpha2/default_kubelet_configuration.go27
-rw-r--r--pkg/apis/componentconfig/edgecore/v1alpha2/types_others.go12
-rw-r--r--pkg/apis/componentconfig/edgecore/v1alpha2/types_windows.go15
4 files changed, 32 insertions, 33 deletions
diff --git a/pkg/apis/componentconfig/edgecore/v1alpha2/default.go b/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
index 35686deb2..8924ebfa5 100644
--- a/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
+++ b/pkg/apis/componentconfig/edgecore/v1alpha2/default.go
@@ -20,7 +20,6 @@ import (
"net"
"net/url"
"path"
- "runtime"
"strconv"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -68,6 +67,7 @@ func NewDefaultEdgeCoreConfig() (config *EdgeCoreConfig) {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
+ WindowsPriorityClass: DefaultWindowsPriorityClass,
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
@@ -159,10 +159,6 @@ func NewDefaultEdgeCoreConfig() (config *EdgeCoreConfig) {
},
},
}
-
- if runtime.GOOS == "windows" {
- config.Modules.Edged.WindowsPriorityClass = WindowsPriorityClassNormal
- }
return
}
@@ -202,6 +198,7 @@ func NewMinEdgeCoreConfig() (config *EdgeCoreConfig) {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
+ WindowsPriorityClass: DefaultWindowsPriorityClass,
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
@@ -237,9 +234,5 @@ func NewMinEdgeCoreConfig() (config *EdgeCoreConfig) {
},
},
}
-
- if runtime.GOOS == "windows" {
- config.Modules.Edged.WindowsPriorityClass = WindowsPriorityClassNormal
- }
return
}
diff --git a/pkg/apis/componentconfig/edgecore/v1alpha2/default_kubelet_configuration.go b/pkg/apis/componentconfig/edgecore/v1alpha2/default_kubelet_configuration.go
index 47f08884a..7ef8fd4c2 100644
--- a/pkg/apis/componentconfig/edgecore/v1alpha2/default_kubelet_configuration.go
+++ b/pkg/apis/componentconfig/edgecore/v1alpha2/default_kubelet_configuration.go
@@ -32,15 +32,7 @@ import (
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
configv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1"
"k8s.io/kubernetes/pkg/kubelet/qos"
- kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
utilpointer "k8s.io/utils/pointer"
- "runtime"
-)
-
-var (
- // TODO: Move these constants to k8s.io/kubelet/config/v1beta1 instead?
- // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information.
- DefaultNodeAllocatableEnforcement = []string{"pods"}
)
// SetDefaultsKubeletConfiguration sets defaults for tailored kubelet configuration
@@ -99,18 +91,9 @@ func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.MemoryThrottlingFactor = utilpointer.Float64Ptr(configv1beta1.DefaultMemoryThrottlingFactor)
obj.RegisterNode = utilpointer.BoolPtr(true)
- if runtime.GOOS == "windows" {
- obj.EnforceNodeAllocatable = []string{}
- obj.CgroupDriver = ""
- obj.CgroupsPerQOS = utilpointer.BoolPtr(false)
- obj.ResolverConfig = utilpointer.String("")
- obj.CPUCFSQuota = utilpointer.BoolPtr(false)
- } else {
- obj.EnforceNodeAllocatable = DefaultNodeAllocatableEnforcement
- obj.CgroupDriver = "cgroupfs"
- obj.CgroupsPerQOS = utilpointer.BoolPtr(true)
- obj.ResolverConfig = utilpointer.String(kubetypes.ResolvConfDefault)
- obj.CPUCFSQuota = utilpointer.BoolPtr(true)
- }
-
+ obj.EnforceNodeAllocatable = DefaultNodeAllocatableEnforcement
+ obj.CgroupDriver = DefaultCgroupDriver
+ obj.CgroupsPerQOS = utilpointer.Bool(DefaultCgroupsPerQOS)
+ obj.ResolverConfig = utilpointer.String(DefaultResolverConfig)
+ obj.CPUCFSQuota = utilpointer.Bool(DefaultCPUCFSQuota)
}
diff --git a/pkg/apis/componentconfig/edgecore/v1alpha2/types_others.go b/pkg/apis/componentconfig/edgecore/v1alpha2/types_others.go
index c1dab91bd..f2a2dcc28 100644
--- a/pkg/apis/componentconfig/edgecore/v1alpha2/types_others.go
+++ b/pkg/apis/componentconfig/edgecore/v1alpha2/types_others.go
@@ -8,4 +8,16 @@ const (
// DataBaseDataSource is edge.db
DataBaseDataSource = "/var/lib/kubeedge/edgecore.db"
+
+ DefaultCgroupDriver = "cgroupfs"
+ DefaultCgroupsPerQOS = true
+ DefaultResolverConfig = kubetypes.ResolvConfDefault
+ DefaultCPUCFSQuota = true
+ DefaultWindowsPriorityClass = ""
+)
+
+var (
+ // TODO: Move these constants to k8s.io/kubelet/config/v1beta1 instead?
+ // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information.
+ DefaultNodeAllocatableEnforcement = []string{"pods"}
)
diff --git a/pkg/apis/componentconfig/edgecore/v1alpha2/types_windows.go b/pkg/apis/componentconfig/edgecore/v1alpha2/types_windows.go
index 59b4839e6..4ff62fdef 100644
--- a/pkg/apis/componentconfig/edgecore/v1alpha2/types_windows.go
+++ b/pkg/apis/componentconfig/edgecore/v1alpha2/types_windows.go
@@ -7,6 +7,17 @@ const (
CGroupDriverSystemd = ""
// DataBaseDataSource is edge.db
- DataBaseDataSource = "C:\\var\\lib\\kubeedge\\edgecore.db"
- WindowsPriorityClassNormal = "NORMAL_PRIORITY_CLASS"
+ DataBaseDataSource = "C:\\var\\lib\\kubeedge\\edgecore.db"
+
+ DefaultCgroupDriver = ""
+ DefaultCgroupsPerQOS = false
+ DefaultResolverConfig = ""
+ DefaultCPUCFSQuota = false
+ DefaultWindowsPriorityClass = "NORMAL_PRIORITY_CLASS"
+)
+
+var (
+ // TODO: Move these constants to k8s.io/kubelet/config/v1beta1 instead?
+ // Refer to [Node Allocatable](https://git.k8s.io/community/contributors/design-proposals/node/node-allocatable.md) doc for more information.
+ DefaultNodeAllocatableEnforcement = []string{}
)