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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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-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 public IP address which the edge can access to.
  16. 1. Can access the k8s master.
  17. Simply you can use the node which `cloudcore` of `kubeedge` is deployed at.
  18. The shell commands below should to be executed in this node and **one terminal session** in case keeping the shell variables.
  19. ### Download source
  20. ```shell
  21. git clone http://github.com/kubeedge/sedna.git
  22. cd sedna
  23. git checkout main
  24. ```
  25. ### Create CRDs
  26. ```shell
  27. # create these crds including dataset, model, joint-inference
  28. kubectl create -f build/crds/
  29. ```
  30. ### Deploy GM
  31. #### Prepare GM config
  32. Get `build/gm/gm-config.yaml` for a copy
  33. ```yaml
  34. kubeConfig: ""
  35. master: ""
  36. namespace: ""
  37. websocket:
  38. address: 0.0.0.0
  39. port: 9000
  40. localController:
  41. server: http://localhost:9100
  42. ```
  43. 1. `kubeConfig`: config to connect k8s, default `""`
  44. 1. `master`: k8s master addr, default `""`
  45. 1. `namespace`: the namespace GM watches, `""` means that gm watches all namespaces, default `""`.
  46. 1. `websocket`: since the current limit of kubeedge(1.5), GM needs to build the websocket channel for communicating between GM and LCs.
  47. 1. `localController`:
  48. - `server`: to be injected into the worker to connect LC.
  49. #### Run GM as k8s deployment:
  50. 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).
  51. 1\. Create the cluster role in case that gm can access/write the CRDs:
  52. ```shell
  53. # create the cluster role
  54. kubectl create -f build/gm/rbac/
  55. ```
  56. 2\. Prepare the config:
  57. ```shell
  58. # edit it with another number if you wish
  59. GM_PORT=9000
  60. LC_PORT=9100
  61. # here using github container registry for example
  62. # edit it with the truly container registry by your choice.
  63. IMAGE_REPO=kubeedge
  64. IMAGE_TAG=v0.1.0
  65. LC_SERVER="http://localhost:$LC_PORT"
  66. ```
  67. ```shell
  68. # copy and edit CONFIG_FILE.
  69. CONFIG_FILE=gm-config.yaml
  70. cp build/gm/gm-config.yaml $CONFIG_FILE
  71. # prepare the config with empty kubeconfig and empty master url meaning accessing k8s by rest.InClusterConfig().
  72. # here using sed command, alternative you can edit the config file manully.
  73. sed -i 's@kubeConfig:.*@kubeConfig: ""@' $CONFIG_FILE
  74. sed -i 's@master:.*@master: ""@' $CONFIG_FILE
  75. sed -i "s@port:.*@port: $GM_PORT@" $CONFIG_FILE
  76. # setting lc server
  77. sed -i "s@http://localhost:9100@$LC_SERVER@" $CONFIG_FILE
  78. ```
  79. 3\. Build the GM image:
  80. ```shell
  81. # build image from source OR use the gm image previous built.
  82. # edit it with the truly base repo by your choice.
  83. GM_IMAGE=$IMAGE_REPO/sedna-gm:$IMAGE_TAG
  84. make gmimage IMAGE_REPO=$IMAGE_REPO IMAGE_TAG=$IMAGE_TAG
  85. # push image to registry, login to registry first if needed
  86. docker push $GM_IMAGE
  87. ```
  88. 4\. Create gm configmap:
  89. ```shell
  90. # create configmap from $CONFIG_FILE
  91. CONFIG_NAME=gm-config # customize this configmap name
  92. kubectl create -n sedna configmap $CONFIG_NAME --from-file=$CONFIG_FILE
  93. ```
  94. 5\. Deploy GM as deployment:
  95. ```shell
  96. # we assign gm to the node which edge node can access to.
  97. # here current terminal node name, i.e. the k8s master node.
  98. # remember the GM_IP
  99. GM_NODE_NAME=$(hostname)
  100. kubectl apply -f - <<EOF
  101. apiVersion: v1
  102. kind: Service
  103. metadata:
  104. name: gm
  105. namespace: sedna
  106. spec:
  107. selector:
  108. app: gm
  109. type: NodePort
  110. ports:
  111. - protocol: TCP
  112. port: $GM_PORT
  113. targetPort: $GM_PORT
  114. ---
  115. apiVersion: apps/v1
  116. kind: Deployment
  117. metadata:
  118. name: gm
  119. labels:
  120. app: gm
  121. namespace: sedna
  122. spec:
  123. replicas: 1
  124. selector:
  125. matchLabels:
  126. app: gm
  127. template:
  128. metadata:
  129. labels:
  130. app: gm
  131. spec:
  132. nodeName: $GM_NODE_NAME
  133. serviceAccountName: sedna
  134. containers:
  135. - name: gm
  136. image: $GM_IMAGE
  137. command: ["sedna-gm", "--config", "/config/$CONFIG_FILE", "-v2"]
  138. volumeMounts:
  139. - name: gm-config
  140. mountPath: /config
  141. resources:
  142. requests:
  143. memory: 32Mi
  144. cpu: 100m
  145. limits:
  146. memory: 128Mi
  147. volumes:
  148. - name: gm-config
  149. configMap:
  150. name: $CONFIG_NAME
  151. EOF
  152. ```
  153. 6\. Check the GM status:
  154. ```shell
  155. kubectl get deploy -n sedna gm
  156. ```
  157. ### Deploy LC
  158. Prerequisites:
  159. 1. Run GM successfully.
  160. 2. Get the bind address/port of GM.
  161. Steps:
  162. 1\. Build LC image:
  163. ```shell
  164. LC_IMAGE=$IMAGE_REPO/sedna-lc:$IMAGE_TAG
  165. make lcimage IMAGE_REPO=$IMAGE_REPO IMAGE_TAG=$IMAGE_TAG
  166. # push image to registry, login to registry first if needed
  167. docker push $LC_IMAGE
  168. ```
  169. 2\. Deploy LC as k8s daemonset:
  170. ```shell
  171. gm_node_port=$(kubectl -n sedna get svc gm -ojsonpath='{.spec.ports[0].nodePort}')
  172. # fill the GM_NODE_NAME's ip which edge node can access to.
  173. # such as gm_node_ip=192.168.0.9
  174. # gm_node_ip=<GM_NODE_NAME_IP_ADDRESS>
  175. # here try to get node ip by kubectl
  176. gm_node_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="ExternalIP")].address }')
  177. gm_node_internal_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="InternalIP")].address }')
  178. GM_ADDRESS=${gm_node_ip:-$gm_node_internal_ip}:$gm_node_port
  179. kubectl create -f- <<EOF
  180. apiVersion: apps/v1
  181. kind: DaemonSet
  182. metadata:
  183. labels:
  184. k8s-app: sedna-lc
  185. name: lc
  186. namespace: sedna
  187. spec:
  188. selector:
  189. matchLabels:
  190. k8s-app: lc
  191. template:
  192. metadata:
  193. labels:
  194. k8s-app: lc
  195. spec:
  196. containers:
  197. - name: lc
  198. image: $LC_IMAGE
  199. env:
  200. - name: GM_ADDRESS
  201. value: $GM_ADDRESS
  202. - name: BIND_PORT
  203. value: "$LC_PORT"
  204. - name: NODENAME
  205. valueFrom:
  206. fieldRef:
  207. fieldPath: spec.nodeName
  208. - name: ROOTFS_MOUNT_DIR
  209. # the value of ROOTFS_MOUNT_DIR is same with the mount path of volume
  210. value: /rootfs
  211. resources:
  212. requests:
  213. memory: 32Mi
  214. cpu: 100m
  215. limits:
  216. memory: 128Mi
  217. volumeMounts:
  218. - name: localcontroller
  219. mountPath: /rootfs
  220. volumes:
  221. - name: localcontroller
  222. hostPath:
  223. path: /
  224. restartPolicy: Always
  225. hostNetwork: true
  226. EOF
  227. ```
  228. 3\. Check the LC status:
  229. ```shell
  230. kubectl get ds lc -n sedna
  231. kubectl get pod -n sedna
  232. ```
  233. [git_tool]:https://git-scm.com/downloads
  234. [go_tool]:https://golang.org/dl/
  235. [kubeedge]:https://github.com/kubeedge/kubeedge
  236. [kubernetes]:https://kubernetes.io/