forked from kubeedge/kubeedge
/
types.go
266 lines (231 loc) · 8.89 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
Copyright 2019 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.
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 common
import (
"time"
)
//InitOptions has the kubeedge cloud init information filled by CLI
type InitOptions struct {
KubeEdgeVersion string
KubernetesVersion string
DockerVersion string
KubeConfig string
}
//JoinOptions has the kubeedge cloud init information filled by CLI
type JoinOptions struct {
InitOptions
CertPath string
EdgeControllerIP string
K8SAPIServerIPPort string
EdgeNodeID string
RuntimeType string
}
//InstallState enum set used for verifying a tool version is installed in host
type InstallState uint8
//Difference enum values for type InstallState
const (
NewInstallRequired InstallState = iota
AlreadySameVersionExist
DefVerInstallRequired
VersionNAInRepo
)
//ModuleRunning is defined to know the running status of KubeEdge components
type ModuleRunning uint8
//Different possible values for ModuleRunning type
const (
NoneRunning ModuleRunning = iota
KubeEdgeCloudRunning
KubeEdgeEdgeRunning
)
//ToolsInstaller interface for tools with install and teardown methods.
type ToolsInstaller interface {
InstallTools() error
TearDown() error
}
//OSTypeInstaller interface for methods to be executed over a specified OS distribution type
type OSTypeInstaller interface {
IsToolVerInRepo(string, string) (bool, error)
IsDockerInstalled(string) (InstallState, error)
InstallDocker() error
InstallMQTT() error
IsK8SComponentInstalled(string, string) (InstallState, error)
InstallK8S() error
StartK8Scluster() error
InstallKubeEdge() error
SetDockerVersion(string)
SetK8SVersionAndIsNodeFlag(version string, flag bool)
SetKubeEdgeVersion(string)
RunEdgeCore() error
KillKubeEdgeBinary(string) error
IsKubeEdgeProcessRunning(string) (bool, error)
}
//FlagData stores value and default value of the flags used in this command
type FlagData struct {
Val interface{}
DefVal interface{}
}
//NodeMetaDataLabels defines
type NodeMetaDataLabels struct {
Name string
}
//NodeMetaDataSt defines
type NodeMetaDataSt struct {
Name string
Labels NodeMetaDataLabels
}
//NodeDefinition defines
type NodeDefinition struct {
Kind string
APIVersion string
MetaData NodeMetaDataSt
}
//KubeEdgeControllerConfig has all the below fields; (data taken from "github.com/kubeedge/kubeedge/cloud/pkg/controller/config/kube.go")
type KubeEdgeControllerConfig struct {
//Master is the url of edge master(kube api server)
Master string `yaml:"master"`
//Namespace is the namespace to watch(default is NamespaceAll)
Namespace string `yaml:"namespace"`
//ContentType is the content type communicate with edge master(default is "application/vnd.kubernetes.protobuf")
ContentType string `yaml:"content_type"`
//QPS is the QPS communicate with edge master(default is 100.0)
QPS uint `yaml:"qps"`
//Burst default is 10
Burst uint `yaml:"burst"`
//NodeFrequency is the time duration for update node status(default is 20s)
NodeUpdateFrequency time.Duration `yaml:"node_update_frequency"`
//KubeConfig is the config used connect to edge master
KubeConfig string `yaml:"kubeconfig"`
}
//CloudControllerSt consists information to access api-server @ master
type CloudControllerSt struct {
Kube KubeEdgeControllerConfig `yaml:"kube"`
}
//CloudHubSt represents configuration options for http access
type CloudHubSt struct {
IPAddress string `yaml:"address"`
Port uint16 `yaml:"port"`
CA string `yaml:"ca"`
Cert string `yaml:"cert"`
Key string `yaml:"key"`
KeepAliveInterval uint32 `yaml:"keepalive-interval"`
WriteTimeout uint32 `yaml:"write-timeout"`
NodeLimit uint32 `yaml:"node-limit"`
}
//DeviceControllerSt consists information to access api-server @ master for Device CRD
type DeviceControllerSt struct {
Kube KubeEdgeControllerConfig `yaml:"kube"`
}
//ControllerYaml has the edgecontroller yaml configuration/content which shall be written in conf/controller.yaml for cloud component
type ControllerYaml struct {
Controller CloudControllerSt `yaml:"controller"`
CloudHub CloudHubSt `yaml:"cloudhub"`
DeviceController DeviceControllerSt `yaml:"devicecontroller"`
}
//ModulesSt contains the list of modules which shall be added to edgecontroller and edge_core respectively during init
type ModulesSt struct {
Enabled []string `yaml:"enabled"`
}
//ModulesYaml is the module list which shall be written in conf/modules.yaml for cloud and edge component
type ModulesYaml struct {
Modules ModulesSt `yaml:"modules"`
}
//LoggingYaml shall be written in conf/logging.yaml for cloud and edge component
type LoggingYaml struct {
LoggerLevel string `yaml:"loggerLevel,omitempty"`
EnableRsysLog bool `yaml:"enableRsyslog,omitempty"`
LogFormatText bool `yaml:"logFormatText,omitempty"`
Writers []string `yaml:"writers,omitempty"`
LoggerFile string `yaml:"loggerFile,omitempty"`
}
//MQTTMode = # 0: internal mqtt broker enable only. 1: internal and external mqtt broker enable. 2: external mqtt broker enable only.
type MQTTMode uint8
//Different message exchange mode supported in KubeEdge using MQTT
const (
MQTTInternalMode MQTTMode = iota
MQTTInternalExternalMode
MQTTExternalMode
)
//MQTTQoSType = # 0: QOSAtMostOnce, 1: QOSAtLeastOnce, 2: QOSExactlyOnce.
type MQTTQoSType uint8
//Different MQTT QoS
const (
MQTTQoSAtMostOnce MQTTQoSType = iota
MQTTQoSAtLeastOnce
MQTTQoSExactlyOnce
)
//MQTTConfig contains MQTT specific config to use MQTT broker
type MQTTConfig struct {
Server string `yaml:"server"`
InternalServer string `yaml:"internal-server"`
Mode MQTTMode `yaml:"mode"`
QOS MQTTQoSType `yaml:"qos"`
Retain bool `yaml:"retain"`
SessionQueueSize uint64 `yaml:"session-queue-size"`
}
//WebSocketSt contains websocket configurations to communicate between CloudHub and EdgeHub
type WebSocketSt struct {
URL string `yaml:"url"`
CertFile string `yaml:"certfile"`
KeyFile string `yaml:"keyfile"`
HandshakeTimeout uint16 `yaml:"handshake-timeout"`
WriteDeadline uint16 `yaml:"write-deadline"`
ReadDeadline uint16 `yaml:"read-deadline"`
}
//ControllerSt contain edgecontroller config which edge component uses
type ControllerSt struct {
Placement bool `yaml:"placement"`
Heartbeat uint32 `yaml:"heartbeat"`
RefreshAKSKInterval uint16 `yaml:"refresh-ak-sk-interval"`
AuthInfoFilesPath string `yaml:"auth-info-files-path"`
PlacementURL string `yaml:"placement-url"`
ProjectID string `yaml:"project-id"`
NodeID string `yaml:"node-id"`
}
//EdgeDSt contains configuration required by edged module in KubeEdge component
type EdgeDSt struct {
RegisterNodeNamespace string `yaml:"register-node-namespace"`
HostnameOverride string `yaml:"hostname-override"`
InterfaceName string `yaml:"interface-name"`
NodeStatusUpdateFrequency uint16 `yaml:"node-status-update-frequency"`
DevicePluginEnabled bool `yaml:"device-plugin-enabled"`
GPUPluginEnabled bool `yaml:"gpu-plugin-enabled"`
ImageGCHighThreshold uint16 `yaml:"image-gc-high-threshold"`
ImageGCLowThreshold uint16 `yaml:"image-gc-low-threshold"`
MaximumDeadContainersPerContainer uint16 `yaml:"maximum-dead-containers-per-container"`
DockerAddress string `yaml:"docker-address"`
Version string `yaml:"version"`
EdgedMemory uint16 `yaml:"edged-memory-capacity-bytes"`
RuntimeType string `yaml:"runtime-type"`
RuntimeEndpoint string `yaml:"remote-runtime-endpoint"`
ImageEndpoint string `yaml:"remote-image-endpoint"`
RequestTimeout uint16 `yaml:"runtime-request-timeout"`
PodSandboxImage string `yaml:"podsandbox-image"`
}
type Mesh struct {
LB LoadBalance `yaml:"loadbalance"`
}
type LoadBalance struct {
StrategyName string `yaml:"strategy-name"`
}
//EdgeHubSt contains both websocket and controller config
type EdgeHubSt struct {
WebSocket WebSocketSt `yaml:"websocket"`
Controller ControllerSt `yaml:"controller"`
}
//EdgeYamlSt content is written into conf/edge.yaml
type EdgeYamlSt struct {
MQTT MQTTConfig `yaml:"mqtt"`
EdgeHub EdgeHubSt `yaml:"edgehub"`
EdgeD EdgeDSt `yaml:"edged"`
Mesh Mesh `yaml:"mesh"`
}