云原生边缘计算KubeEdge安装配置(二)

1. K8S集群部署,可以参考如下博客

请安装k8s集群,centos安装k8s集群
请安装k8s集群,ubuntu安装k8s集群

请安装kubeedge cloudcore centos安装K8S

2.安装kubEedge

2.1 编辑kube-proxy使用ipvs代理

kubectl edit configmaps kube-proxy -n kube-system #修改kube-proxy
#大约在40多行37     ipvs:38       excludeCIDRs: null39       minSyncPeriod: 0s40       scheduler: ""41       strictARP: true  #这里由原来的false修改为true42       syncPeriod: 0s43       tcpFinTimeout: 0s44       tcpTimeout: 0s45       udpTimeout: 0s46     kind: KubeProxyConfiguration47     metricsBindAddress: ""48     mode: "ipvs"  #这里原来是空的修改为ipvs49     nodePortAddresses: null50     oomScoreAdj: null51     portRange: ""52     showHiddenMetricsForVersion: ""53     winkernel:54       enableDSR: false55       forwardHealthCheckVip: false56       networkName: ""57       rootHnsEndpointName: ""58       sourceVip: ""
kubectl rollout restart daemonset kube-proxy -n kube-system
kubectl get pods -n kube-system

2.2 基础服务提供,负载均衡器metallb

#无网络情况下,先上传kubeedge.tar 和 metallb-native.yaml文件
docker load -i kubeedge.tar  #导入镜像#有网络可以直接拉去镜像
docker pull quay.io/metallb/controller:v0.13.5
docker pull quay.io/metallb/speaker:v0.13.5
wget https://raw.githubusercontent.com/metallb/metallb/v0.13.5/config/manifests/metallb-native.yaml
kubectl apply -f metallb-native.yaml
kubectl get pods -n metallb-system
[root@k8s-master01 ~]# kubectl get pods -n metallb-system
NAME                         READY   STATUS    RESTARTS   AGE
controller-8d9cf599f-m4x27   1/1     Running   0          23s
speaker-zm7w4                1/1     Running   0          23s
speaker-zww5l                1/1     Running   0          23s
[root@k8s-master01 ~]# 

#具体参考官网地址:https://metallb.universe.tf/configuration/#layer-2-configuration

#创建IP地址资源池,原则是跟主机在同一个网段,没有使用的地址,根据自己项目的规模我合理预留了21个IP
cat > first-ippool.yaml << EOF
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:name: first-poolnamespace: metallb-system
spec:addresses:- 192.168.186.200-192.168.186.220
EOF
kubectl apply -f first-ippool.yaml
kubectl get ipaddresspools -n metallb-system
[root@k8s-master01 ~]# kubectl get ipaddresspools -n metallb-system
NAME         AGE
first-pool   2m1s
[root@k8s-master01 ~]# 
#开启二层转发,实现k8s集群节点外访问
cat > l2forward.yaml << EOF
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:name: examplenamespace: metallb-system
EOFkubectl apply -f l2forward.yaml
#二层转发案例测试
cat > nginx.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:name: nginx
spec:replicas: 1selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- image: nginxname: nginximagePullPolicy: IfNotPresent
---
apiVersion: v1
kind: Service
metadata:name: nginx-svc
spec:type: LoadBalancerports:- port: 80targetPort: 80selector:app: nginx
EOFkubectl apply -f nginx.yaml
[root@k8s-master01 ~]# kubectl get pods,svc #svc的ip从地址池中分配的
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-5f5c64f949-bhpvf   1/1     Running   0          50sNAME                 TYPE           CLUSTER-IP     EXTERNAL-IP       PORT(S)        AGE
service/kubernetes   ClusterIP      10.96.0.1      <none>            443/TCP        5h43m
service/nginx-svc    LoadBalancer   10.99.41.146   192.168.186.200   80:30293/TCP   50s
[root@k8s-master01 ~]# 

测试通过

kubectl delete -f nginx.yaml  #删除无用的pod和svc

3. 对于kubeEdge概述

KubeEdge由云和边缘组成。它建立在Kubernetes之上,为联网应用部署和云与边缘之间的元数据同步提供核心基础设施支持。所以如果我们想要设置KubeEdge,我们需要设置Kubernetes集群(可以使用现有的集群),云端和边缘端在cloud side, 我们需要安装

Docker
Kubernetes cluster
cloudcore

在 edge side, 我们需要安装

Docker
MQTT (配置可以选用,不是一定需要)
edgecore

在这里插入图片描述

3.部署kubeedge cloudcore

3.1 获取keadm工具

wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.1/keadm-v1.12.1-linux-amd64.tar.gztar -zxvf keadm-v1.12.1-linux-amd64.tar.gz
cp keadm-v1.12.1-linux-amd64/keadm/keadm  /usr/local/bin/
keadm version

3.2 部署cloudcore

#在master上部署
#设置云端  使用keadm初始化,安装cloudcore
docker pull kubeedge/cloudcore:v1.14.2  
docker pull  kubeedge/iptables-manager:v1.14.2keadm init --advertise-address=192.168.110.100 --kubeedge-version=1.12.1   #这是master的ip,互联网用这种形式keadm init --advertise-address=192.168.186.200 --set iptablesManager.mode="external" --profile version=v1.12.1 #这里的IP是负载均衡器metallb分配的IP#以上参数分别为master节点地址和要安装的KubeEdge版本。#keadm reset  #安装错误可以重置
keadm gettoken  #获取token
[root@k8s-master01 ~]# keadm init --advertise-address=192.168.186.200 --set iptablesManager.mode="external" --profile version=v1.14.2
Kubernetes version verification passed, KubeEdge installation will start...
CLOUDCORE started
=========CHART DETAILS=======
NAME: cloudcore
LAST DEPLOYED: Mon Oct  9 15:25:36 2023
NAMESPACE: kubeedge
STATUS: deployed
REVISION: 1
[root@k8s-master ~]# keadm gettoken
3b917d79963d290608f00b2c567808bbf37f99379efdb4a2848ddd2d2713cb52.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTY5NDc2NTl9.1DQ6GwR687bpyR_8q-Xf2HwFfLeUdZ2oqYrYkEyNEEo[root@k8s-master ~]# 
[root@k8s-master01 ~]# kubectl get ns
NAME                   STATUS   AGE
default                Active   58d
kube-node-lease        Active   58d
kube-public            Active   58d
kube-system            Active   58d
kubeedge               Active   8m44s  #在这个空间中中
kubernetes-dashboard   Active   58d
metallb-system         Active   57d
[root@k8s-master ~]# kubectl get pods,svc -n kubeedge
NAME                               READY   STATUS    RESTARTS   AGE
pod/cloud-iptables-manager-8kh6q   1/1     Running   0          109m
pod/cloudcore-5876c76687-tkkzx     1/1     Running   0          109mNAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                             AGE
service/cloudcore   ClusterIP   10.101.140.171   <none>        10000/TCP,10001/TCP,10002/TCP,10003/TCP,10004/TCP   109m
[root@k8s-master ~]# 
kubectl edit svc cloudcore -n kubeedge #修改大概在51行 49   selector:50     k8s-app: kubeedge51     kubeedge: cloudcore52   sessionAffinity: None53   type: LoadBalancer  #修改后的54 status:55   loadBalancer: {}
[root@k8s-master ~]# kubectl get pods,svc -n kubeedge
NAME                               READY   STATUS    RESTARTS   AGE
pod/cloud-iptables-manager-8kh6q   1/1     Running   0          110m
pod/cloudcore-5876c76687-tkkzx     1/1     Running   0          110mNAME                TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)                                                                           AGE
service/cloudcore   LoadBalancer   10.101.140.171   192.168.186.200   10000:31953/TCP,10001:32329/TCP,10002:31154/TCP,10003:30807/TCP,10004:31038/TCP   110m
[root@k8s-master ~]# 
[root@k8s-master kubernetes]# kubectl get pods -n kube-system -o wide #metrics-server不正常
NAME                                       READY   STATUS    RESTARTS   AGE     IP                NODE         NOMINATED NODE   READINESS GATES
calico-kube-controllers-67bb5696f5-sfhs6   1/1     Running   0          4h3m    10.244.235.195    k8s-master   <none>           <none>
calico-node-2w8jn                          1/1     Running   0          4h3m    192.168.186.128   k8s-master   <none>           <none>
calico-node-vt8g4                          1/1     Running   0          4h3m    192.168.186.129   k8s-node1    <none>           <none>
coredns-7f6cbbb7b8-q8z29                   1/1     Running   0          4h5m    10.244.235.193    k8s-master   <none>           <none>
coredns-7f6cbbb7b8-qc8d2                   1/1     Running   0          4h5m    10.244.235.194    k8s-master   <none>           <none>
etcd-k8s-master                            1/1     Running   0          4h5m    192.168.186.128   k8s-master   <none>           <none>
kube-apiserver-k8s-master                  1/1     Running   0          4h5m    192.168.186.128   k8s-master   <none>           <none>
kube-controller-manager-k8s-master         1/1     Running   0          4h5m    192.168.186.128   k8s-master   <none>           <none>
kube-proxy-2vt4s                           1/1     Running   0          3h52m   192.168.186.129   k8s-node1    <none>           <none>
kube-proxy-99x2t                           1/1     Running   0          3h52m   192.168.186.128   k8s-master   <none>           <none>
kube-scheduler-k8s-master                  1/1     Running   0          4h5m    192.168.186.128   k8s-master   <none>           <none>
metrics-server-5f85c44dcd-kpnpk            1/1     Running   0          4m4s    10.244.36.85      k8s-node1    <none>           <none>    #如果状态和READY不正确,就执行如下的语句
[root@k8s-master kubernetes]# 
kubectl patch deploy metrics-server -n kube-system --type='json' -p='[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'  #修改为不认证

4. 部署edgecore(边缘节点)

[root@k8s-master ~]# kubectl get nodes
NAME         STATUS   ROLES                  AGE     VERSION
k8s-master   Ready    control-plane,master   4h12m   v1.22.6
k8s-node1    Ready    <none>                 4h9m    v1.22.6
[root@k8s-master ~]# 

4.1 获取keadm工具

#注意边缘节点配置都很低,只需要运行业务容器
#边缘节点只需要安装docker就可以了
hostnamectl set-hostname edge-node1  && bashwget https://github.com/kubeedge/kubeedge/releases/download/v1.10.1/keadm-v1.12.1-linux-amd64.tar.gztar -zxvf keadm-v1.12.1-linux-amd64.tar.gz
cp keadm-v1.12.1-linux-amd64/keadm/keadm  /usr/local/bin/
keadm version
TOKEN=3b917d79963d290608f00b2c567808bbf37f99379efdb4a2848ddd2d2713cb52.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTY5NDc2NTl9.1DQ6GwR687bpyR_8q-Xf2HwFfLeUdZ2oqYrYkEyNEEo  #这串数字是在cloudcore执行keadm gettoken获取的SERVER=192.168.186.200:10000
keadm join --token=$TOKEN --cloudcore-ipport=$SERVER --kubeedge-version=1.12.1#如果添加失败了,请在edgecore中执行
#docker rm -f mqtt   && rm -fr /etc/kubeedge/
#keadm join --token=$TOKEN --cloudcore-ipport=$SERVER --kubeedge-version=1.12.1
[root@edgenode1 ~]# TOKEN=3b917d79963d290608f00b2c567808bbf37f99379efdb4a2848ddd2d2713cb52.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTY5NDc2NTl9.1DQ6GwR687bpyR_8q-Xf2HwFfLeUdZ2oqYrYkEyNEEo
[root@edgenode1 ~]# SERVER=192.168.186.200:10000
[root@edgenode1 ~]# keadm join --token=$TOKEN --cloudcore-ipport=$SERVER --kubeedge-version=1.12.1
I1009 13:40:18.319594    2217 command.go:845] 1. Check KubeEdge edgecore process status
I1009 13:40:18.480783    2217 command.go:845] 2. Check if the management directory is clean
I1009 13:40:18.480907    2217 join.go:100] 3. Create the necessary directories
I1009 13:40:18.484206    2217 join.go:176] 4. Pull Images
Pulling kubeedge/installation-package:v1.12.1 ...
Successfully pulled kubeedge/installation-package:v1.12.1
Pulling eclipse-mosquitto:1.6.15 ...
Successfully pulled eclipse-mosquitto:1.6.15
Pulling kubeedge/pause:3.1 ...
Successfully pulled kubeedge/pause:3.1
I1009 13:42:56.611776    2217 join.go:176] 5. Copy resources from the image to the management directory
I1009 13:42:59.996519    2217 join.go:176] 6. Start the default mqtt service
I1009 13:43:02.033426    2217 join.go:100] 7. Generate systemd service file
I1009 13:43:02.034038    2217 join.go:100] 8. Generate EdgeCore default configuration
I1009 13:43:02.034469    2217 join.go:230] The configuration does not exist or the parsing fails, and the default configuration is generated
W1009 13:43:02.051996    2217 validation.go:71] NodeIP is empty , use default ip which can connect to cloud.
I1009 13:43:02.055240    2217 join.go:100] 9. Run EdgeCore daemon
I1009 13:43:02.733562    2217 join.go:317] 
I1009 13:43:02.733581    2217 join.go:318] KubeEdge edgecore is running, For logs visit: journalctl -u edgecore.service -xe
[root@edgenode1 ~]# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/129255.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

聊聊分布式架构02——Http到Https

目录 HTTP通信协议 请求报文 响应报文 持久连接 状态管理 HTTPS通信协议 安全的HTTPS HTTP到HTTPS的演变 对称加密 非对称加密 混合加密机制 证书机构 SSL到底是什么 HTTPS是身披SSL外壳的HTTP HTTP通信协议 一次HTTP请求的通信流程&#xff1a;客户端浏览器通过…

SpringBoot的流浪宠物系统

采用技术:springbootvue 项目可以完美运行

Linux配置SSH允许TCP转发

#编辑SSH配置文件 vi /etc/ssh/sshd_config #重启SSH服务 systemctl restart sshd.service AllowTcpForwarding yes

VsCode 常见的配置、常用好用插件

1、自动保存&#xff1a;不用装插件&#xff0c;在VsCode中设置一下就行 2、设置ctr滚轮改变字体大小 3、设置选项卡多行展示 这样打开了很多个文件&#xff0c;就不会导致有的打开的文件被隐藏 4、实时刷新网页的插件&#xff1a;LiveServer 5、open in browser 支持快捷键…

基于SpringBoot的篮球论坛系统

基于SpringBoot的篮球论坛系统~ 开发语言&#xff1a;Java数据库&#xff1a;MySQL技术&#xff1a;SpringBootMyBatisVue工具&#xff1a;IDEA/Ecilpse、Navicat、Maven 系统展示 前台界面 登录界面 管理员界面 摘要 基于Spring Boot的篮球论坛系统代表了一个现代社交网络应…

基于YOLO的BIM对象检测

我在此过程中使用的 BIM 数据集取自澳大利亚卫生设施指南。 该数据集包含一组房间数据表和房间布局表&#xff0c;旨在提供典型房间类型的合规示例&#xff0c;并减少规划和设计这些房间时“重新发明轮子”的需要。 推荐&#xff1a;用 NSDT编辑器 快速搭建可编程3D场景 1、合…

【NLTK系列01】:nltk库介绍

一、说明 NLTK是个啥&#xff1f;它是个复杂的应用库&#xff0c;可以实现基本预料库操作&#xff0c;比如&#xff0c;、将文章分词成独立token&#xff0c;等操作。从词统计、标记化、词干提取、词性标记&#xff0c;停用词收集&#xff0c;包括语义索引和依赖关系解析等。 …

Hive窗口函数回顾

1.语法 1.1 基于行的窗口函数 Hive的窗口函数分为两种类型&#xff0c;一种是基于行的窗口函数&#xff0c;即将某个字段的多行限定为一个范围&#xff0c;对范围内的字段值进行计算&#xff0c;最后将形成的字段拼接在该表上。 注意&#xff1a;在进行窗口函数计算之前&#…

web:[护网杯 2018]easy_tornado

题目 点进页面显示如下 点进去查看 有个render&#xff0c;结合题目名&#xff0c;可能是ssti 同时注意到url&#xff0c;无论点进哪个文件&#xff0c;url的格式都为file?filename/xxx&filehashxxx 所以结合hints.txt中的提示&#xff0c;filehash就是md5加密得到的&…

PL/SQL拉链表

练习:-- 拉链表练习: 维度表源表 ID M_NAME REST UP_DATE 1 车贷 0.01 2022/12/1 2 房贷 0.03 2022/12/1 3 经营贷 0.015 2022/12/1 维度表拉链表 ID M_NAME REST BEGIN_DATE END_DATE 1 车贷 …

平凡工作也能创造奇迹:学习公文的写作逻辑和技巧

引言 如何把平凡的工作写出光环 &#x1f4dc; 很多初入职场的人在撰写个人先进事迹材料时面临的最大问题是&#xff1a;他们认为自己做的工作都是琐碎且普通的&#xff0c;没有任何惊天动地的成就或值得称赞的成绩。因此&#xff0c;他们感到非常困惑&#xff0c;不知道该如何…

elasticSearch7.9数据占用磁盘存储空间情况

最近&#xff0c;在VMware Workstation虚拟机上安装了es7.9&#xff0c;单节点的es&#xff0c;不是集群&#xff0c;然后建了一个索引&#xff08;包含3个分片和一个副本&#xff09;&#xff0c;插入了500万条数据&#xff0c;占据磁盘空间17G。如下图&#xff1a; 索引的字…