kubeedge1.6.2环境搭建(本地版)

4 篇文章 0 订阅

1.准备工作:

参考文档

Nanopi R4s 构建 kubuEdge 集群 (基于kubuEdge v1.5.0)_沐风飞花-CSDN博客

kubeedge 1.4 本地部署_我是干饭人的博客-CSDN博客_kubeedge 离线安装

环境依赖: 

角色ip负载
cloud  x86_64

k8s master ip

192.168.1.171

k8s、cloudcore、docker
edge  x86_64

同网段ip

192.168.1.176

edgecore、docker、mosquitto、kubeedge/pause:3.1

 请参考下面文章安装k8s

​​​​centos7.6安装Kubernetes-V1.21_mayi_xiaochaun的博客-CSDN博客_centos7.6安装kubernetes

如果需要安装指定版本docker,请参考下面链接

docker 安装指定版本_mayi_xiaochaun的博客-CSDN博客

环境配置:

跟k8s配置一样,增加hostname和ip的映射关系,master和edge节点配置一样
// 设置主机名

hostnamectl set-hostname k8s-edge01

// 设置hosts地址解析

vim /etc/hosts  

edge 节点:mosquitto安装

// Ubuntu 1804系统直接使用如下指令即可安装
sudo apt-get install -y mosquitto

//centos 7.6安装
yum install -y mosquitto

2.搭建kubeedge环境

(1)云端Master节点部署

注意:

  1. 本方案采用的master节点物理机为x86 8g设备!!!!!!
  2. 继续运行下面步骤,需要保证K8S集群已启动,并且master节点为Ready状态

关于树莓派4B组件k8s集群方案可以查看笔者的这篇博客:
树莓派4B Ubuntu1804 构建K8s技术方案

2.1.1go环境配置

#下载最新版本
wget https://golang.google.cn/dl/go1.17.8.linux-amd64.tar.gz --no-check-certificate

#解压
tar -zxvf go1.17.8.linux-amd64.tar.gz -C /usr/local/

vim /etc/profile
export GOROOT=/usr/local/go
export GO_HOME=$GOROOT
export GOPATH=/home/gopath
export PATH=$GO_HOME/bin:$PATH

source /etc/profile

go version
go version go1.17.8 linux/amd64

mkdir -p /home/gopath && cd /home/gopath
mkdir -p src pkg bin

2.1.2 下载kubeedge源码
 

#切kubeedge最新源码
git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge
cd $GOPATH/src/github.com/kubeedge/kubeedge
#切换为v1.6.2版本
git checkout -b v1.6.2 v1.6.2

2.1.3 云端环境配置

添加device

cd $GOPATH/src/github.com/kubeedge/kubeedge/build/crds/devices
kubectl apply -f devices_v1alpha2_devicemodel.yaml
kubectl apply -f devices_v1alpha2_device.yaml

cd ../reliablesyncs/
kubectl apply -f cluster_objectsync_v1alpha1.yaml
kubectl apply -f objectsync_v1alpha1.yaml

编译(也可直接下载Release程序)

cd $GOPATH/src/github.com/kubeedge/kubeedge
make all WHAT=cloudcore && make all WHAT=edgecore
cd _output/local/bin/
cp cloudcore /usr/local/bin
# 注意:这里的 /usr/local/bin/ 就是到时候cloudcore.service,需修改ExecStart为真实值目录
scp -P 22 edgecore root@192.168.1.176:/usr/local/bin/

配置cloudcore

mkdir -p /etc/kubeedge/config && cd /etc/kubeedge/config
cloudcore --minconfig >cloudcore.yaml
# 清除已有的密钥
kubectl delete secret casecret -nkubeedge
kubectl delete secret cloudcoresecret -nkubeedge

vim cloudcore.yaml
# 将tlsCertFile和tlsPrivateKeyFile注释,并删除/etc/kubeedge/ca 和/etc/kubeedge/cert
# 我们采用自动注册结点的方式,在添加配置modules.edged.registerNode=true
# 修改kubeConfig=正确的路径
# 修改advertiseAddress为对外暴露的ip,即master所在的IP
# 修改cloudcore.service
/**************************************************
# With --minconfig , you can easily used this configurations as reference.
# It's useful to users who are new to KubeEdge, and you can modify/create your own configs accordingly. 
# This configuration is suitable for beginners.
apiVersion: cloudcore.config.kubeedge.io/v1alpha1
kind: CloudCore
kubeAPIConfig:
  kubeConfig: /root/.kube/config
  master: ""
leaderelection:
  LeaderElect: false
  LeaseDuration: 0s
  RenewDeadline: 0s
  ResourceLock: ""
  ResourceName: ""
  ResourceNamespace: ""
  RetryPeriod: 0s
modules:
  cloudHub:
    advertiseAddress:
    - 192.168.1.171
    https:
      address: 0.0.0.0
      enable: true
      port: 10002
    nodeLimit: 1000
    tlsCAFile: /etc/kubeedge/ca/rootCA.crt
    tlsCAKeyFile: /etc/kubeedge/ca/rootCA.key
    unixsocket:
      address: unix:///var/lib/kubeedge/kubeedge.sock
      enable: true
    websocket:
      address: 0.0.0.0
      enable: true
      port: 10000
  edged:
    registerNode: true
***************************************************/

cd $GOPATH/src/github.com/kubeedge/kubeedge/build/tools
vim cloudcore.service
# 将cloudcore的路径修改为真实路径
# 即将ExecStart=/etc/kubeedge/cloudcore,改为 ExecStart=/usr/local/bin/cloudcore
cp cloudcore.service /lib/systemd/system/
systemctl daemon-reload
systemctl enable cloudcore
systemctl start cloudcore
# 同理修改edgecore.service
vim edgecore.service
# 即将ExecStart=/etc/kubeedge/edgecore,改为 ExecStart=/usr/local/bin/edgecore
scp -P 22 edgecore.service root@192.168.1.176:/lib/systemd/system/

(2)、边端Edge节点部署

# 不要安装kubelet或将其关闭
mkdir -p /etc/kubeedge/config/
edgecore --minconfig > /etc/kubeedge/config/edgecore.yaml
vim /etc/kubeedge/config/edgecore.yaml
# 注释modules.edgehub.tlsCaFile,modules.edgehub.tlsCertFile,modules.edgehub.tlsPrivateKeyFile
    #tlsCaFile: /etc/kubeedge/ca/rootCA.crt
    #tlsCertFile: /etc/kubeedge/certs/server.crt
    #tlsPrivateKeyFile: /etc/kubeedge/certs/server.key
# 修改modules.edgehub.websocket.server和modules.edgehub.quic.server(没有就不改)
    httpServer: https://192.168.1.171:10002
# 修改modules.edgehub.httpServer
    websocket:
      enable: true
      handshakeTimeout: 30
      readDeadline: 15
      server: 192.168.1.171:10000
    edged:
 #此处cgroupDriver默认是cgroups,修改为跟k8s和docker一致的systemd,避免后续启动edgecore失败
      cgroupDriver: systemd
/***********************************!!!!!在云端操作  开始!!!!!**************************************/      
# cloud端操作!!!!!在云端操作!!!!!
kubectl get secret tokensecret -n kubeedge -oyaml
     /*注意,如果报错:Error from server (NotFound): namespaces "kubeedge" not found 
     	请执行:systemctl start cloudcore.service
     	并使用:systemctl status cloudcore.service,查看服务是否正常启动!
     	● cloudcore.service
		   Loaded: loaded (/lib/systemd/system/cloudcore.service; enabled; vendor preset: enabled)
		   Active: active (running) since Wed 2020-12-30 15:46:44 CST; 12s ago
		 Main PID: 15705 (cloudcore)
		    Tasks: 10 (limit: 4443)
		   CGroup: /system.slice/cloudcore.service
		           └─15705 /usr/local/bin/cloudcore
	*/ 
# 将返回值中的data.tokendata字符串复制并进行转码
echo 填入data.tokendata的数值 | base64 -d
/***********************************!!!!!在云端操作  结束!!!!!**************************************/
# 将值填入edgecore.yaml的token处
# edgecore.yaml 编辑结束

# 提前导入镜像
# arm64
docker pull kubeedge/pause-arm64:3.1
# x86_64 or amd64
docker pull kubeedge/pause:3.1
# arm
docker pull kubeedge/pause-arm:3.1
systemctl daemon-reload
systemctl enable edgecore
systemctl start edgecore

部署完成

# 在master结点查看
kubectl get no -o wide
# 均处于Ready状态


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值