KubeEdge安装实践

岁酱吖の 提交于 2020-02-29 23:17:28

#安装环境:
OS:CentOS7.4
Master: Kubernetes v1.15.1 ; docker 18.09.7
Edge-node:KubeEdge v1.1.0 ; docker 18.09.7

一、安装Cloud端

配置master节点

vi /etc/kubernetes/manifests/kube-apiserver.yaml
# Add the following flags in spec: containers: -command section
- --insecure-port=8080
- --insecure-bind-address=0.0.0.0

kubectl proxy --port=8080 &

vi /etc/hosts  #将以下语句添加到最后一行
151.101.72.133 raw.githubusercontent.com #如果该ip失效可以再找一个外国ip ping通也可以用

下载安装包

先进入kubeedge的github仓库中的KubeEdge v1.1.0 release,下载kubeedge-v1.1.0-linux-amd64.tar.gz ,将下载的安装包上传到k8s master节点的/root目录下,之后再进行下面的步骤

tar -zxvf kubeedge-v1.1.0-linux-amd64.tar.gz
mv kubeedge-v1.1.0-linux-amd64 /etc/kubeedge

修改controller.yaml

vi /etc/kubeedge/cloud/cloudcore/conf/controller.yaml

controller:
  kube:
    ...
    kubeconfig: "/root/.kube/config" #Enter path to kubeconfig file to enable https connection to k8s apiserver
master: http://127.0.0.1:8080  # kube-apiserver address

devicecontroller:
  kube:
    ...
    kubeconfig: "/root/.kube/config" #Enter path to kubeconfig file to enable https connection to k8s apiserver
master: http://127.0.0.1:8080  # kube-apiserver address

在master节点生成证书

wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/tools/certgen.sh
# make script executable
chmod +x certgen.sh
bash -x ./certgen.sh genCertAndKey edge

创建device model 和 device CRDs

wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_devicemodel.yaml
# make script executable
chmod +x devices_v1alpha1_devicemodel.yaml
kubectl create -f devices_v1alpha1_devicemodel.yaml
wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/crds/devices/devices_v1alpha1_device.yaml
# make script executable
chmod +x devices_v1alpha1_device.yaml
kubectl create -f devices_v1alpha1_device.yaml

运行Cloud端

cd /etc/kubeedge/cloud/cloudcore
./cloudcore

二、安装Edge端

准备Edge端安装包

因为证书问题,将master节点上的/etc/kubeedge直接拷贝到edge节点的/etc下,在master节点上运行以下命令:

scp -r /etc/kubeedge root@[edge节点ip]:/etc

#例如 scp -r /etc/kubeedge root@ 172.21.16.13:/etc 用内网ip速度会比较快

在master节点上创建edge-node

wget -L https://raw.githubusercontent.com/kubeedge/kubeedge/master/build/node.json
kubectl apply -f node.json

#可以在node.json中更改edge节点的名称,默认为edge-node

修改edge-node的配置

vi /etc/kubeedge/edge/conf/edge.yaml

edgehub.websocket.url:ip修改成master ip端口不变

controller:node-id:与在master上通过node.json创建的node的name保持一致
edged:hostname-override:与在master上通过node.json创建的node的name保持一致
edgehub.websocket.url:其中表示node的name与通过node.json创建的node的name保持一致,例如:url: wss://172.21.16.12:10000/e632aba927ea4ac2b575ec1603d56f10/edge-node/events

edged. cgroup-driver: system  #与docker cgroup-driver保持一致

运行Edge端

cd /etc/kubeedge/edge
./edgecore

三、检验edge-node初始化

kubectl get nodes  #edge-node显示Ready即安装成功

安装成功

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!