当前位置:   article > 正文

搭建kubeedge_kubeedge搭建

kubeedge搭建

搭建kubeedge

参考官网

https://kubeedge.io/en/docs/setup/keadm/

选择版本

在这里插入图片描述

下载Keadm

选择v1.12.1

wget https://github.com/kubeedge/kubeedge/releases/download/v1.12.1/keadm-v1.12.1-linux-amd64.tar.gz
tar -zxvf keadm-v1.12.1-linux-amd64.tar.gz
cp keadm-v1.12.1-linux-amd64/keadm/keadm /usr/local/bin/keadm
  • 1
  • 2
  • 3
安装云端
  • 安装cloud
keadm init --advertise-address="192.168.19.133" --profile version=v1.12.1 --kube-config=/root/.kube/config --set cloudCore.hostNetWork="false"
  • 1

最新的云端是以容器化的方式运行

我这边没有公网IP,所有云端的端口均以NodePort的形式暴露,cloudCore.hostNetWork 设置为true

端口映射

30000:10000

30001:10001

30002:10002

30003:10003

30004:10004

  • 禁止kube-proxy调度到边缘端
kubectl get daemonsets.apps -n kube-system | grep -v NAME | awk '{print $1}' | xargs -n 1 kubectl patch daemonset -n kube-system --type='json' -p='[{"op":"replace","path":"/spec/template/spec/affinity","value":{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"node-role.kubernetes.io/edge","operator":"DoesNotExist"}]}]}}}}]'
  • 1

修改calicl-node kube-proxy nodelocaldns组件的亲和性,运行在非边缘节点

安装边缘端
  • 边缘端配置

边缘端新建一个虚拟机

ip: 192.168.19.139

hostname: edgenode1

安装docker

yum remove docker*

curl https://get.docker.com | bash

systemctl disable docker.service

systemctl start docker.service
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 获取云端token
keadm gettoken
1f872fbcc3a7d5c17585b337d44c198799f42d7ec0d71dace046317aea98482b.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Nzc1NDc4MDF9.f9j8yvYWHf_bHzyykd7Dxrxg7gdR5OGD7NS58EBk6Tc

  • 1
  • 2
  • 3
  • 安装edge
TOKEN=1f872fbcc3a7d5c17585b337d44c198799f42d7ec0d71dace046317aea98482b.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Nzc1NDc4MDF9.f9j8yvYWHf_bHzyykd7Dxrxg7gdR5OGD7NS58EBk6Tc
SERVER=192.168.19.133:30001
keadm join --cloudcore-ipport=$SERVER --kubeedge-version=v1.12.1 --token=$TOKEN
  • 1
  • 2
  • 3

由于cloud端用的是NodePort,所以edge端有些默认端口需要修改,配置文件在/etc/kubeedge/config/edgecore.yaml

主要将10000 10001 10002 10003 10004这些端口改为NodePort的映射端口

apiVersion: edgecore.config.kubeedge.io/v1alpha2
database:
  aliasName: default
  dataSource: /var/lib/kubeedge/edgecore.db
  driverName: sqlite3
kind: EdgeCore
modules:
  dbTest:
    enable: false
  deviceTwin:
    enable: true
  edgeHub:
    enable: true
    heartbeat: 15
    httpServer: https://192.168.19.133:30002
    messageBurst: 60
    messageQPS: 30
    projectID: e632aba927ea4ac2b575ec1603d56f10
    quic:
      enable: false
      handshakeTimeout: 30
      readDeadline: 15
      server: 192.168.19.139:10001
      writeDeadline: 15
    rotateCertificates: true
    tlsCaFile: /etc/kubeedge/ca/rootCA.crt
    tlsCertFile: /etc/kubeedge/certs/server.crt
    tlsPrivateKeyFile: /etc/kubeedge/certs/server.key
    token: 1f872fbcc3a7d5c17585b337d44c198799f42d7ec0d71dace046317aea98482b.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzcyMjQzNjR9.TpK0L-aDrEHnTaWjN6SQA_-cQCQqp5UO3VgZfNWlxNo
    websocket:
      enable: true
      handshakeTimeout: 30
      readDeadline: 15
      server: 192.168.19.133:30000
      writeDeadline: 15
  edgeStream:
    enable: false
    handshakeTimeout: 30
    readDeadline: 15
    server: 192.168.19.133:30004
    tlsTunnelCAFile: /etc/kubeedge/ca/rootCA.crt
    tlsTunnelCertFile: /etc/kubeedge/certs/server.crt
    tlsTunnelPrivateKeyFile: /etc/kubeedge/certs/server.key
    writeDeadline: 15
  edged:
    cniBinDir: /opt/cni/bin
    cniCacheDir: /var/lib/cni/cache
    cniConfDir: /etc/cni/net.d
    containerRuntime: docker
    dockerEndpoint: unix:///var/run/docker.sock
    enable: true
    hostnameOverride: edgenode1
    imagePullProgressDeadline: 1m0s
    kubeConfig: /etc/kubeedge/config/kubeconfig
    masterServiceNamespace: default
    maxPerPodContainerCount: 1
    minimumGCAge: 0s
    networkPluginMTU: 1500
    nonMasqueradeCidr: 10.0.0.0/8
    podSandboxImage: kubeedge/pause:3.1
    registerNode: true
    registerNodeNamespace: default
    registerSchedulable: true
    remoteImageEndpoint: unix:///var/run/dockershim.sock
    remoteRuntimeEndpoint: unix:///var/run/dockershim.sock
    rootDirectory: /var/lib/kubelet
    seccompProfileRoot: /var/lib/kubelet/seccomp
    tailoredKubeletConfig:
      address: 127.0.0.1
      cgroupDriver: cgroupfs
      cgroupsPerQOS: true
      configMapAndSecretChangeDetectionStrategy: Get
      containerLogMaxFiles: 5
      containerLogMaxSize: 10Mi
      contentType: application/json
      cpuCFSQuota: true
      cpuCFSQuotaPeriod: 100ms
      cpuManagerPolicy: none
      cpuManagerReconcilePeriod: 10s
      enableControllerAttachDetach: true
      enableDebugFlagsHandler: true
      enableDebuggingHandlers: true
      enableProfilingHandler: true
      enableServer: false
      enableSystemLogHandler: true
      enforceNodeAllocatable:
      - pods
      eventBurst: 10
      eventRecordQPS: 5
      evictionHard:
        imagefs.available: 15%
        memory.available: 100Mi
        nodefs.available: 10%
        nodefs.inodesFree: 5%
      evictionPressureTransitionPeriod: 5m0s
      failSwapOn: false
      fileCheckFrequency: 20s
      hairpinMode: promiscuous-bridge
      healthzBindAddress: 127.0.0.1
      healthzPort: 10248
      httpCheckFrequency: 20s
      imageGCHighThresholdPercent: 80
      imageGCLowThresholdPercent: 40
      imageMinimumGCAge: 2m0s
      iptablesDropBit: 15
      iptablesMasqueradeBit: 14
      kubeAPIBurst: 10
      kubeAPIQPS: 5
      logging:
        format: text
      makeIPTablesUtilChains: true
      maxOpenFiles: 1000000
      maxPods: 110
      memoryManagerPolicy: None
      memorySwap: {}
      memoryThrottlingFactor: 0.8
      nodeLeaseDurationSeconds: 40
      nodeStatusMaxImages: 50
      nodeStatusReportFrequency: 5m0s
      nodeStatusUpdateFrequency: 10s
      oomScoreAdj: -999
      podPidsLimit: -1
      readOnlyPort: 10350
      registryBurst: 10
      registryPullQPS: 5
      resolvConf: /etc/resolv.conf
      runtimeRequestTimeout: 2m0s
      seccompDefault: false
      serializeImagePulls: true
      shutdownGracePeriod: 0s
      shutdownGracePeriodCriticalPods: 0s
      streamingConnectionIdleTimeout: 4h0m0s
      syncFrequency: 1m0s
      topologyManagerPolicy: none
      topologyManagerScope: container
      volumePluginDir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/
      volumeStatsAggPeriod: 1m0s
  eventBus:
    enable: true
    eventBusTLS:
      enable: false
      tlsMqttCAFile: /etc/kubeedge/ca/rootCA.crt
      tlsMqttCertFile: /etc/kubeedge/certs/server.crt
      tlsMqttPrivateKeyFile: /etc/kubeedge/certs/server.key
    mqttMode: 2
    mqttPassword: ""
    mqttPubClientID: ""
    mqttQOS: 0
    mqttRetain: false
    mqttServerExternal: tcp://127.0.0.1:1883
    mqttServerInternal: tcp://127.0.0.1:1884
    mqttSessionQueueSize: 100
    mqttSubClientID: ""
    mqttUsername: ""
  metaManager:
    contextSendGroup: hub
    contextSendModule: websocket
    enable: true
    metaServer:
      enable: false
      server: 127.0.0.1:10550
      tlsCaFile: /etc/kubeedge/ca/rootCA.crt
      tlsCertFile: /etc/kubeedge/certs/server.crt
      tlsPrivateKeyFile: /etc/kubeedge/certs/server.key
    remoteQueryTimeout: 60
  serviceBus:
    enable: false
    port: 9060
    server: 127.0.0.1
    timeout: 60

  • 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
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 重启edgecore.service
systemctl restart edgecore.service
//如果需要可以查看日志
journalctl -u edgecore.service -f -n 200
  • 1
  • 2
  • 3
  • 云端检验连接
//可以看到新增的一个edge的边缘节点
kubectl get nodes

  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/327792
推荐阅读
相关标签
  

闽ICP备14008679号