# 关于kubeedge的crd# kubectl get CustomResourceDefinition -A |grep edgeclusterobjectsyncs.reliablesyncs.kubeedge.io2021-05-25T02:35:25Zdevicemodels.devices.kubeedge.io2021-05-25T02:33:32Zdevices.devices.kubeedge.io2021-05-25T02:29:00Zobjectsyncs.reliablesyncs.kubeedge.io2021-05-25T02:44:23Zruleendpoints.rules.kubeedge.io2021-05-25T02:44:24Zrules.rules.kubeedge.io2021-05-25T02:44:23Z# kubeedge device-model 和 device的crd# kubectl get CustomResourceDefinition -A |grep edge |grep devicedevicemodels.devices.kubeedge.io2021-05-25T02:33:32Zdevices.devices.kubeedge.io2021-05-25T02:29:00Z
// ChannelMessageQueue is the channel implementation of MessageQueuetype ChannelMessageQueue struct {
queuePool sync.Map
storePool sync.Map
listQueuePool sync.Map
listStorePool sync.Map
objectSyncLister reliablesyncslisters.ObjectSyncLister
clusterObjectSyncLister reliablesyncslisters.ClusterObjectSyncLister
}
// Add message to the queue:
key,_:=getMsgKey(&message)
nodeStore.Add(message)
nodeQueue.Add(message)
// Get the message from the queue:
key,_:=nodeQueue.Get()
msg,_,_:=nodeStore.GetByKey(key.(string))
// Structure of the message key:
Key = resourceType/resourceNamespace/resourceName
type ClusterObjectSync struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ClusterObjectSyncSpec `json:"spec,omitempty"`
Status ClusterObjectSyncStatus `json:"spec,omitempty"`
}
// ClusterObjectSyncSpec stores the details of objects that sent to the edge.type ClusterObjectSyncSpec struct {
// Required: ObjectGroupVerion is the group and version of the object// that was successfully sent to the edge node.
ObjectGroupVerion string`json:"objectGroupVerion,omitempty"`// Required: ObjectKind is the type of the object// that was successfully sent to the edge node.
ObjectKind string`json:"objectKind,omitempty"`// Required: ObjectName is the name of the object// that was successfully sent to the edge node.
ObjectName string`json:"objectName,omitempty"`
}
// ClusterObjectSyncSpec stores the resourceversion of objects that sent to the edge.type ClusterObjectSyncStatus struct {
// Required: ObjectResourceVersion is the resourceversion of the object// that was successfully sent to the edge node.
ObjectResourceVersion string`json:"objectResourceVersion,omitempty"`
}
type ClusterObjectSync struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ObjectSyncSpec `json:"spec,omitempty"`
Status ObjectSyncStatus `json:"spec,omitempty"`
}
// ObjectSyncSpec stores the details of objects that sent to the edge.type ObjectSyncSpec struct {
// Required: ObjectGroupVerion is the group and version of the object// that was successfully sent to the edge node.
ObjectGroupVerion string`json:"objectGroupVerion,omitempty"`// Required: ObjectKind is the type of the object// that was successfully sent to the edge node.
ObjectKind string`json:"objectKind,omitempty"`// Required: ObjectName is the name of the object// that was successfully sent to the edge node.
ObjectName string`json:"objectName,omitempty"`
}
// ClusterObjectSyncSpec stores the resourceversion of objects that sent to the edge.type ObjectSyncStatus struct {
// Required: ObjectResourceVersion is the resourceversion of the object// that was successfully sent to the edge node.
ObjectResourceVersion string`json:"objectResourceVersion,omitempty"`
}
# ./keadm -h
+----------------------------------------------------------+
| KEADM |
| Easily bootstrap a KubeEdge cluster |
| |
| Please give us feedback at: |
| https://github.com/kubeedge/kubeedge/issues |
+----------------------------------------------------------+
Create a cluster with cloud node
(which controls the edge node cluster), and edge nodes
(where native containerized application, in the form of
pods and deployments run), connects to devices.
Usage:
keadm [command]
Examples:
+----------------------------------------------------------+
| On the cloud machine: |
+----------------------------------------------------------+
| master node (on the cloud)# sudo keadm init |
+----------------------------------------------------------+
+----------------------------------------------------------+
| On the edge machine: |
+----------------------------------------------------------+
| worker node (at the edge)# sudo keadm join <flags> |
+----------------------------------------------------------+
You can then repeat the second step on, as many other machines as you like.
Available Commands:
debug debug function to help diagnose the cluster
gettoken To get the token for edge nodes to join the cluster
help Help about any command
init Bootstraps cloud component. Checks and install (if required) the pre-requisites.
join Bootstraps edge component. Checks and install (if required) the pre-requisites. Execute it on any edge node machine you wish to join
reset Teardowns KubeEdge (cloud & edge) component
version Print the version of keadm
Flags:
-h, --help help for keadm
Use "keadm [command] --help" for more information about a command.
Setup Cloud Side (KubeEdge Master Node)
By default ports 10000 and 10002 in your cloudcore needs to be accessible for your edge nodes.
keadm init will install cloudcore, generate the certs and install the CRDs. It also provides a flag by which a specific version can be set.
在master节点上执行:
采用默认版本参数
1
2
3
# keadm init --advertise-address="THE-EXPOSED-IP"(only work since 1.3 release)
keadm init --advertise-address="10.7.11.213"
Kubernetes version verification passed, KubeEdge installation will start...
...
KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]# ./keadm init --advertise-address="10.7.11.213" --kubeedge-version=1.6.2 --kube-config=/root/.kube/config
Kubernetes version verification passed, KubeEdge installation will start...
Expected or Default KubeEdge version 1.6.2 is already downloaded and will checksum for it.
kubeedge-v1.6.2-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.6.2-linux-amd64.tar.gz.txt content:
kubeedge-v1.6.2-linux-amd64.tar.gz in your path checksum failed and do you want to delete this file and try to download again?
[y/N]:
y
I0524 17:09:26.209161 8227 common.go:271] kubeedge-v1.6.2-linux-amd64.tar.gz have been deleted and will try to download again
kubeedge-v1.6.2-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.6.2-linux-amd64.tar.gz.txt content:
[Run as service] service file already exisits in /etc/kubeedge//cloudcore.service, skip download
kubeedge-v1.6.2-linux-amd64/
kubeedge-v1.6.2-linux-amd64/edge/
kubeedge-v1.6.2-linux-amd64/edge/edgecore
kubeedge-v1.6.2-linux-amd64/cloud/
kubeedge-v1.6.2-linux-amd64/cloud/csidriver/
kubeedge-v1.6.2-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.6.2-linux-amd64/cloud/admission/
kubeedge-v1.6.2-linux-amd64/cloud/admission/admission
kubeedge-v1.6.2-linux-amd64/cloud/cloudcore/
kubeedge-v1.6.2-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.6.2-linux-amd64/version
KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log
CloudCore started
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]# ps -ef |grep -i cloudcore
root 25669 1 0 17:13 pts/11 00:00:00 /usr/local/bin/cloudcore
root 30844 94002 0 17:16 pts/11 00:00:00 grep --color=auto -i cloudcore
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
keadm join will install edgecore and mqtt. It also provides a flag by which a specific version can be set.
Example:
1
2
# keadm join --cloudcore-ipport=192.168.20.50:10000 --token=27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE# IMPORTANT NOTE: 1. --cloudcore-ipport flag is a mandatory flag. 1. If you want to apply certificate for edge node automatically, --token is needed. 1. The kubeEdge version used in cloud and edge side should be same.
Host has mosquit+ already installed and running. Hence skipping the installation steps !!!
...
KubeEdge edgecore is running, For logs visit: /var/log/kubeedge/edgecore.log
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]# ./keadm gettoken
9ecb7342293641c71fe70ac296e349bf0fce395618cb66c27e0643c3b8c985b5.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjE5MzQwMzh9.5b8f16RDwRhCnnebz_3oc4yn3CnfXLz3kMl7-tPoRD0
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]# ./keadm join --cloudcore-ipport=10.7.11.213:10000 --token=9ecb7342293641c71fe70ac296e349bf0fce395618cb66c27e0643c3b8c985b5.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjE5MzQwMzh9.5b8f16RDwRhCnnebz_3oc4yn3CnfXLz3kMl7-tPoRD0
install MQTT service successfully.
Expected or Default KubeEdge version 1.6.2 is already downloaded and will checksum for it.
kubeedge-v1.6.2-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.6.2-linux-amd64.tar.gz.txt content:
kubeedge-v1.6.2-linux-amd64.tar.gz in your path checksum failed and do you want to delete this file and try to download again?
[y/N]:
N
W0524 17:35:22.099204 64615 common.go:276] failed to checksum and will continue to install.
[Run as service] start to download service file for edgecore
[Run as service] success to download service file for edgecore
kubeedge-v1.6.2-linux-amd64/
kubeedge-v1.6.2-linux-amd64/edge/
kubeedge-v1.6.2-linux-amd64/edge/edgecore
kubeedge-v1.6.2-linux-amd64/cloud/
kubeedge-v1.6.2-linux-amd64/cloud/csidriver/
kubeedge-v1.6.2-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.6.2-linux-amd64/cloud/admission/
kubeedge-v1.6.2-linux-amd64/cloud/admission/admission
kubeedge-v1.6.2-linux-amd64/cloud/cloudcore/
kubeedge-v1.6.2-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.6.2-linux-amd64/version
KubeEdge edgecore is running, For logs visit: journalctl -u edgecore.service -b
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
# edgecore.service的下载和加载目录位置
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]# find / -name edgecore.service
/etc/systemd/system/multi-user.target.wants/edgecore.service
/etc/systemd/system/edgecore.service
/etc/kubeedge/edgecore.service
(base) [root@node2 /home/wangb/kubeedge/keadm-v1.6.2-linux-amd64/keadm]#
# ./keadm reset
[reset] WARNING: Changes made to this host by 'keadm init' or 'keadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]: y
edgecore is stopped
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
2022-01-01 What is Delayed ACK and how can it be a bottleneck in your network.
2022-01-01 Delayed ACK and Nagle's Algorithm