部署 KubeEdge 及简单使用

版本说明

k8s版本:1.22.3
kubeedge:1.10.0

kubernetes 集群准备

[root@hadoop03 kubeedge]# kubectl  get nodes
NAME       STATUS   ROLES                  AGE    VERSION
hadoop03   Ready    control-plane,master   9d     v1.22.3

cloudcore

k8s master 创建 /etc/kubeedge

[root@hadoop03 kubeedge]# pwd
/etc/kubeedge
[root@hadoop03 kubeedge]# ll
total 55432
-rw-r--r-- 1 root root      129 2023-01-29 11:19:56 checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt
-rw-r--r-- 1 root root      162 2023-01-29 11:19:56 cloudcore.service
drwxr-xr-x 2 root root       28 2023-01-29 11:25:17 config
drwxr-xr-x 5 root root       56 2023-01-29 11:19:56 crds
drwxr-xr-x 4 root root       46 2022-03-14 10:30:27 kubeedge-v1.10.0-linux-amd64
-rw-r--r-- 1 root root 56751052 2022-03-14 11:01:50 kubeedge-v1.10.0-linux-amd64.tar.gz
[root@hadoop03 kubeedge]#keadm init --advertise-address=192.168.153.103 --kubeedge-version=1.10.0 --kube-config=/etc/kubernetes/admin.conf

部署 KubeEdge 及简单使用_第1张图片

token
[root@hadoop03 kubeedge]# keadm gettoken --kube-config /etc/kubernetes/admin.conf
4215246d02ba07dbc38a867b98b764d42b8e295f335dd7a84ed5b770e47970da.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzQyMjk3MzB9.zKXZJ8Z58_DG6BaEPyINfkkH0wAmqKClhPrm06LwcYg
启动 cloudcore 服务
service cloudcore start
edgecore
[root@hadoop02 kubeedge]# keadm  join --cloudcore-ipport 192.168.153.103:10000 --token=4215246d02ba07dbc38a867b98b764d42b8e295f335dd7a84ed5b770e47970da.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzQyMjk3MzB9.zKXZJ8Z58_DG6BaEPyINfkkH0wAmqKClhPrm06LwcYg --kubeedge-version=1.10.0
...
Failed to get the latest KubeEdge release version, will use default version:  1.10.0
Host has /usr/sbin/mosquitto already installed and running. Hence skipping the installation steps !!!
Expected or Default KubeEdge version 1.10.0 is already downloaded and will checksum for it.
kubeedge-v1.10.0-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt content:
Expected or Default checksum file checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt is already downloaded.
Expected or Default KubeEdge version 1.10.0 is already downloaded
[Run as service] start to download service file for edgecore
[Run as service] success to download service file for edgecore
kubeedge-v1.10.0-linux-amd64/
kubeedge-v1.10.0-linux-amd64/cloud/
kubeedge-v1.10.0-linux-amd64/cloud/cloudcore/
kubeedge-v1.10.0-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.10.0-linux-amd64/cloud/iptablesmanager/
kubeedge-v1.10.0-linux-amd64/cloud/iptablesmanager/iptablesmanager
kubeedge-v1.10.0-linux-amd64/cloud/csidriver/
kubeedge-v1.10.0-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.10.0-linux-amd64/cloud/admission/
kubeedge-v1.10.0-linux-amd64/cloud/admission/admission
kubeedge-v1.10.0-linux-amd64/edge/
kubeedge-v1.10.0-linux-amd64/edge/edgecore
kubeedge-v1.10.0-linux-amd64/version

KubeEdge edgecore is running, For logs visit: journalctl -u edgecore.service -xe
[root@hadoop02 kubeedge]# service edgecore status
Redirecting to /bin/systemctl status  edgecore.service
● edgecore.service
   Loaded: loaded (/etc/systemd/system/edgecore.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-29 11:32:23 CST; 22s ago
 Main PID: 26460 (edgecore)
    Tasks: 11
   Memory: 34.2M
   CGroup: /system.slice/edgecore.service
           └─26460 /usr/local/bin/edgecore

在这里插入图片描述

初体验
[root@hadoop03 k8s]# kubectl  get node --show-labels
NAME       STATUS   ROLES                  AGE   VERSION                    LABELS
hadoop02   Ready    agent,edge             22h   v1.22.6-kubeedge-v1.10.0   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=hadoop02,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge=
hadoop03   Ready    control-plane,master   10d   v1.22.3                    beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=hadoop03,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=

nginx-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-controller
spec:
  replicas: 1
  selector:
    name: nginx
  template:
    metadata:
      labels:
        name: nginx
    spec:
      containers:
        - name: nginx
          image: hadoop03:5000/nginx:latest
          ports:
            - containerPort: 80
          #volumeMounts:
          #  - mountPath: /usr/share/nginx/html
          #    name: data-volume
      #volumes:
      #  - name: data-volume
      #    persistentVolumeClaim:
      #      claimName: test-pvc
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: "node-role.kubernetes.io/edge"
                operator: In
                values:
                - ""

部署 KubeEdge 及简单使用_第2张图片
部署 KubeEdge 及简单使用_第3张图片

设置了NodePort,也只能通过访问Edge,才能访问 nginx 服务,Cloud 端无法访问

注意:需要 k8s master 启动 cloudcore 服务,否则 nginx pod 一直 pending 状态

部署 KubeEdge 及简单使用_第4张图片
部署 KubeEdge 及简单使用_第5张图片

问题记录

在join 过程中有一句Host has /usr/sbin/mosquitto already installed and running. Hence skipping the installation steps !!!

部署 KubeEdge 及简单使用_第6张图片
似乎提示需要安装 mosquitto?

在keadm init,join 过程一直都报需要获取最新KubeEdge版本?即使指定了 --kubeedge-version=1.10.0

部署 KubeEdge 及简单使用_第7张图片
部署 KubeEdge 及简单使用_第8张图片

一开始部署是 kubeedge 1.12.1 版本,但是在keadm join过程中一直遇到 resource not found, namespace: default, name: hadoop02

部署 KubeEdge 及简单使用_第9张图片
部署 KubeEdge 及简单使用_第10张图片

部署 KubeEdge 及简单使用_第11张图片

部署 KubeEdge 及简单使用_第12张图片

你可能感兴趣的:(边缘计算,K8S,kubernetes,docker,容器)