You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.md 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. * [Prerequisites](#prerequisites)
  2. * [Download project source](#download-source)
  3. * [Create CRDs](#create-crds)
  4. * [Deploy GM](#deploy-gm)
  5. * [Prepare GM config](#prepare-gm-config)
  6. * [Run GM as k8s deployment](#run-gm-as-a-k8s-deployment)
  7. * [Deploy LC](#deploy-lc)
  8. ## Deploy Sedna
  9. ### Prerequisites
  10. - [GIT][git_tool]
  11. - [GO][go_tool] version v1.15+.
  12. - [Kubernetes][kubernetes] 1.16+.
  13. - [KubeEdge][kubeedge] version v.15+.
  14. GM will be deployed to a node which has satisfied these requirements:
  15. 1. Has a IP address which the edge can access to.
  16. Simply you can use the node which `cloudcore` of `kubeedge` is deployed at.
  17. The shell commands below should to be executed in this node and **one terminal session** in case keeping the shell variables.
  18. ### Download source
  19. ```shell
  20. git clone http://github.com/kubeedge/sedna.git
  21. cd sedna
  22. git checkout main
  23. ```
  24. ### Create CRDs
  25. ```shell
  26. # create these crds including dataset, model, joint-inference etc.
  27. kubectl create -f build/crds/
  28. ```
  29. ### Deploy GM
  30. #### Prepare GM config
  31. The content of `build/gm/gm-config.yaml`:
  32. ```yaml
  33. kubeConfig: ""
  34. master: ""
  35. namespace: ""
  36. localController:
  37. server: http://localhost:9100
  38. ```
  39. 1. `kubeConfig`: config to connect k8s, default `""`
  40. 1. `master`: k8s master addr, default `""`
  41. 1. `namespace`: the namespace GM watches, `""` means that gm watches all namespaces, default `""`.
  42. 1. `localController`:
  43. - `server`: to be injected into the worker to connect LC.
  44. Edit the config file if you wish.
  45. Note: if you just want to use the default values, don't need to run the below commands.
  46. ```shell
  47. # edit build/gm/gm-config.yaml, here using sed command.
  48. # alternative you can edit the config file manully.
  49. GM_CONFIG_FILE=build/gm/gm-config.yaml
  50. # here edit it with another LC bind ports if you wish or it's conflict with your node environment since LC is deployed in host namespace.
  51. LC_BIND_PORT=9100
  52. LC_SERVER="http://localhost:$LC_BIND_PORT"
  53. # setting lc server
  54. sed -i "s@http://localhost:9100@$LC_SERVER@" $GM_CONFIG_FILE
  55. ```
  56. #### Run GM as a K8S Deployment:
  57. We don't need to config the kubeconfig in this method said by [accessing the API from a Pod](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod).
  58. 1\. Create the cluster roles in order to GM can access/write the CRDs:
  59. ```shell
  60. # create the cluster role
  61. kubectl create -f build/gm/rbac/
  62. ```
  63. 2\. Deploy GM as deployment:
  64. Currently we need to deploy GM to a k8s node which edge node can access to.
  65. More specifically, the k8s node has a INTERNAL-IP or EXTERNAL-IP where edge node can access to.
  66. For example, in a kind cluster `kubectl get node -o wide`:
  67. ```shell
  68. NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
  69. edge-node Ready agent,edge 3d21h v1.19.3-kubeedge-v1.6.1 192.168.0.233 <none> Ubuntu 18.04.5 LTS 4.15.0-128-generic docker://20.10.2
  70. sedna-control-plane Ready control-plane,master 3d21h v1.20.2 172.18.0.2 <none> Ubuntu 20.10 4.15.0-128-generic containerd://1.5.0-beta.3-24-g95513021e
  71. ```
  72. In this example the node `sedna-control-plane` has a internal-ip 172.18.0.2, and `edge-node` can access it.
  73. So we can set `GM_NODE_NAME=sedna-control-plane` in below instructions:
  74. ```shell
  75. # set the right node where edge node can be access
  76. # GM_NODE_NAME=sedna-control-plane
  77. GM_NODE_NAME=CHANGE-ME-HERE
  78. # create configmap from $GM_CONFIG_FILE
  79. GM_CONFIG_FILE=${GM_CONFIG_FILE:-build/gm/gm-config.yaml}
  80. GM_CONFIG_FILE_NAME=$(basename $GM_CONFIG_FILE)
  81. kubectl create -n sedna configmap gm-config --from-file=$GM_CONFIG_FILE
  82. kubectl apply -f - <<EOF
  83. apiVersion: v1
  84. kind: Service
  85. metadata:
  86. name: gm
  87. namespace: sedna
  88. spec:
  89. selector:
  90. app: gm
  91. type: NodePort
  92. ports:
  93. - protocol: TCP
  94. port: 9000
  95. targetPort: 9000
  96. ---
  97. apiVersion: apps/v1
  98. kind: Deployment
  99. metadata:
  100. name: gm
  101. labels:
  102. app: gm
  103. namespace: sedna
  104. spec:
  105. replicas: 1
  106. selector:
  107. matchLabels:
  108. app: gm
  109. template:
  110. metadata:
  111. labels:
  112. app: gm
  113. spec:
  114. nodeName: $GM_NODE_NAME
  115. serviceAccountName: sedna
  116. containers:
  117. - name: gm
  118. image: kubeedge/sedna-gm:v0.1.0
  119. command: ["sedna-gm", "--config", "/config/$GM_CONFIG_FILE_NAME", "-v2"]
  120. volumeMounts:
  121. - name: gm-config
  122. mountPath: /config
  123. resources:
  124. requests:
  125. memory: 32Mi
  126. cpu: 100m
  127. limits:
  128. memory: 128Mi
  129. volumes:
  130. - name: gm-config
  131. configMap:
  132. name: gm-config
  133. EOF
  134. ```
  135. 4\. Check the GM status:
  136. ```shell
  137. kubectl get deploy -n sedna gm
  138. ```
  139. ### Deploy LC
  140. Prerequisites:
  141. 1. Run GM successfully.
  142. 1\. Deploy LC as k8s daemonset:
  143. ```shell
  144. gm_node_port=$(kubectl -n sedna get svc gm -ojsonpath='{.spec.ports[0].nodePort}')
  145. # fill the GM_NODE_NAME's ip which edge node can access to.
  146. # such as gm_node_ip=192.168.0.9
  147. # gm_node_ip=<GM_NODE_NAME_IP_ADDRESS>
  148. # Here is the automatical way: try to get node ip by kubectl
  149. gm_node_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="ExternalIP")].address }')
  150. gm_node_internal_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="InternalIP")].address }')
  151. GM_ADDRESS=${gm_node_ip:-$gm_node_internal_ip}:$gm_node_port
  152. kubectl create -f- <<EOF
  153. apiVersion: apps/v1
  154. kind: DaemonSet
  155. metadata:
  156. labels:
  157. k8s-app: sedna-lc
  158. name: lc
  159. namespace: sedna
  160. spec:
  161. selector:
  162. matchLabels:
  163. k8s-app: lc
  164. template:
  165. metadata:
  166. labels:
  167. k8s-app: lc
  168. spec:
  169. containers:
  170. - name: lc
  171. image: kubeedge/sedna-lc:v0.1.0
  172. env:
  173. - name: GM_ADDRESS
  174. value: $GM_ADDRESS
  175. - name: BIND_PORT
  176. value: "${LC_BIND_PORT:-9100}"
  177. - name: NODENAME
  178. valueFrom:
  179. fieldRef:
  180. fieldPath: spec.nodeName
  181. - name: ROOTFS_MOUNT_DIR
  182. # the value of ROOTFS_MOUNT_DIR is same with the mount path of volume
  183. value: /rootfs
  184. resources:
  185. requests:
  186. memory: 32Mi
  187. cpu: 100m
  188. limits:
  189. memory: 128Mi
  190. volumeMounts:
  191. - name: localcontroller
  192. mountPath: /rootfs
  193. volumes:
  194. - name: localcontroller
  195. hostPath:
  196. path: /
  197. restartPolicy: Always
  198. hostNetwork: true
  199. EOF
  200. ```
  201. 2\. Check the LC status:
  202. ```shell
  203. kubectl get ds lc -n sedna
  204. kubectl get pod -n sedna
  205. ```
  206. [git_tool]:https://git-scm.com/downloads
  207. [go_tool]:https://golang.org/dl/
  208. [kubeedge]:https://github.com/kubeedge/kubeedge
  209. [kubernetes]:https://kubernetes.io/