github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/pkg/apis/componentconfig/edgecore/v1alpha1/default.go (about) 1 /* 2 Copyright 2019 The KubeEdge Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha1 18 19 import ( 20 "os" 21 "path" 22 23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 25 "github.com/kubeedge/kubeedge/common/constants" 26 metaconfig "github.com/kubeedge/kubeedge/pkg/apis/componentconfig/meta/v1alpha1" 27 "github.com/kubeedge/kubeedge/pkg/util" 28 ) 29 30 // NewDefaultEdgeCoreConfig returns a full EdgeCoreConfig object 31 func NewDefaultEdgeCoreConfig() *EdgeCoreConfig { 32 hostnameOverride, err := os.Hostname() 33 if err != nil { 34 hostnameOverride = constants.DefaultHostnameOverride 35 } 36 localIP, _ := util.GetLocalIP(hostnameOverride) 37 38 return &EdgeCoreConfig{ 39 TypeMeta: metav1.TypeMeta{ 40 Kind: Kind, 41 APIVersion: path.Join(GroupName, APIVersion), 42 }, 43 DataBase: &DataBase{ 44 DriverName: DataBaseDriverName, 45 AliasName: DataBaseAliasName, 46 DataSource: DataBaseDataSource, 47 }, 48 Modules: &Modules{ 49 Edged: &Edged{ 50 Enable: true, 51 NodeStatusUpdateFrequency: constants.DefaultNodeStatusUpdateFrequency, 52 RuntimeType: constants.DefaultRuntimeType, 53 DockerAddress: constants.DefaultDockerAddress, 54 RemoteRuntimeEndpoint: constants.DefaultRemoteRuntimeEndpoint, 55 RemoteImageEndpoint: constants.DefaultRemoteImageEndpoint, 56 NodeIP: localIP, 57 ClusterDNS: "", 58 ClusterDomain: "", 59 ConcurrentConsumers: constants.DefaultConcurrentConsumers, 60 EdgedMemoryCapacity: constants.DefaultEdgedMemoryCapacity, 61 PodSandboxImage: constants.DefaultPodSandboxImage, 62 ImagePullProgressDeadline: constants.DefaultImagePullProgressDeadline, 63 RuntimeRequestTimeout: constants.DefaultRuntimeRequestTimeout, 64 HostnameOverride: hostnameOverride, 65 RegisterNodeNamespace: constants.DefaultRegisterNodeNamespace, 66 RegisterNode: true, 67 InterfaceName: constants.DefaultInterfaceName, 68 DevicePluginEnabled: false, 69 GPUPluginEnabled: false, 70 ImageGCHighThreshold: constants.DefaultImageGCHighThreshold, 71 ImageGCLowThreshold: constants.DefaultImageGCLowThreshold, 72 MaximumDeadContainersPerPod: constants.DefaultMaximumDeadContainersPerPod, 73 CGroupDriver: CGroupDriverCGroupFS, 74 NetworkPluginName: "", 75 CNIConfDir: constants.DefaultCNIConfDir, 76 CNIBinDir: constants.DefaultCNIBinDir, 77 CNICacheDir: constants.DefaultCNICacheDir, 78 NetworkPluginMTU: constants.DefaultNetworkPluginMTU, 79 }, 80 EdgeHub: &EdgeHub{ 81 Enable: true, 82 Heartbeat: 15, 83 ProjectID: "e632aba927ea4ac2b575ec1603d56f10", 84 TLSCAFile: constants.DefaultCAFile, 85 TLSCertFile: constants.DefaultCertFile, 86 TLSPrivateKeyFile: constants.DefaultKeyFile, 87 Quic: &EdgeHubQUIC{ 88 Enable: false, 89 HandshakeTimeout: 30, 90 ReadDeadline: 15, 91 Server: "127.0.0.1:10001", 92 WriteDeadline: 15, 93 }, 94 WebSocket: &EdgeHubWebSocket{ 95 Enable: true, 96 HandshakeTimeout: 30, 97 ReadDeadline: 15, 98 Server: "127.0.0.1:10000", 99 WriteDeadline: 15, 100 }, 101 }, 102 EventBus: &EventBus{ 103 Enable: true, 104 MqttQOS: 0, 105 MqttRetain: false, 106 MqttSessionQueueSize: 100, 107 MqttServerExternal: "tcp://127.0.0.1:1883", 108 MqttServerInternal: "tcp://127.0.0.1:1884", 109 MqttMode: MqttModeExternal, 110 }, 111 MetaManager: &MetaManager{ 112 Enable: true, 113 ContextSendGroup: metaconfig.GroupNameHub, 114 ContextSendModule: metaconfig.ModuleNameEdgeHub, 115 PodStatusSyncInterval: constants.DefaultPodStatusSyncInterval, 116 }, 117 ServiceBus: &ServiceBus{ 118 Enable: false, 119 }, 120 DeviceTwin: &DeviceTwin{ 121 Enable: true, 122 }, 123 DBTest: &DBTest{ 124 Enable: false, 125 }, 126 EdgeMesh: &EdgeMesh{ 127 Enable: true, 128 LBStrategy: EdgeMeshDefaultLoadBalanceStrategy, 129 ListenInterface: EdgeMeshDefaultInterface, 130 ListenPort: EdgeMeshDefaultListenPort, 131 SubNet: EdgeMeshDefaultSubNet, 132 }, 133 }, 134 } 135 } 136 137 // NewMinEdgeCoreConfig returns a common EdgeCoreConfig object 138 func NewMinEdgeCoreConfig() *EdgeCoreConfig { 139 hostnameOverride, err := os.Hostname() 140 if err != nil { 141 hostnameOverride = constants.DefaultHostnameOverride 142 } 143 localIP, _ := util.GetLocalIP(hostnameOverride) 144 return &EdgeCoreConfig{ 145 TypeMeta: metav1.TypeMeta{ 146 Kind: Kind, 147 APIVersion: path.Join(GroupName, APIVersion), 148 }, 149 DataBase: &DataBase{ 150 DataSource: DataBaseDataSource, 151 }, 152 Modules: &Modules{ 153 Edged: &Edged{ 154 RuntimeType: constants.DefaultRuntimeType, 155 RemoteRuntimeEndpoint: constants.DefaultRemoteRuntimeEndpoint, 156 RemoteImageEndpoint: constants.DefaultRemoteImageEndpoint, 157 DockerAddress: constants.DefaultDockerAddress, 158 NodeIP: localIP, 159 ClusterDNS: "", 160 ClusterDomain: "", 161 PodSandboxImage: constants.DefaultPodSandboxImage, 162 HostnameOverride: hostnameOverride, 163 InterfaceName: constants.DefaultInterfaceName, 164 DevicePluginEnabled: false, 165 GPUPluginEnabled: false, 166 CGroupDriver: CGroupDriverCGroupFS, 167 }, 168 EdgeHub: &EdgeHub{ 169 Heartbeat: 15, 170 TLSCAFile: constants.DefaultCAFile, 171 TLSCertFile: constants.DefaultCertFile, 172 TLSPrivateKeyFile: constants.DefaultKeyFile, 173 WebSocket: &EdgeHubWebSocket{ 174 Enable: true, 175 HandshakeTimeout: 30, 176 ReadDeadline: 15, 177 Server: "127.0.0.1:10000", 178 WriteDeadline: 15, 179 }, 180 }, 181 EventBus: &EventBus{ 182 MqttQOS: 0, 183 MqttRetain: false, 184 MqttServerExternal: "tcp://127.0.0.1:1883", 185 MqttServerInternal: "tcp://127.0.0.1:1884", 186 MqttMode: MqttModeExternal, 187 }, 188 }, 189 } 190 }