EdgeX Foundry

For more details about these two components, please refer to , Yurt-EdgeX-Manager

If you don’t have an OpenYurt on hand, you can use to create one or convert from an exist Kubernetes cluster.

Environment

  • OpenYurt v0.5.0+

  • You should first install .

  • Set ServiceTopology to for CoreDNS service. For details, please refer to ServiceTopology

1. install yurt-edgex-manager and create an EdgeX insatnce

install yurt-edgex-manager

Create a nodepool named hangzhou, join node into this nodepool.

  1. $ export WORKER_NODEPOOL="hangzhou"
  2. $ export EDGE_NODE="node1"
  3. # create nodepool hangzhou
  4. $ cat <<EOF | kubectl apply -f -
  5. apiVersion: apps.openyurt.io/v1alpha1
  6. kind: NodePool
  7. metadata:
  8. name: $WORKER_NODEPOOL
  9. spec:
  10. type: Edge
  11. EOF
  12. # join edge node into nodepool hangzhou
  13. $ kubectl label node $EDGE_NODE apps.openyurt.io/desired-nodepool=hangzhou
  14. # check node status
  15. $ kubectl get nodepool
  16. NAME TYPE READYNODES NOTREADYNODES AGE
  17. hangzhou Edge 0 1 6d22h

create EdgeX Foundry instance in nodepool hangzhou and deploy edgex-device-virtual

  1. apiVersion: device.openyurt.io/v1alpha1
  2. kind: EdgeX
  3. metadata:
  4. name: edgex-sample-beijing
  5. spec:
  6. version: jakarta
  7. poolname: hangzhou
  8. ---
  9. apiVersion: apps/v1
  10. kind: Deployment
  11. metadata:
  12. labels:
  13. org.edgexfoundry.service: edgex-device-virtual
  14. name: edgex-device-virtual
  15. spec:
  16. replicas: 1
  17. selector:
  18. matchLabels:
  19. org.edgexfoundry.service: edgex-device-virtual
  20. strategy:
  21. type: Recreate
  22. template:
  23. metadata:
  24. labels:
  25. org.edgexfoundry.service: edgex-device-virtual
  26. spec:
  27. hostname: edgex-device-virtual
  28. nodeSelector:
  29. apps.openyurt.io/nodepool: hangzhou
  30. containers:
  31. - name: edgex-device-virtual
  32. image: openyurt/device-virtual:2.1.0
  33. imagePullPolicy: IfNotPresent
  34. ports:
  35. - containerPort: 59900
  36. name: "tcp-59900"
  37. protocol: TCP
  38. env:
  39. - name: MESSAGEQUEUE_HOST
  40. value: edgex-redis
  41. - name: SERVICE_HOST
  42. value: edgex-device-virtual
  43. envFrom:
  44. - configMapRef:
  45. name: common-variables
  46. startupProbe:
  47. tcpSocket:
  48. periodSeconds: 1
  49. failureThreshold: 120
  50. livenessProbe:
  51. tcpSocket:
  52. port: 59900
  53. ---
  54. apiVersion: v1
  55. kind: Service
  56. metadata:
  57. labels:
  58. org.edgexfoundry.service: edgex-device-virtual
  59. name: edgex-device-virtual
  60. spec:
  61. ports:
  62. - name: "tcp-59900"
  63. port: 59900
  64. protocol: TCP
  65. targetPort: 59900
  66. selector:
  67. org.edgexfoundry.service: edgex-device-virtual
  68. type: NodePort

2. install yurt-device-controller

install CRDs of yurt-device-controller

  1. $ kubectl apply -f https://raw.githubusercontent.com/openyurtio/yurt-device-controller/main/config/setup/crd.yaml

use UnitedDeployment to deploy yurt-device-controller instance in nodepool hangzhou. It should be pointed out that we use cluster-admin ClusterRole just for demo purpose

  1. apiVersion: apps.openyurt.io/v1alpha1
  2. kind: UnitedDeployment
  3. metadata:
  4. labels:
  5. controller-tools.k8s.io: "1.0"
  6. name: ud-device
  7. namespace: default
  8. spec:
  9. selector:
  10. matchLabels:
  11. app: ud-device
  12. topology:
  13. pools:
  14. - name: hangzhou
  15. nodeSelectorTerm:
  16. matchExpressions:
  17. - key: apps.openyurt.io/nodepool
  18. operator: In
  19. values:
  20. - hangzhou
  21. replicas: 1
  22. tolerations:
  23. - operator: Exists
  24. workloadTemplate:
  25. deploymentTemplate:
  26. metadata:
  27. creationTimestamp: null
  28. labels:
  29. app: ud-device
  30. spec:
  31. selector:
  32. matchLabels:
  33. app: ud-device
  34. strategy: {}
  35. template:
  36. metadata:
  37. creationTimestamp: null
  38. labels:
  39. app: ud-device
  40. control-plane: controller-manager
  41. spec:
  42. containers:
  43. - args:
  44. - --health-probe-bind-address=:8081
  45. - --metrics-bind-address=127.0.0.1:8080
  46. - --leader-elect=false
  47. - --namespace=default
  48. - --v=5
  49. command:
  50. - /yurt-device-controller
  51. image: openyurt/yurt-device-controller:v0.2.0
  52. imagePullPolicy: IfNotPresent
  53. livenessProbe:
  54. httpGet:
  55. path: /healthz
  56. scheme: HTTP
  57. initialDelaySeconds: 15
  58. periodSeconds: 20
  59. successThreshold: 1
  60. timeoutSeconds: 1
  61. name: manager
  62. readinessProbe:
  63. failureThreshold: 3
  64. httpGet:
  65. path: /readyz
  66. port: 8081
  67. scheme: HTTP
  68. initialDelaySeconds: 5
  69. periodSeconds: 10
  70. successThreshold: 1
  71. timeoutSeconds: 1
  72. resources:
  73. limits:
  74. cpu: 100m
  75. memory: 512Mi
  76. requests:
  77. cpu: 100m
  78. memory: 512Mi
  79. securityContext:
  80. allowPrivilegeEscalation: false
  81. dnsPolicy: ClusterFirst
  82. restartPolicy: Always
  83. securityContext:
  84. runAsUser: 65532
  85. ---
  86. apiVersion: rbac.authorization.k8s.io/v1
  87. kind: ClusterRoleBinding
  88. metadata:
  89. name: ud-rolebinding
  90. roleRef:
  91. apiGroup: rbac.authorization.k8s.io
  92. kind: ClusterRole
  93. name: cluster-admin
  94. subjects:
  95. - kind: ServiceAccount
  96. name: default
  97. namespace: default

check whether yurt-device-controller has been deployed successful

3. Check virtual devices synced from EdgeX

The device-virtual-go driver will automatically create and register 5 virtual devices of different kinds upon start, yurt-device-controller will then sync them to OpenYurt. You can use kubectl to check it:

  1. $ kubectl get device
  2. NAME NODEPOOL SYNCED AGE
  3. hangzhou-random-binary-device hangzhou true 19h
  4. hangzhou-random-boolean-device hangzhou true 19h
  5. hangzhou-random-float-device hangzhou true 19h
  6. hangzhou-random-integer-device hangzhou true 19h
  7. hangzhou-random-unsignedinteger-device hangzhou true 19h

4. Uninstall and cleanup

  1. $ export WORKER_NODEPOOL="hangzhou"
  2. $ export EDGE_NODE="node1"
  3. # 1.1 delete all device, deviceservice, deviceprofile资源
  4. $ kubectl delete device --all
  5. $ kubectl delete deviceprofile --all
  6. $ kubectl delete deviceservice --all
  7. # 1.2 uninstall yurt-device-controller
  8. $ kubectl delete uniteddeployment yurt-device-controller
  9. $ kubectl delete clusterrolebinding ud-rolebinding
  10. # 1.3 delete CRDs of yurt-device-controller
  11. $ kubectl delete -f https://raw.githubusercontent.com/openyurtio/yurt-device-controller/main/config/setup/crd.yaml
  12. # 2.1 delete EdgeX instance
  13. $ kubectl delete edgex --all
  14. # 2.2 uninstall yurt-edgex-manager
  15. $ kubectl delete -f https://github.com/openyurtio/yurt-edgex-manager/releases/download/v0.2.0/yurt-edgex-manager.yaml
  16. # (optional)
  17. # 3.1 remove node from nodepool
  18. $ kubectl label node $EDGE_NODE apps.openyurt.io/desired-nodepool-
  19. $ kubectl delete nodepool $WORKER_NODEPOOL