KubeEdge v1.3 部署安装
前提: 安装好了 K8s 集群,K8s 版本为1.16.2
并修改 /etc/kubernetes/manifests/kube-apiserver.yaml
1 2
| - --insecure-port=8080 - --insecure-bind-address=0.0.0.0
|
使用二进制安装
云端操作:
设置 KubeEdge 主节点
1 2 3 4 5 6 7
| kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_device.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha2_devicemodel.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/cluster_objectsync_v1alpha1.yaml
kubectl apply -f https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/reliablesyncs/objectsync_v1alpha1.yaml
|
如果下载不下来,可以访问下面这个github下载:https://github.com/kubeedge/kubeedge/tree/master/build/crds/devices
1 2 3 4 5 6 7 8 9 10 11 12
| # wget https://github.com/kubeedge/kubeedge/releases/download/v1.3.0/kubeedge-v1.3.0-linux-amd64.tar.gz
# tar xf kubeedge-v1.3.0-linux-amd64.tar.gz cd kubeedge-v1.3.0-linux-amd64/cloud/cloudcore
# 使用命令创建最小配置 ./cloudcore --minconfig > /etc/kubeedge/config/cloudcore.yaml
或带有命令的完整配置 ./cloudcore --defaultconfig > /etc/kubeedge/config/cloudcore.yaml
|
1
| ./cloudcore --config /etc/kubeedge/config/cloudcore.yaml
|
边缘端操作:
1 2 3 4 5 6 7 8 9 10
| # curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum clean all && yum makecache
# yum install -y docker-ce-cli-19.03.9-3.el7 docker-ce-19.03.9-3.el7
# systemctl enable docker && systemctl start docker
|
1 2
| scp -r 192.168.8.102:/opt/kubeedge-v1.3.0-linux-amd64/ /opt/ cd /opt/kubeedge-v1.3.0-linux-amd64/edge
|
1
| edgecore --minconfig > /root/edgecore.yaml
|
1
| kubectl get secret -nkubeedge tokensecret -o=jsonpath='{.data.tokendata}' | base64 -d
|
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
| vim /root/edgecore.yaml
apiVersion: edgecore.config.kubeedge.io/v1alpha1 database: dataSource: /var/lib/kubeedge/edgecore.db kind: EdgeCore modules: edgeHub: heartbeat: 15 httpServer: https://192.168.8.101:10002 #默认云端IP和端口 tlsCaFile: /etc/kubeedge/ca/rootCA.crt tlsCertFile: /etc/kubeedge/certs/server.crt tlsPrivateKeyFile: /etc/kubeedge/certs/server.key token: "e97268645d7bb5122d5d5e38fc3149a312f0a6cfcb7fa6e4281183f1b717762b.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQzNDk4Njh9._lYCVGLTxmgGtzmjdRP6rZyCBiP3qbJA5F9bbkTfcYs" #从云端拿下来的token websocket: enable: true handshakeTimeout: 30 readDeadline: 15 server: 192.168.8.101:10000 #默认云端IP和端口 writeDeadline: 15 edged: cgroupDriver: cgroupfs cgroupRoot: "" cgroupsPerQOS: true clusterDNS: "" clusterDomain: "" devicePluginEnabled: false dockerAddress: unix:///var/run/docker.sock gpuPluginEnabled: false hostnameOverride: edge-node #边缘节点的hostname interfaceName: ens33 #边缘节点的网卡名 nodeIP: 192.168.8.240 #边缘节点的IP podSandboxImage: kubeedge/pause:3.1 remoteImageEndpoint: unix:///var/run/dockershim.sock remoteRuntimeEndpoint: unix:///var/run/dockershim.sock runtimeType: docker eventBus: mqttMode: 2 #KubeEdge 支持 3 种 MQTT 模式(internalMqttMode、bothMqttMode、externalMqttMode),将mqttModeedgecore.yaml 中的字段设置为所需的模式。+ internalMqttMode:启用内部 mqtt 代理(mqttMode=0)。+ bothMqttMode:启用内部和外部代理(mqttMode=1)。+ externalMqttMode:仅启用外部代理(mqttMode=2)。 #要在双 mqtt 或外部模式下使用 KubeEdge,您需要确保在边缘节点上安装 mosquitto 或 emqx edge 作为 MQTT Broker。 mqttQOS: 0 mqttRetain: false mqttServerExternal: tcp://127.0.0.1:1883 mqttServerInternal: tcp://127.0.0.1:1884
|
1 2 3 4 5
| ## 添加EPEL软件库 yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
## 下载mosquitto yum install -y mosquitto
|
1
| edgecore --config /root/edgecore.yaml
|
vim nginx_v1.yaml
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
| apiVersion: v1 kind: Pod metadata: name: nginx-pods namespace: default labels: app: nginx release: v1 spec: containers: - name: nginx-pods image: nginx:latest imagePullPolicy: IfNotPresent ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx-service-nodeport spec: ports: - port: 80 targetPort: 80 protocol: TCP type: NodePort selector: app: nginx
|
kubectl create -f nginx_v1.yaml #创建服务
查看节点是否部署到了 Edge-node 上: