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
40 changes: 8 additions & 32 deletions common/constants/default.go
Expand Up @@ -28,38 +28,17 @@ const (

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

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

DefaultStreamCAFile = "/etc/kubeedge/ca/streamCA.crt"
DefaultStreamCertFile = "/etc/kubeedge/certs/stream.crt"
DefaultStreamKeyFile = "/etc/kubeedge/certs/stream.key"

DefaultMqttCAFile = "/etc/kubeedge/ca/rootCA.crt"
DefaultMqttCertFile = "/etc/kubeedge/certs/server.crt"
DefaultMqttKeyFile = "/etc/kubeedge/certs/server.key"

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

// Edged
DefaultRootDir = "/var/lib/edged"
DefaultDockerAddress = "unix:///var/run/docker.sock"
DefaultRuntimeType = "remote"
DefaultDockershimRootDir = "/var/lib/dockershim"
DefaultEdgedMemoryCapacity = 7852396000
DefaultRemoteRuntimeEndpoint = "unix:///run/containerd/containerd.sock"
DefaultRemoteImageEndpoint = "unix:///run/containerd/containerd.sock"
DefaultMosquittoImage = "eclipse-mosquitto:1.6.15"
DefaultDockerAddress = "unix:///var/run/docker.sock"
DefaultDockershimRootDir = "/var/lib/dockershim"
DefaultRuntimeType = "remote"
DefaultEdgedMemoryCapacity = 7852396000
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"
Expand All @@ -69,9 +48,6 @@ const (
DefaultMaximumDeadContainersPerPod = 1
DefaultHostnameOverride = "default-edge-node"
DefaultRegisterNodeNamespace = "default"
DefaultCNIConfDir = "/etc/cni/net.d"
DefaultCNIBinDir = "/opt/cni/bin"
DefaultCNICacheDir = "/var/lib/cni/cache"
DefaultNetworkPluginMTU = 1500
DefaultConcurrentConsumers = 5
DefaultCgroupRoot = ""
Expand Down
33 changes: 33 additions & 0 deletions common/constants/default_others.go
@@ -0,0 +1,33 @@
//go:build !windows

package constants

// Resources
const (
// Certificates
DefaultConfigDir = "/etc/kubeedge/config/"
DefaultCAFile = "/etc/kubeedge/ca/rootCA.crt"
DefaultCAKeyFile = "/etc/kubeedge/ca/rootCA.key"
DefaultCertFile = "/etc/kubeedge/certs/server.crt"
DefaultKeyFile = "/etc/kubeedge/certs/server.key"

DefaultStreamCAFile = "/etc/kubeedge/ca/streamCA.crt"
DefaultStreamCertFile = "/etc/kubeedge/certs/stream.crt"
DefaultStreamKeyFile = "/etc/kubeedge/certs/stream.key"

DefaultMqttCAFile = "/etc/kubeedge/ca/rootCA.crt"
DefaultMqttCertFile = "/etc/kubeedge/certs/server.crt"
DefaultMqttKeyFile = "/etc/kubeedge/certs/server.key"

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

// Edged
DefaultRootDir = "/var/lib/edged"
DefaultRemoteRuntimeEndpoint = "unix:///run/containerd/containerd.sock"
DefaultRemoteImageEndpoint = "unix:///run/containerd/containerd.sock"
DefaultCNIConfDir = "/etc/cni/net.d"
DefaultCNIBinDir = "/opt/cni/bin"
DefaultCNICacheDir = "/var/lib/cni/cache"
DefaultVolumePluginDir = "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/"
)
36 changes: 36 additions & 0 deletions common/constants/default_windows.go
@@ -0,0 +1,36 @@
//go:build windows
wujunyi792 marked this conversation as resolved.
Show resolved Hide resolved

package constants

// Module name and group name
const ()

// 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"

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"
DefaultRemoteRuntimeEndpoint = "npipe://./pipe/containerd-containerd"
DefaultRemoteImageEndpoint = "npipe://./pipe/containerd-containerd"
DefaultCNIConfDir = "c:\\etc\\cni\\net.d"
DefaultCNIBinDir = "c:\\opt\\cni\\bin"
DefaultCNICacheDir = "c:\\var\\lib\\cni\\cache"
DefaultVolumePluginDir = "C:\\usr\\libexec\\kubernetes\\kubelet-plugins\\volume\\exec\\"
)
3 changes: 2 additions & 1 deletion edge/cmd/edgecore/app/server.go
Expand Up @@ -176,7 +176,8 @@ func environmentCheck() error {
for _, process := range processes {
processName, err := process.Name()
if err != nil {
return err
// err usually cant be fixed by user, so just skip it instead of return error (we only check named process)
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"
)
22 changes: 2 additions & 20 deletions edge/pkg/devicetwin/dmiserver/server.go
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"sync"
"time"

Expand All @@ -46,9 +45,8 @@ import (
)

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

type server struct {
Expand Down Expand Up @@ -179,22 +177,6 @@ func CreateMessageTwinUpdate(name, valueType, value string) ([]byte, error) {
return msg, err
}

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) {
return nil
} else {
return fmt.Errorf("fail to stat uds socket path")
}
}

func StartDMIServer(cache *DMICache) {
err := initSock(SockPath)
if err != nil {
Expand Down
26 changes: 26 additions & 0 deletions edge/pkg/devicetwin/dmiserver/server_others.go
@@ -0,0 +1,26 @@
//go:build !windows

package dmiserver

import (
"fmt"
"os"

"k8s.io/klog/v2"
)

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) {
return nil
} else {
return fmt.Errorf("fail to stat uds socket path")
}
}
22 changes: 22 additions & 0 deletions edge/pkg/devicetwin/dmiserver/server_windows.go
@@ -0,0 +1,22 @@
//go:build windows

package dmiserver

import (
"fmt"
"os"

"k8s.io/klog/v2"
)

func initSock(sockPath string) error {
klog.Infof("init uds socket: %s", sockPath)
err := os.Remove(sockPath)
if os.IsNotExist(err) {
return nil
} else if err != nil {
klog.Error(err)
return fmt.Errorf("fail to stat uds socket path")
}
return nil
}
3 changes: 3 additions & 0 deletions edge/pkg/edged/config/config.go
Expand Up @@ -187,6 +187,9 @@ func ConvertConfigEdgedFlagToConfigKubeletFlag(in *v1alpha2.TailoredKubeletFlag,
out.RegisterSchedulable = in.RegisterSchedulable
out.KeepTerminatedPodVolumes = in.KeepTerminatedPodVolumes
out.SeccompDefault = in.SeccompDefault
out.WindowsPriorityClass = in.WindowsPriorityClass
// out.WindowsService may always be false, or kubelet will try to install itself as a windows service.
// out.WindowsService = in.WindowsService

// container-runtime-specific options
out.ContainerRuntime = in.ContainerRuntime
Expand Down
12 changes: 8 additions & 4 deletions pkg/apis/componentconfig/edgecore/v1alpha2/default.go
Expand Up @@ -30,14 +30,14 @@ import (
)

// NewDefaultEdgeCoreConfig returns a full EdgeCoreConfig object
func NewDefaultEdgeCoreConfig() *EdgeCoreConfig {
func NewDefaultEdgeCoreConfig() (config *EdgeCoreConfig) {
hostnameOverride := util.GetHostname()
localIP, _ := util.GetLocalIP(hostnameOverride)

defaultTailedKubeletConfig := TailoredKubeletConfiguration{}
SetDefaultsKubeletConfiguration(&defaultTailedKubeletConfig)

return &EdgeCoreConfig{
config = &EdgeCoreConfig{
TypeMeta: metav1.TypeMeta{
Kind: Kind,
APIVersion: path.Join(GroupName, APIVersion),
Expand Down Expand Up @@ -67,6 +67,7 @@ func NewDefaultEdgeCoreConfig() *EdgeCoreConfig {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
WindowsPriorityClass: DefaultWindowsPriorityClass,
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
Expand Down Expand Up @@ -158,17 +159,18 @@ func NewDefaultEdgeCoreConfig() *EdgeCoreConfig {
},
},
}
return
}

// NewMinEdgeCoreConfig returns a common EdgeCoreConfig object
func NewMinEdgeCoreConfig() *EdgeCoreConfig {
func NewMinEdgeCoreConfig() (config *EdgeCoreConfig) {
hostnameOverride := util.GetHostname()
localIP, _ := util.GetLocalIP(hostnameOverride)

defaultTailedKubeletConfig := TailoredKubeletConfiguration{}
SetDefaultsKubeletConfiguration(&defaultTailedKubeletConfig)

return &EdgeCoreConfig{
config = &EdgeCoreConfig{
TypeMeta: metav1.TypeMeta{
Kind: Kind,
APIVersion: path.Join(GroupName, APIVersion),
Expand Down Expand Up @@ -196,6 +198,7 @@ func NewMinEdgeCoreConfig() *EdgeCoreConfig {
NodeLabels: make(map[string]string),
RegisterNode: true,
RegisterSchedulable: true,
WindowsPriorityClass: DefaultWindowsPriorityClass,
},
CustomInterfaceName: "",
RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace,
Expand Down Expand Up @@ -231,4 +234,5 @@ func NewMinEdgeCoreConfig() *EdgeCoreConfig {
},
},
}
return
}
@@ -1,5 +1,5 @@
/*
Copyright 2022 The KubeEdge Authors.
Copyright 2023 The KubeEdge Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,18 +31,11 @@ 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"

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

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
func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.SyncFrequency = metav1.Duration{Duration: 1 * time.Minute}
Expand All @@ -62,8 +55,6 @@ func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.ImageGCHighThresholdPercent = utilpointer.Int32Ptr(constants.DefaultImageGCHighThreshold)
obj.ImageGCLowThresholdPercent = utilpointer.Int32Ptr(constants.DefaultImageGCLowThreshold)
obj.VolumeStatsAggPeriod = metav1.Duration{Duration: time.Minute}
obj.CgroupsPerQOS = utilpointer.BoolPtr(true)
obj.CgroupDriver = "cgroupfs"
obj.CPUManagerPolicy = "none"
// Keep the same as default NodeStatusUpdateFrequency
obj.CPUManagerReconcilePeriod = metav1.Duration{Duration: 10 * time.Second}
Expand All @@ -75,8 +66,6 @@ func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.MaxPods = 110
// default nil or negative value to -1 (implies node allocatable pid limit)
obj.PodPidsLimit = utilpointer.Int64(-1)
obj.ResolverConfig = utilpointer.String(kubetypes.ResolvConfDefault)
obj.CPUCFSQuota = utilpointer.BoolPtr(true)
obj.CPUCFSQuotaPeriod = &metav1.Duration{Duration: 100 * time.Millisecond}
obj.NodeStatusMaxImages = utilpointer.Int32Ptr(0)
obj.MaxOpenFiles = 1000000
Expand All @@ -93,7 +82,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 All @@ -102,4 +91,10 @@ func SetDefaultsKubeletConfiguration(obj *TailoredKubeletConfiguration) {
obj.SeccompDefault = utilpointer.BoolPtr(false)
obj.MemoryThrottlingFactor = utilpointer.Float64Ptr(configv1beta1.DefaultMemoryThrottlingFactor)
obj.RegisterNode = utilpointer.BoolPtr(true)

obj.EnforceNodeAllocatable = DefaultNodeAllocatableEnforcement
obj.CgroupDriver = DefaultCgroupDriver
obj.CgroupsPerQOS = utilpointer.Bool(DefaultCgroupsPerQOS)
obj.ResolverConfig = utilpointer.String(DefaultResolverConfig)
obj.CPUCFSQuota = utilpointer.Bool(DefaultCPUCFSQuota)
}