1. 前言
    上一篇文章我把整个KubeEdge的宏观架构设计讲了一遍,今天的内容是实操实践,手把手教你搭建KubeEdge集群。

  2. 准备工作
    需要两台机器,不管是笔记本也好还是树莓派都可以,单是有一个前提,作为Master节点的机器的配置至少要达到2C4G,不然跑不了k8s。还要就是OS要是Linux的,别的系统不行。负载节点就无所谓啦,比如说树莓派3B+或者是树莓派4B+都可以。现在的树莓派配置也是相当的高了,arm的小板子也能做到4C 8G。

  3. 搭建K8s
    搭建K8s我已经在之前的文章中写了,不会的直接回去看。

  4. 安装Cloudcore
    安装有两种方式,一种源码编译手动安装,还有一种是使用ke提供的工具-keadm。手动安装比较繁琐,对于新手而言是一种很大的心智负担,最好大家还是都用keadm这个工具去安装,但是,这种方式安装最大的问题就是国内的墙的问题会导致很多某些资源无法下载,比如说 CRD的yaml,cloudcore启动的service,所以我会结合两者,采用半手动半工具的安装方式去帮助大家顺利的完成ke的集群搭建。

1 下载keadm

wget https://github.com/kubeedge/kubeedge/releases/download/v1.5.0/keadm-v1.5.0-linux-amd64.tar.gz

我写这篇文章的时候,ke的版本还是v1.5.0,所以我就以安装1.5.0版本的作为一个例子。

下载下来之后执行

tar -zxvf keadm-v1.5.0-linux-amd64.tar.gz # 解压keadm的tar.gz的包
cd keadm-v1.5.0-linux-amd64/keadm && chmod +x keadm && mv keadm /usr/local/bin

验证keadm是否安装成功

keadm version
version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.0", GitCommit:"8b0913e04ef4ef826af6715d336e23a66e3774df", GitTreeState:"clean", BuildDate:"2020-11-13T08:04:56Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

2 使用keadm安装cloudcore

keadm init --advertise-address=xxx.xx.xx.xx --kubeedge-version=1.5.0
Kubernetes version verification passed, KubeEdge installation will start...
--2021-02-11 13:20:41--  https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.76.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.76.133|:443... connected.
Unable to establish SSL connection.
Converted links in 0 files in 0 seconds.
Error: failed to run 'sh -c cd /etc/kubeedge/crds/devices && wget -k --no-check-certificate --progress=bar:force https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml' because of error : exit status 4
Usage:keadm init [flags]Examples:keadm init- This command will download and install the default version of KubeEdge cloud componentkeadm init --kubeedge-version=1.5.0  --kube-config=/root/.kube/config- kube-config is the absolute path of kubeconfig which used to secure connectivity between cloudcore and kube-apiserverFlags:--advertise-address string   Use this key to set IPs in cloudcore's certificate SubAltNames field. eg: 10.10.102.78,10.10.102.79--domainname string          Use this key to set domain names in cloudcore's certificate SubAltNames field. eg: www.cloudcore.cn,www.kubeedge.cn-h, --help                       help for init--kube-config string         Use this key to set kube-config path, eg: $HOME/.kube/config (default "/root/.kube/config")--kubeedge-version string    Use this key to download and use the required KubeEdge version--master string              Use this key to set K8s master address, eg: http://127.0.0.1:8080--tarballpath string         Use this key to set the temp directory path for KubeEdge tarball, if not exist, download itF0211 13:20:41.433946   15198 keadm.go:27] failed to run 'sh -c cd /etc/kubeedge/crds/devices && wget -k --no-check-certificate --progress=bar:force https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml' because of error : exit status 4
goroutine 1 [running]:
k8s.io/klog.stacks(0xc0000d3e00, 0xc000026480, 0x122, 0x176)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:883 +0xb9
k8s.io/klog.(*loggingT).output(0x2cb3c80, 0xc000000003, 0xc0000b4b60, 0x29d13f1, 0x8, 0x1b, 0x0)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:834 +0x35f
k8s.io/klog.(*loggingT).printDepth(0x2cb3c80, 0xc000000003, 0x1, 0xc000843f68, 0x1, 0x1)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:706 +0x12d
k8s.io/klog.(*loggingT).print(...)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:697
k8s.io/klog.Fatal(...)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:1264
main.main()/root/codes/src/github.com/kubeedge/kubeedge/keadm/cmd/keadm/keadm.go:27 +0x8a

–advertise-address=xxx.xx.xx.xx 这里的xxx.xx.xx.xx换成你master机器的ip,可以是内网地址,也可以是公网ip地址,–kubeedge-version=1.5.0 意思是指定安装的ke的版本,如果你默认不指定那么keadm会自动去下载最新的版本。很遗憾,我在执行

keadm init --advertise-address=xxx.xx.xx.xx --kubeedge-version=1.5.0

命令的时候出错了,这个错的问题在于网络被墙了,特别是在公有云的虚拟机上,出现这种问题的概率特别大,这种问题咋解决,一种是翻墙翻出去,另外一种是在/etc/hosts下添加如下内容

# GitHub Start
52.74.223.119 github.com
192.30.253.119 gist.github.com
54.169.195.247 api.github.com
185.199.111.153 assets-cdn.github.com
151.101.76.133 raw.githubusercontent.com
151.101.108.133 user-images.githubusercontent.com
151.101.76.133 gist.githubusercontent.com
151.101.76.133 cloud.githubusercontent.com
151.101.76.133 camo.githubusercontent.com
151.101.76.133 avatars0.githubusercontent.com
151.101.76.133 avatars1.githubusercontent.com
151.101.76.133 avatars2.githubusercontent.com
151.101.76.133 avatars3.githubusercontent.com
151.101.76.133 avatars4.githubusercontent.com
151.101.76.133 avatars5.githubusercontent.com
151.101.76.133 avatars6.githubusercontent.com
151.101.76.133 avatars7.githubusercontent.com
151.101.76.133 avatars8.githubusercontent.com
# GitHub End

添加这个的目的就是我们遇到的错误其实就是keadm初始化过程中可能无法解析raw.githubusercontent.com。
如果试了上述方法还是不行,那我只能用杀手锏了,我们回过头看错误

F0211 13:20:41.433946   15198 keadm.go:27] failed to run 'sh -c cd /etc/kubeedge/crds/devices && wget -k --no-check-certificate --progress=bar:force https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml'

这是下载devices_v1alpha2_device.yaml这个crd的yaml下载不了啊。熟悉源码的朋友一定知道这不就是用于设备接入的CRD嘛。一个叫Devicle,一个叫DeviceModel。其实我的做法就是从源码里把这两个crd搞下来不就好了嘛。

mkdir -p /etc/kubeedge/crds/devices && mkdir -p /etc/kubeedge/crds/reliablesyncs

按照这个路径创建文件夹 devices和reliablesyncs都是keadm去下载的

cd /etc/kubeedge/crds/devices && vim devices_v1alpha2_devicemodel.yaml ## 创建 evices_v1alpha2_devicemodel.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: devicemodels.devices.kubeedge.io
spec:group: devices.kubeedge.ionames:kind: DeviceModelplural: devicemodelsscope: Namespacedvalidation:openAPIV3Schema:properties:apiVersion:description: 'APIVersion defines the versioned schema of this representationof an object. Servers should convert recognized schemas to the latestinternal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'type: stringkind:description: 'Kind is a string value representing the REST resource thisobject represents. Servers may infer this from the endpoint the clientsubmits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'type: stringmetadata:type: objectspec:properties:properties:description: 'Required: List of device properties.'items:properties:description:description: The device property description.type: stringname:description: 'Required: The device property name.'type: stringtype:description: 'Required: PropertyType represents the type and datavalidation of the property.'properties:int:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWritedefaultValue:format: int64type: integermaximum:format: int64type: integerminimum:format: int64type: integerunit:description: The unit of the propertytype: stringrequired:- accessModetype: objectstring:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWritedefaultValue:type: stringrequired:- accessModetype: objectdouble:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWritedefaultValue:format: doubletype: numbermaximum:format: doubletype: numberminimum:format: doubletype: numberunit:description: The unit of the propertytype: stringrequired:- accessModetype: objectfloat:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWritedefaultValue:format: floattype: numbermaximum:format: floattype: numberminimum:format: floattype: numberunit:description: The unit of the propertytype: stringrequired:- accessModetype: objectboolean:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWritedefaultValue:type: booleanrequired:- accessModetype: objectbytes:properties:accessMode:description: 'Required: Access mode of property, ReadWriteor ReadOnly.'type: stringenum:- ReadOnly- ReadWriterequired:- accessModetype: objecttype: objectrequired:- name- typetype: objecttype: arraytype: objectversion: v1alpha2
cd /etc/kubeedge/crds/devices && vim devices_v1alpha2_device.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:labels:controller-tools.k8s.io: "1.0"name: devices.devices.kubeedge.io
spec:group: devices.kubeedge.ionames:kind: Deviceplural: devicesscope: Namespacedvalidation:openAPIV3Schema:properties:apiVersion:description: 'APIVersion defines the versioned schema of this representationof an object. Servers should convert recognized schemas to the latestinternal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'type: stringkind:description: 'Kind is a string value representing the REST resource thisobject represents. Servers may infer this from the endpoint the clientsubmits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'type: stringmetadata:type: objectspec:properties:deviceModelRef:description: 'Required: DeviceModelRef is reference to the device modelused as a template to create the device instance.'type: objectnodeSelector:description: NodeSelector indicates the binding preferences betweendevices and nodes. Refer to k8s.io/kubernetes/pkg/apis/core NodeSelectorfor more detailstype: objectprotocol:description: 'Required: The protocol configuration used to connect tothe device.'properties:bluetooth:description: Protocol configuration for bluetoothproperties:macAddress:description: Unique identifier assigned to the device.type: stringtype: objectmodbus:description: Protocol configuration for modbusproperties:slaveID:description: Required. 0-255format: int64type: integerminimum: 0maximum: 255required:- slaveIDtype: objectopcua:description: Protocol configuration for opc-uaproperties:certificate:description: Certificate for access opc server.type: stringpassword:description: Password for access opc server.type: stringprivateKey:description: PrivateKey for access opc server.type: stringsecurityMode:description: Defaults to "none".type: stringsecurityPolicy:description: Defaults to "none".type: stringtimeout:description: Timeout seconds for the opc server connection.???format: int64type: integerurl:description: 'Required: The URL for opc server endpoint.'type: stringuserName:description: Username for access opc server.type: stringrequired:- urltype: objectcommon:description: Common part of protocol configurationproperties:com:properties:baudRate:description: Required. BaudRate 115200|57600|38400|19200|9600|4800|2400|1800|1200|600|300|200|150|134|110|75|50format: int64type: integerenum:- 115200- 57600- 38400- 19200- 9600- 4800- 2400- 1800- 1200- 600- 300- 200- 150- 134- 110- 75- 50dataBits:description: Required. Valid values are 8, 7, 6, 5.format: int64type: integerenum:- 8- 7- 6- 5parity:description: Required. Valid options are "none", "even","odd". Defaults to "none".type: stringenum:- none- even- oddserialPort:description: Required.type: stringstopBits:description: Required. Bit that stops 1|2format: int64type: integerenum:- 1- 2required:- baudRate- dataBits- parity- serialPort- stopBitstype: objecttcp:properties:ip:description: Required.type: stringport:description: Required.format: int64type: integerrequired:- ip- porttype: objectcommType:description: Communication type, like tcp client, tcp server or COMtype: stringreconnTimeout:description: Reconnection timeouttype: integerreconnRetryTimes:description: Reconnecting retry timestype: integercollectTimeout:description: 'Define timeout of mapper collect from device.'format: int64type: integercollectRetryTimes:description: 'Define retry times of mapper will collect from device.'format: int64type: integercollectType:description: 'Define collect type, sync or async.'type: stringenum:- sync- asynccustomizedValues:description: Customized values for provided protocoltype: objecttype: objectcustomizedProtocol:description: Protocol configuration for customized Protocolproperties:protocolName:description: The name of protocoltype: stringconfigData:description: customized config datatype: objectrequired:- protocolNametype: objecttype: objectpropertyVisitors:description: 'Required: List of property visitors which describe howto access the device properties. PropertyVisitors must unique by propertyVisitor.propertyName.'items:properties:bluetooth:description: Bluetooth represents a set of additional visitorconfig fields of bluetooth protocol.properties:characteristicUUID:description: 'Required: Unique ID of the corresponding operation'type: stringdataConverter:description: Responsible for converting the data being readfrom the bluetooth device into a form that is understandableby the platformproperties:endIndex:description: 'Required: Specifies the end index of incomingbyte stream to be considered to convert the data thevalue specified should be inclusive for example if 3is specified it includes the third index'format: int64type: integerorderOfOperations:description: Specifies in what order the operations(whichare required to be performed to convert incoming datainto understandable form) are performeditems:properties:operationType:description: 'Required: Specifies the operationto be performed to convert incoming data'type: stringenum:- Add- Subtract- Multiply- DivideoperationValue:description: 'Required: Specifies with what valuethe operation is to be performed'format: doubletype: numbertype: objecttype: arrayshiftLeft:description: Refers to the number of bits to shift left,if left-shift operation is necessary for conversionformat: int64type: integershiftRight:description: Refers to the number of bits to shift right,if right-shift operation is necessary for conversionformat: int64type: integerstartIndex:description: 'Required: Specifies the start index of theincoming byte stream to be considered to convert thedata. For example: start-index:2, end-index:3 concatenatesthe value present at second and third index of the incomingbyte stream. If we want to reverse the order we cangive it as start-index:3, end-index:2'format: int64type: integerrequired:- endIndex- startIndextype: objectdataWrite:description: 'Responsible for converting the data coming fromthe platform into a form that is understood by the bluetoothdevice For example: "ON":[1], "OFF":[0]'type: objectrequired:- characteristicUUIDtype: objectmodbus:description: Modbus represents a set of additional visitor configfields of modbus protocol.properties:isRegisterSwap:description: Indicates whether the high and low register swapped.Defaults to false.type: booleanisSwap:description: Indicates whether the high and low byte swapped.Defaults to false.type: booleanlimit:description: 'Required: Limit number of registers to read/write.'format: int64type: integeroffset:description: 'Required: Offset indicates the starting registernumber to read/write data.'format: int64type: integerregister:description: 'Required: Type of register'type: stringenum:- CoilRegister- DiscreteInputRegister- InputRegister- HoldingRegisterscale:description: The scale to convert raw property data into finalunits. Defaults to 1.0format: doubletype: numberrequired:- limit- offset- registertype: objectopcua:description: Opcua represents a set of additional visitor configfields of opc-ua protocol.properties:browseName:description: The name of opc-ua nodetype: stringnodeID:description: 'Required: The ID of opc-ua node, e.g. "ns=1,i=1005"'type: stringrequired:- nodeIDtype: objectcustomizedProtocol:description: customized protocolproperties:protocolName:description: The name of protocoltype: stringconfigData:description: customized config datatype: objectrequired:- protocolName- configDatatype: objectpropertyName:description: 'Required: The device property name to be accessed.This should refer to one of the device properties defined inthe device model.'type: stringreportCycle:description: 'Define how frequent mapper will report the value.'format: int64type: integercollectCycle:description: 'Define how frequent mapper will collect from device.'format: int64type: integercustomizedValues:description: Customized values for visitor of provided protocolstype: objectrequired:- propertyNametype: objecttype: arraydata:properties:dataTopic:description: 'Topic used by mapper, all data collected from dataPropertiesshould be published to this topic,the default value is $ke/events/device/+/data/update'type: stringdataProperties:description: A list of data properties, which are not required to be processed by edgecoreitems:properties:propertyName:description: 'Required: The property name for which the desired/reportedvalues are specified. This property should be present in thedevice model.'type: stringmetadata:description: Additional metadata like filter policy, should be k-v formattype: objectrequired:- propertyNametype: objecttype: arraytype: objectrequired:- deviceModelRef- nodeSelectortype: objectstatus:properties:twins:description: A list of device twins containing desired/reported desired/reportedvalues of twin properties. A passive device won't have twin propertiesand this list could be empty.items:properties:desired:description: 'Required: the desired property value.'properties:metadata:description: Additional metadata like timestamp when the valuewas reported etc.type: objectvalue:description: 'Required: The value for this property.'type: stringrequired:- valuetype: objectpropertyName:description: 'Required: The property name for which the desired/reportedvalues are specified. This property should be present in thedevice model.'type: stringreported:description: 'Required: the reported property value.'properties:metadata:description: Additional metadata like timestamp when the valuewas reported etc.type: objectvalue:description: 'Required: The value for this property.'type: stringrequired:- valuetype: objectrequired:- propertyNametype: objecttype: arraytype: objectversion: v1alpha2

device的crd好了,现在去弄reliablesyncs的crd还是一样

cd /etc/kubeedge/crds/reliablesyncs && vim cluster_objectsync_v1alpha1.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:labels:controller-tools.k8s.io: "1.0"name: clusterobjectsyncs.reliablesyncs.kubeedge.io
spec:group: reliablesyncs.kubeedge.ionames:kind: ClusterObjectSyncplural: clusterobjectsyncsscope: Clustersubresources:status: {}validation:openAPIV3Schema:properties:apiVersion:description: 'APIVersion defines the versioned schema of this representationof an object. Servers should convert recognized schemas to the latestinternal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'type: stringkind:description: 'Kind is a string value representing the REST resource thisobject represents. Servers may infer this from the endpoint the clientsubmits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'type: stringmetadata:type: objectspec:properties:objectType:description: NodeSelector indicates the binding preferences betweendevices and nodes. Refer to k8s.io/kubernetes/pkg/apis/core NodeSelectorfor more detailstype: stringobjectName:description: 'Required: The protocol configuration used to connect tothe device.'type: stringstatus:properties:objectResourceVersion:description: 'Required: DeviceModelRef is reference to the device modelused as a template to create the device instance.'type: stringversion: v1alpha
cd /etc/kubeedge/crds/reliablesyncs && vim objectsync_v1alpha1.yaml
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:labels:controller-tools.k8s.io: "1.0"name: objectsyncs.reliablesyncs.kubeedge.io
spec:group: reliablesyncs.kubeedge.ionames:kind: ObjectSyncplural: objectsyncsscope: Namespacedsubresources:status: {}validation:openAPIV3Schema:properties:apiVersion:description: 'APIVersion defines the versioned schema of this representationof an object. Servers should convert recognized schemas to the latestinternal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'type: stringkind:description: 'Kind is a string value representing the REST resource thisobject represents. Servers may infer this from the endpoint the clientsubmits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'type: stringmetadata:type: objectspec:properties:objectType:description: NodeSelector indicates the binding preferences betweendevices and nodes. Refer to k8s.io/kubernetes/pkg/apis/core NodeSelectorfor more detailstype: stringobjectName:description: 'Required: The protocol configuration used to connect tothe device.'type: stringstatus:properties:objectResourceVersion:description: 'Required: DeviceModelRef is reference to the device modelused as a template to create the device instance.'type: stringversion: v1alpha1#

还有一个事情要提前说下,这些crd都准备好了之后,keadm会去下载kubedge的资源。我们实现准备好的话是不是就可以啦,主要还是怕你网络不行,网络ok的话就没有这个问题。
在 /etc/kubeedge下面执行

wget https://github.com/kubeedge/kubeedge/releases/download/v1.5.0/kubeedge-v1.5.0-linux-amd64.tar.gz
## 因为的机器是x86架构的处理器,所以是amd64,如果你是别的那就改下这个就行了。

这些都创建完了,切回去之后,再次执行

keadm init --advertise-address=xxx.xx.xx.xx --kubeedge-version=1.5.0
Kubernetes version verification passed, KubeEdge installation will start...
W0211 13:58:27.853894   23320 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 13:58:27.862976   23320 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 13:58:27.870072   23320 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 13:58:27.876587   23320 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
Expected or Default KubeEdge version 1.5.0 is already downloaded and will checksum for it.
kubeedge-v1.5.0-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.5.0-linux-amd64.tar.gz.txt content:
[Run as service] start to download service file for cloudcore
Output failed:  exit status 4
Error: fail to download service file,error:{failed to run command(cd /etc/kubeedge/ && sudo -E wget -t 5 -k --no-check-certificate https://raw.githubusercontent.com/kubeedge/kubeedge/release-1.5/build/tools/cloudcore.service), err:exit status 4}
Usage:keadm init [flags]Examples:keadm init- This command will download and install the default version of KubeEdge cloud componentkeadm init --kubeedge-version=1.5.0  --kube-config=/root/.kube/config- kube-config is the absolute path of kubeconfig which used to secure connectivity between cloudcore and kube-apiserverFlags:--advertise-address string   Use this key to set IPs in cloudcore's certificate SubAltNames field. eg: 10.10.102.78,10.10.102.79--domainname string          Use this key to set domain names in cloudcore's certificate SubAltNames field. eg: www.cloudcore.cn,www.kubeedge.cn-h, --help                       help for init--kube-config string         Use this key to set kube-config path, eg: $HOME/.kube/config (default "/root/.kube/config")--kubeedge-version string    Use this key to download and use the required KubeEdge version--master string              Use this key to set K8s master address, eg: http://127.0.0.1:8080--tarballpath string         Use this key to set the temp directory path for KubeEdge tarball, if not exist, download itF0211 13:58:30.352570   23320 keadm.go:27] fail to download service file,error:{failed to run command(cd /etc/kubeedge/ && sudo -E wget -t 5 -k --no-check-certificate https://raw.githubusercontent.com/kubeedge/kubeedge/release-1.5/build/tools/cloudcore.service), err:exit status 4}
goroutine 1 [running]:
k8s.io/klog.stacks(0xc000599300, 0xc0008ce2c0, 0x11a, 0x2a4)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:883 +0xb9
k8s.io/klog.(*loggingT).output(0x2cb3c80, 0xc000000003, 0xc0002f2850, 0x29d13f1, 0x8, 0x1b, 0x0)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:834 +0x35f
k8s.io/klog.(*loggingT).printDepth(0x2cb3c80, 0xc000000003, 0x1, 0xc00089ff68, 0x1, 0x1)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:706 +0x12d
k8s.io/klog.(*loggingT).print(...)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:697
k8s.io/klog.Fatal(...)/root/codes/src/github.com/kubeedge/kubeedge/vendor/k8s.io/klog/klog.go:1264
main.main()/root/codes/src/github.com/kubeedge/kubeedge/keadm/cmd/keadm/keadm.go:27 +0x8a

到了最后还是出了一个问题,还是网络的问题啊,意思是cloudcore的service文件下载不了,那没办法了,手动创建咯。

vim cloudcore.service
[Unit]
Description=cloudcore.service[Service]
Type=simple
ExecStart=/etc/kubeedge/kubeedge-v1.5.0-linux-amd64/cloud/cloudcore/cloudcore --logtostderr=false --log-file=/var/log/kubeedge/cloudcore.log -v=3
Restart=always
RestartSec=10[Install]
WantedBy=multi-user.target

然后我们再执行

keadm init --advertise-address=106.13.177.82 --kubeedge-version=1.5.0
Kubernetes version verification passed, KubeEdge installation will start...
W0211 14:04:38.942389   29815 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 14:04:38.950811   29815 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 14:04:38.966118   29815 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0211 14:04:38.975750   29815 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
Expected or Default KubeEdge version 1.5.0 is already downloaded and will checksum for it.
kubeedge-v1.5.0-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.5.0-linux-amd64.tar.gz.txt content:
[Run as service] service file already exisits in /etc/kubeedge//cloudcore.service, skip download
kubeedge-v1.5.0-linux-amd64/
kubeedge-v1.5.0-linux-amd64/edge/
kubeedge-v1.5.0-linux-amd64/edge/edgecore
kubeedge-v1.5.0-linux-amd64/cloud/
kubeedge-v1.5.0-linux-amd64/cloud/csidriver/
kubeedge-v1.5.0-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.5.0-linux-amd64/cloud/admission/
kubeedge-v1.5.0-linux-amd64/cloud/admission/admission
kubeedge-v1.5.0-linux-amd64/cloud/cloudcore/
kubeedge-v1.5.0-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.5.0-linux-amd64/versionKubeEdge cloudcore is running, For logs visit:  /var/log/kubeedge/cloudcore.log
CloudCore started

这就表示cloudcore已经安装完成了

  1. 校验cloudcore安装情况
  2. 检查进程的运行情况
ps aux | grep cloudcore
root       599  0.0  0.0  16188  1012 pts/0    S+   14:07   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox cloudcore
root     32150  0.8  1.2 1269852 51632 ?       Ssl  14:06   0:00 /etc/kubeedge/kubeedge-v1.5.0-linux-amd64/cloud/cloudcore/cloudcore --logtostderr=false --log-file=/var/log/kubeedge/cloudcore.log -v=3

如果你想把cloudcore交给systemed托管的话切记把cloudcore.service移到/etc/systemed/system下面然后再执行下systemctl daemon-reload
2. 查看k8s
正常的情况下cloudcore运行起来之后会在k8s器群创建一个叫kubeedge的namespace,这个ns下面有secret,存的就是ke集群的token cert啥的

k get secret -nkubeedge
NAME                  TYPE                                  DATA   AGE
casecret              Opaque                                2      21h
cloudcoresecret       Opaque                                2      21h
default-token-bt26c   kubernetes.io/service-account-token   3      21h
tokensecret           Opaque                                1      21h

如果你的结果和我的一样,恭喜你,你的ke的cloudcore已经顺利安装完成了。

  1. 安装edgecore
    edgecore的安装相比cloudcore而言简单很多,不过我们还是要靠keadm这个工具,先在边缘节点上安装keadm,安装方式和上面cloudcore的一样,这里就不重复说了。如果你的边缘节点的网络不是很好的话还是建议提早下载好ke的资源文件,和安装cloudcore的时候一样
mkdir -p /etc/kubeedge && wget https://github.com/kubeedge/kubeedge/releases/download/v1.5.0/kubeedge-v1.5.0-linux-arm.tar.gz
## 我用树莓派作为边缘节点的,所以下载的是arm架构的

直接执行

keadm join --cloudcore-ipport=xx.xx.xx.xx:10000 --kubeedge-version=1.5.0 --token=<token>

-cloudcore-ipport表示的是cloudcore的对外暴露的ip就是公网ip了,记得打开安全组的端口如果你是在公有云服务器上的
–kubeedge-version就是ke的版本
–token= 这个token从master机器上来,执行

keadm gettoken
b75afee838d35d8208a6880381ceca1aa1a1d72e289d307723da210a87cc6bf0.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTMxMTAwMTJ9.jtrC0EBjuq3VpwIGQ21a5aPq5dr3wJniH6XGVnu_rKE

下面的这一大串就是token,这个token就是用于去拿ca证书的。

  1. 检查ke集群是否安装完成
    在master机器上执行
k get no
NAME          STATUS   ROLES        AGE     VERSION
didi-cloud    Ready    <none>       3d15h   v1.19.7
k8s-master    Ready    master       4d      v1.19.7
raspberrypi   Ready    agent,edge   16h     v1.19.3-kubeedge-v1.5.0

树莓派就是ke的边缘节点,并且已经是ready,如果你的结果和我一样,那么恭喜你,你的ke的集群已经搭建完成了。

kubeedge集群搭建相关推荐

  1. 大数据调度平台Airflow(八):Airflow分布式集群搭建及测试

    目录 Airflow分布式集群搭建及测试 一.节点规划 二.airflow集群搭建步骤 1.在所有节点安装python3.7 2.在所有节点上安装airflow 三.初始化Airflow 1.每台节点 ...

  2. 2021年大数据Kafka(三):❤️Kafka的集群搭建以及shell启动命令脚本编写❤️

    全网最详细的大数据Kafka文章系列,强烈建议收藏加关注! 新文章都已经列出历史文章目录,帮助大家回顾前面的知识重点. 目录 系列历史文章 Kafka的集群搭建以及shell启动命令脚本编写 一.搭建 ...

  3. 2021年大数据ZooKeeper(二):ZooKeeper集群搭建

    目录 ZooKeeper集群搭建 第一步:下载zookeeeper的压缩包,下载网址如下 第二步:解压 第三步:修改配置文件 第四步:添加myid配置 ​​​​​​​第五步:安装包分发并修改myid的 ...

  4. 基于zookeeper的solrCloud集群搭建

    转自:https://blog.csdn.net/yougoule/article/details/78445759  基于原文对实践遇到的问题稍作补充 1.安装及搭建相关环境 1.1环境准备 cen ...

  5. Hbase基础(特点、架构、应用场景、集群搭建、HA设计)这一篇就够了

    Hbase基础(特点.架构.应用场景.集群搭建.HA设计)这一篇就够了 1. Hbase特点 2. Hbase VS RDBMS 3. Hbase架构及版本选择 4. Hbase应用场景 5. Ntp ...

  6. java kafka 集群消费_kafka集群搭建和使用Java写kafka生产者消费者

    转自:http://chengjianxiaoxue.iteye.com/blog/2190488 1 kafka集群搭建 1.zookeeper集群 搭建在110, 111,112 2.kafka使 ...

  7. Spark集群搭建【Spark+Hadoop+Scala+Zookeeper】

    1.安装Linux 需要:3台CentOS7虚拟机 IP:192.168.245.130,192.168.245.131,192.168.245.132(类似,尽量保持连续,方便记忆) 注意: 3台虚 ...

  8. 正式环境docker部署hyperf_应用部署 - Docker Swarm 集群搭建 - 《Hyperf v1.1.1 开发文档》 - 书栈网 · BookStack...

    Docker Swarm 集群搭建 现阶段,Docker容器技术已经相当成熟,就算是中小型公司也可以基于 Gitlab.Aliyun镜像服务.Docker Swarm 轻松搭建自己的 Docker集群 ...

  9. 大数据分布式集群搭建(1)

    在学习了几天的hadoop分布式集群搭建之后想写写文章记录一下一路以来遇到的困难和解决方案. 闲话不多说,进入正题. 一.环境及准备 因为只有一台电脑,所以需要用虚拟机来模拟环境. 本地机器用到软件: ...

  10. Eureka集群搭建,unavailable-replicas服务节点不可用解決方案

    最近由于项目需要搭建了eureka集群,集群搭建完成后,发现服务节点均在unavailable-replicas下,即说明集群搭建失败,各节点之间不能互相通信,网上查找了各种资料,终于解决,现将问题处 ...

最新文章

  1. Asterisk cli模块分析
  2. Linux内存管理【转】
  3. 千位亿万富豪调研:六成富豪担心继承人婚姻问题致财富外流
  4. keil 使用AC6 中文警告解决办法
  5. C++ 11 笔记 (四) : std::bind
  6. 【下载】推荐一款免费的人脸识别SDK
  7. boost::log模块实现格式化程序流的测试程序
  8. centos7安装mysql日志空白_centos7安装Mysql爬坑记录 - G
  9. LoadRunner脚本增强技巧之检查点
  10. [Link]选择一个 Python Web 框架:Django vs Flask vs Pyramid
  11. mysql中sysdate(),curdate(),curtime(),now()
  12. 关系分类 relation classification
  13. php算法复杂度,php的几个经典排序算法及时间复杂度和耗时​
  14. 教你ogg怎么转mp3格式
  15. SSM员工工资管理系统(Java毕设项目)
  16. HTML5响应式手机模板:【超炫购物模板】——仿拍鞋网商城手机网站模板( HTML+CSS+JavaScript) 企业手机网站模板...
  17. 极客日报:iPhone 13或有8款配色;vivo百万年薪招工程师;特斯拉新增行车记录视频紧急情况自动保存功能
  18. JavaSE编码实操
  19. 工业路由器的端口映射方法 NAT/DMZ/UPNP
  20. centos6.8经典实用大全、教程

热门文章

  1. 高德地图根据经纬度获取详细地址
  2. 比较两组数据的差异用什么图更直观_第四节 单因素完全随机实验设计及数据处理...
  3. 2022最新教程,半小时速通Git和Github的基本操作。
  4. Latex大括号左对齐
  5. “大数据”查询平台利用抖音导流,存个人信息泄露或倒卖风险
  6. NH7020固件网口分析与platoSDR固件对比
  7. JS 表单提交信息加密
  8. 玩转华为ENSP模拟器系列 | 配置OSPF ABR路由聚合示例
  9. WIN10你不能访问此共享文件夹,因为你组织的安全策略
  10. Fiddler - IOS 开启证书(描述文件与设备管理 / 证书信任设置)