kubeedge / kubeedge

Kubernetes Native Edge Computing Framework (project under CNCF)
https://kubeedge.io
Apache License 2.0
6.63k stars 1.71k forks source link

Easy way to provision containerized multi-node KubeEdge env for app development/testing purpose #3984

Open kevin-wangzefeng opened 2 years ago

kevin-wangzefeng commented 2 years ago

What would you like to be added/modified: A tool that easily spin up a multi-node KubeEdge environment (and better on just one machine).

Why is this needed:

For app development cases, developers need an easy way to get a multi-node KubeEdge environment, so that they can focus on the application or other upper-layer platform development.

Differenct to EdgeMark which uses hollow edge node, all the components need to be really running and serving. Local-up-cluster.sh is more a script for kubeedge/kubeedge develops to dev/test the KubeEdge core platform itself.

kevin-wangzefeng commented 2 years ago

Initial idea -- we can wrap Kind for implementing this tool:

  1. rely on Kind for the control-plane provisioning
  2. implement containerized edgenodes part by ourselves.
  3. the edgenode part we can also refer to the kind node construction process and import some basic building blocks.
kevin-wangzefeng commented 2 years ago

/cc @fisherxu @gy95

gy95 commented 2 years ago

Technically feasible, by test, # bin/kind create cluster --config example.yaml --image kindest/node:latest

output is like below

Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:latest) đŸ–ŧ
 ✓ Preparing nodes đŸ“Ļ đŸ“Ļ đŸ“Ļ  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ī¸ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
 ✓ Joining worker nodes 🚜 
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! 👋
 ✓ Starting KubeEdge 📜 
 ✓ Joining edge nodes 🚜
# kubectl get node -owide
NAME                 STATUS   ROLES                  AGE   VERSION                                              INTERNAL-IP   EXTERNAL-IP   OS-IMAGE       KERNEL-VERSION       CONTAINER-RUNTIME
kind-control-plane   Ready    control-plane,master   71s   v1.23.4                                              172.18.0.2    <none>        Ubuntu 21.04   4.15.0-169-generic   containerd://1.5.2
kind-edge-node       Ready    agent,edge             49s   v1.22.6-kubeedge-v1.11.0-beta.0.102+138bc34e64e008   172.18.0.3    <none>        Ubuntu 21.04   4.15.0-169-generic   remote://1.5.2
kind-worker          Ready    <none>                 48s   v1.23.4                                              172.18.0.4    <none>        Ubuntu 21.04   4.15.0-169-generic   containerd://1.5.2

example.yaml is like below

# cat example.yaml 
# this config file contains all config fields with comments
# NOTE: this is not a particularly useful config file
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
# patch the generated kubeadm config with some extra settings
kubeadmConfigPatches:
  - |
    apiVersion: kubelet.config.k8s.io/v1beta1
    kind: KubeletConfiguration
    evictionHard:
      nodefs.available: "0%"
# patch it further using a JSON 6902 patch
kubeadmConfigPatchesJSON6902:
  - group: kubeadm.k8s.io
    version: v1beta2
    kind: ClusterConfiguration
    patch: |
      - op: add
        path: /apiServer/certSANs/-
        value: my-hostname
# 1 control plane node and 1 worker and 1 edge-node
nodes:
  # the control plane node config
  - role: control-plane
  # the  workers
  - role: worker
  # the  edge nodes
  - role: edge-node
gy95 commented 2 years ago

updated the above description

gy95 commented 2 years ago

source codes ref: https://github.com/gy95/kind/tree/release-v0.11