Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/windows nodes edgecore #4967

Merged
merged 11 commits into from Sep 22, 2023
3 changes: 3 additions & 0 deletions common/constants/default.go
@@ -1,3 +1,5 @@
//go:build !windows

package constants

import (
Expand Down Expand Up @@ -78,6 +80,7 @@ const (
DefaultVolumeStatsAggPeriod = time.Minute
DefaultTunnelPort = 10004
DefaultClusterDomain = "cluster.local"
DefaultVolumePluginDir = "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/"

CurrentSupportK8sVersion = "v1.24.14"

Expand Down
180 changes: 180 additions & 0 deletions common/constants/default_windows.go
@@ -0,0 +1,180 @@
//go:build windows
wujunyi792 marked this conversation as resolved.
Show resolved Hide resolved

package constants

import (
"time"

v1 "k8s.io/api/core/v1"
)

// Module name and group name
const (
// SyncController
DefaultContextSendModuleName = "cloudhub"

// NodeName is for the clearer log of cloudcore.
NodeName = "NodeName"

ProjectName = "KubeEdge"

SystemName = "kubeedge"
SystemNamespace = SystemName

CloudConfigMapName = "cloudcore"

// runtime
DockerContainerRuntime = "docker"
RemoteContainerRuntime = "remote"
)

// Resources
const (
// Certificates
DefaultConfigDir = "c:\\etc\\kubeedge\\config\\"
DefaultCAFile = "c:\\etc\\kubeedge\\ca\\rootCA.crt"
DefaultCAKeyFile = "c:\\etc\\kubeedge\\ca\\rootCA.key"
DefaultCertFile = "c:\\etc\\kubeedge\\certs\\server.crt"
DefaultKeyFile = "c:\\etc\\kubeedge\\certs\\server.key"
DefaultServiceAccountIssuer = "https://kubernetes.default.svc.cluster.local"

DefaultCAURL = "/ca.crt"
DefaultCertURL = "/edge.crt"
DefaultNodeUpgradeURL = "/nodeupgrade"

DefaultStreamCAFile = "c:\\etc\\kubeedge\\ca\\streamCA.crt"
DefaultStreamCertFile = "c:\\etc\\kubeedge\\certs\\stream.crt"
DefaultStreamKeyFile = "c:\\etc\\kubeedge\\certs\\stream.key"

DefaultMqttCAFile = "c:\\etc\\kubeedge\\ca\\rootCA.crt"
DefaultMqttCertFile = "c:\\etc\\kubeedge\\certs\\server.crt"
DefaultMqttKeyFile = "c:\\etc\\kubeedge\\certs\\server.key"

// Bootstrap file, contains token used by edgecore to apply for ca/cert
BootstrapFile = "c:\\etc\\kubeedge\\bootstrap-edgecore.conf"

// Edged
DefaultRootDir = "c:\\var\\lib\\edged"
DefaultDockerAddress = "unix:///var/run/docker.sock"
DefaultRuntimeType = "remote"
DefaultDockershimRootDir = "c:\\var\\lib\\dockershim"
DefaultEdgedMemoryCapacity = 7852396000
DefaultRemoteRuntimeEndpoint = "npipe://./pipe/containerd-containerd"
DefaultRemoteImageEndpoint = "npipe://./pipe/containerd-containerd"
DefaultMosquittoImage = "eclipse-mosquitto:1.6.15"
// update PodSandboxImage version when bumping k8s vendor version, consistent with vendor/k8s.io/kubernetes/cmd/kubelet/app/options/container_runtime.go defaultPodSandboxImageVersion
// When this value are updated, also update comments in pkg/apis/componentconfig/edgecore/v1alpha1/types.go
DefaultPodSandboxImage = "kubeedge/pause:3.6"
DefaultImagePullProgressDeadline = time.Minute
DefaultImageGCHighThreshold = 80
DefaultImageGCLowThreshold = 40
DefaultMaximumDeadContainersPerPod = 1
DefaultHostnameOverride = "default-edge-node"
DefaultRegisterNodeNamespace = "default"
DefaultCNIConfDir = "c:\\etc\\cni\\net.d"
DefaultCNIBinDir = "c:\\opt\\cni\\bin"
DefaultCNICacheDir = "c:\\var\\lib\\cni\\cache"
DefaultNetworkPluginMTU = 1500
DefaultConcurrentConsumers = 5
DefaultCgroupRoot = ""
DefaultVolumeStatsAggPeriod = time.Minute
DefaultTunnelPort = 10004
DefaultClusterDomain = "cluster.local"
DefaultVolumePluginDir = "C:\\usr\\libexec\\kubernetes\\kubelet-plugins\\volume\\exec\\"

CurrentSupportK8sVersion = "v1.24.14"

// MetaManager
DefaultRemoteQueryTimeout = 60
DefaultMetaServerAddr = "127.0.0.1:10550"

// Config
DefaultKubeContentType = "application/vnd.kubernetes.protobuf"
DefaultKubeNamespace = v1.NamespaceAll
DefaultKubeQPS = 100.0
DefaultKubeBurst = 200
DefaultNodeLimit = 500
DefaultKubeUpdateNodeFrequency = 20

// EdgeController
DefaultUpdatePodStatusWorkers = 1
DefaultUpdateNodeStatusWorkers = 1
DefaultQueryConfigMapWorkers = 100
DefaultQuerySecretWorkers = 100
DefaultQueryPersistentVolumeWorkers = 4
DefaultQueryPersistentVolumeClaimWorkers = 4
DefaultQueryVolumeAttachmentWorkers = 4
DefaultCreateNodeWorkers = 100
DefaultUpdateNodeWorkers = 4
DefaultPatchPodWorkers = 100
DefaultDeletePodWorkers = 100
DefaultUpdateRuleStatusWorkers = 4
DefaultQueryLeaseWorkers = 100
DefaultServiceAccountTokenWorkers = 100

DefaultUpdatePodStatusBuffer = 1024
DefaultUpdateNodeStatusBuffer = 1024
DefaultQueryConfigMapBuffer = 1024
DefaultQuerySecretBuffer = 1024
DefaultQueryPersistentVolumeBuffer = 1024
DefaultQueryPersistentVolumeClaimBuffer = 1024
DefaultQueryVolumeAttachmentBuffer = 1024
DefaultCreateNodeBuffer = 1024
DefaultUpdateNodeBuffer = 1024
DefaultPatchPodBuffer = 1024
DefaultDeletePodBuffer = 1024
DefaultQueryLeaseBuffer = 1024
DefaultServiceAccountTokenBuffer = 1024

DefaultPodEventBuffer = 1
DefaultConfigMapEventBuffer = 1
DefaultSecretEventBuffer = 1
DefaultRulesEventBuffer = 1
DefaultRuleEndpointsEventBuffer = 1

// DeviceController
DefaultUpdateDeviceStatusBuffer = 1024
DefaultDeviceEventBuffer = 1
DefaultDeviceModelEventBuffer = 1
DefaultUpdateDeviceStatusWorkers = 1

// NodeUpgradeJobController
DefaultNodeUpgradeJobStatusBuffer = 1024
DefaultNodeUpgradeJobEventBuffer = 1
DefaultNodeUpgradeJobWorkers = 1

// Resource sep
ResourceSep = "/"

ResourceTypeService = "service"
ResourceTypeEndpoints = "endpoints"

ResourceTypePersistentVolume = "persistentvolume"
ResourceTypePersistentVolumeClaim = "persistentvolumeclaim"
ResourceTypeVolumeAttachment = "volumeattachment"

CSIResourceTypeVolume = "volume"
CSIOperationTypeCreateVolume = "createvolume"
CSIOperationTypeDeleteVolume = "deletevolume"
CSIOperationTypeControllerPublishVolume = "controllerpublishvolume"
CSIOperationTypeControllerUnpublishVolume = "controllerunpublishvolume"
CSISyncMsgRespTimeout = 1 * time.Minute

// ServerPort is the default port for the edgecore server on each host machine.
// May be overridden by a flag at startup in the future.
ServerAddress = "127.0.0.1"
ServerPort = 10350

// MessageSuccessfulContent is the successful content value of Message struct
MessageSuccessfulContent string = "OK"
DefaultQPS = 30
DefaultBurst = 60
// MaxRespBodyLength is the max length of http response body
MaxRespBodyLength = 1 << 20 // 1 MiB

EdgeNodeRoleKey = "node-role.kubernetes.io/edge"
EdgeNodeRoleValue = ""

DeafultMosquittoContainerName = "mqtt-kubeedge"
DeployMqttContainerEnv = "DEPLOY_MQTT_CONTAINER"
)
2 changes: 1 addition & 1 deletion edge/cmd/edgecore/app/server.go
Expand Up @@ -176,7 +176,7 @@ func environmentCheck() error {
for _, process := range processes {
processName, err := process.Name()
if err != nil {
return err
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the environmentCheck, can we also put it into files for windows and others?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we use continue to skip check for some processes which failed to get name. I think it can be kept in Linux as well, but we need add a comment here.

}
switch processName {
case "kubelet": // if kubelet is running, return error
Expand Down
7 changes: 7 additions & 0 deletions edge/pkg/devicetwin/dmiserver/const_others.go
@@ -0,0 +1,7 @@
//go:build !windows

package dmiserver

const (
SockPath = "/etc/kubeedge/dmi.sock"
)
7 changes: 7 additions & 0 deletions edge/pkg/devicetwin/dmiserver/const_windows.go
@@ -0,0 +1,7 @@
//go:build windows

package dmiserver

const (
SockPath = "c:\\etc\\kubeedge\\dmi.sock"
)
20 changes: 8 additions & 12 deletions edge/pkg/devicetwin/dmiserver/server.go
Expand Up @@ -46,9 +46,8 @@ import (
)

const (
SockPath = "/etc/kubeedge/dmi.sock"
Limit = 1000
Burst = 100
Limit = 1000
Burst = 100
)

type server struct {
Expand Down Expand Up @@ -181,18 +180,15 @@ func CreateMessageTwinUpdate(name, valueType, value string) ([]byte, error) {

func initSock(sockPath string) error {
klog.Infof("init uds socket: %s", sockPath)
_, err := os.Stat(sockPath)
if err == nil {
err = os.Remove(sockPath)
if err != nil {
return err
}
return nil
} else if os.IsNotExist(err) {
err := os.Remove(sockPath)

if os.IsNotExist(err) {
return nil
} else {
} else if err != nil {
klog.Error(err)
return fmt.Errorf("fail to stat uds socket path")
}
return nil
}

func StartDMIServer(cache *DMICache) {
Expand Down
2 changes: 2 additions & 0 deletions edge/pkg/edged/config/config.go
Expand Up @@ -187,6 +187,8 @@ func ConvertConfigEdgedFlagToConfigKubeletFlag(in *v1alpha2.TailoredKubeletFlag,
out.RegisterSchedulable = in.RegisterSchedulable
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
out.SeccompDefault = in.SeccompDefault
out.WindowsPriorityClass = in.WindowsPriorityClass
//out.WindowsService = in.WindowsService
wujunyi792 marked this conversation as resolved.
Show resolved Hide resolved

// container-runtime-specific options
out.ContainerRuntime = in.ContainerRuntime
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/componentconfig/edgecore/v1alpha2/default.go
Expand Up @@ -67,6 +67,7 @@ func NewDefaultEdgeCoreConfig() *EdgeCoreConfig {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
WindowsPriorityClass: "NORMAL_PRIORITY_CLASS",
wujunyi792 marked this conversation as resolved.
Show resolved Hide resolved
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
Expand Down Expand Up @@ -196,6 +197,7 @@ func NewMinEdgeCoreConfig() *EdgeCoreConfig {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
WindowsPriorityClass: "NORMAL_PRIORITY_CLASS",
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
Expand Down
@@ -1,3 +1,5 @@
//go:build !windows

/*
Copyright 2022 The KubeEdge Authors.

Expand Down Expand Up @@ -93,7 +95,7 @@ func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.ContainerLogMaxFiles = utilpointer.Int32Ptr(5)
obj.ConfigMapAndSecretChangeDetectionStrategy = kubeletconfigv1beta1.GetChangeDetectionStrategy
obj.EnforceNodeAllocatable = DefaultNodeAllocatableEnforcement
obj.VolumePluginDir = configv1beta1.DefaultVolumePluginDir
obj.VolumePluginDir = constants.DefaultVolumePluginDir
// Use the Default LoggingConfiguration option
componentbaseconfigv1alpha1.RecommendedLoggingConfiguration(&obj.Logging)
obj.EnableSystemLogHandler = utilpointer.BoolPtr(true)
Expand Down
@@ -0,0 +1,100 @@
//go:build windows

/*
Copyright 2022 The KubeEdge Authors.
wujunyi792 marked this conversation as resolved.
Show resolved Hide resolved

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.

@CHANGELOG
KubeEdge Authors: To set default tailored kubelet configuration,
This file is derived from K8S Kubelet apis code with reduced set of methods
Changes done are
1. Package edged got some functions from "k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1"
and made some variant
*/

package v1alpha2

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentbaseconfigv1alpha1 "k8s.io/component-base/config/v1alpha1"
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
configv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1"
"k8s.io/kubernetes/pkg/kubelet/qos"
utilpointer "k8s.io/utils/pointer"

"github.com/kubeedge/kubeedge/common/constants"
)

// SetDefaultsKubeletConfiguration sets defaults for tailored kubelet configuration
func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.SyncFrequency = metav1.Duration{Duration: 1 * time.Minute}
obj.Address = constants.ServerAddress
obj.ReadOnlyPort = constants.ServerPort
obj.ClusterDomain = constants.DefaultClusterDomain
obj.RegistryPullQPS = utilpointer.Int32(5)
obj.RegistryBurst = 10
obj.EnableDebuggingHandlers = utilpointer.Bool(true)
obj.OOMScoreAdj = utilpointer.Int32(int32(qos.KubeletOOMScoreAdj))
obj.StreamingConnectionIdleTimeout = metav1.Duration{Duration: 4 * time.Hour}
obj.NodeStatusReportFrequency = metav1.Duration{Duration: 5 * time.Minute}
obj.NodeStatusUpdateFrequency = metav1.Duration{Duration: 10 * time.Second}
obj.NodeLeaseDurationSeconds = 40
obj.ImageMinimumGCAge = metav1.Duration{Duration: 2 * time.Minute}
// default is below docker's default dm.min_free_space of 90%
obj.ImageGCHighThresholdPercent = utilpointer.Int32(constants.DefaultImageGCHighThreshold)
obj.ImageGCLowThresholdPercent = utilpointer.Int32(constants.DefaultImageGCLowThreshold)
obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
obj.CgroupsPerQOS = utilpointer.Bool(false)
obj.CgroupDriver = ""
obj.CPUManagerPolicy = "none"
// Keep the same as default NodeStatusUpdateFrequency
obj.CPUManagerReconcilePeriod = metav1.Duration{Duration: 10 * time.Second}
obj.MemoryManagerPolicy = kubeletconfigv1beta1.NoneMemoryManagerPolicy
obj.TopologyManagerPolicy = kubeletconfigv1beta1.NoneTopologyManagerPolicy
obj.TopologyManagerScope = kubeletconfigv1beta1.ContainerTopologyManagerScope
obj.RuntimeRequestTimeout = metav1.Duration{Duration: 2 * time.Minute}
obj.HairpinMode = kubeletconfigv1beta1.PromiscuousBridge
obj.MaxPods = 110
// default nil or negative value to -1 (implies node allocatable pid limit)
obj.PodPidsLimit = utilpointer.Int64(-1)
//obj.ResolverConfig = utilpointer.String("")
obj.CPUCFSQuota = utilpointer.Bool(false)
obj.CPUCFSQuotaPeriod = &metav1.Duration{Duration: 100 * time.Millisecond}
obj.NodeStatusMaxImages = utilpointer.Int32(0)
obj.MaxOpenFiles = 1000000
obj.ContentType = "application/json"
obj.SerializeImagePulls = utilpointer.Bool(true)
obj.EvictionHard = configv1beta1.DefaultEvictionHard
obj.EvictionPressureTransitionPeriod = metav1.Duration{Duration: 5 * time.Minute}
obj.EnableControllerAttachDetach = utilpointer.Bool(true)
obj.MakeIPTablesUtilChains = utilpointer.Bool(true)
obj.IPTablesMasqueradeBit = utilpointer.Int32(configv1beta1.DefaultIPTablesMasqueradeBit)
obj.IPTablesDropBit = utilpointer.Int32(configv1beta1.DefaultIPTablesDropBit)
obj.FailSwapOn = utilpointer.Bool(false)
obj.ContainerLogMaxSize = "10Mi"
obj.ContainerLogMaxFiles = utilpointer.Int32(5)
obj.ConfigMapAndSecretChangeDetectionStrategy = kubeletconfigv1beta1.GetChangeDetectionStrategy
obj.EnforceNodeAllocatable = []string{}
obj.VolumePluginDir = constants.DefaultVolumePluginDir
// Use the Default LoggingConfiguration option
componentbaseconfigv1alpha1.RecommendedLoggingConfiguration(&obj.Logging)
obj.EnableSystemLogHandler = utilpointer.Bool(true)
obj.EnableProfilingHandler = utilpointer.Bool(true)
obj.EnableDebugFlagsHandler = utilpointer.Bool(true)
obj.SeccompDefault = utilpointer.Bool(false)
obj.MemoryThrottlingFactor = utilpointer.Float64(configv1beta1.DefaultMemoryThrottlingFactor)
obj.RegisterNode = utilpointer.Bool(true)
}