* [Prerequisites](#prerequisites) * [Download project source](#download-source) * [Create CRDs](#create-crds) * [Deploy GM](#deploy-gm) * [Prepare GM config](#prepare-gm-config) * [Build worker base images](#build-worker-base-images) * [Run GM as k8s deployment(recommended)](#run-gm-as-k8s-deploymentrecommended) * [Run GM as a single process(alternative)](#run-gm-as-a-single-processalternative) * [Run GM as docker container(alternative)](#run-gm-as-docker-containeralternative) * [Deploy LC](#deploy-lc) ## Deploy Neptune ### Prerequisites - [GIT][git_tool] - [GO][go_tool] version v1.15+. - [Kubernetes][kubernetes] 1.16+. - [KubeEdge][kubeedge] version v.15+. GM will be deployed to a node which has satisfied these requirements: 1. Has a public IP address which the edge can access to. 1. Can access the k8s master. Simply you can use the node which `cloudcore` of `kubeedge` is deployed at. The shell commands below should to be executed in this node and **one terminal session** in case keeping the shell variables. ### Download source ```shell git clone http://github.com/edgeai-neptune/neptune.git cd neptune git checkout master ``` ### Create CRDs ```shell # create these crds including dataset, model, joint-inference kubectl apply -f build/crds/neptune/ ``` ### Deploy GM #### Prepare GM config Get `build/gm/gm-config.yaml` for a copy ```yaml kubeConfig: "" master: "" namespace: "" imageHub: "tensorflow:1.15": "docker.io/neptune/tensorflow-base-image-to-filled:1.15" websocket: address: 0.0.0.0 port: 9000 localController: server: http://localhost:9100 ``` 1. `kubeConfig`: config to connect k8s, default `""` 1. `master`: k8s master addr, default `""` 1. `namespace`: the namespace GM watches, `""` means that gm watches all namespaces, default `""`. 1. `imageHub`: the base image mapping for model training/evaluation/inference which key is frameworkType/frameVersion. 1. `websocket`: since the current limit of kubeedge(1.5), GM needs to build the websocket channel for communicating between GM and LCs. 1. `localController`: - `server`: to be injected into the worker to connect LC. #### Build worker base images Here build worker base image for tensorflow 1.15 for example: ```shell # here using github container registry for example. # edit it with the truly container registry by your choice. IMAGE_REPO=ghcr.io/edgeai-neptune/neptune # build tensorflow image WORKER_TF1_IMAGE=$IMAGE_REPO/worker-tensorflow:1.15 docker build -f build/worker/base_images/tensorflow/tensorflow-1.15.Dockerfile -t $WORKER_TF1_IMAGE . # push worker image to registry, login to registry first if needed docker push $WORKER_TF1_IMAGE ``` There are some methods to run gm, you can choose one method below: #### Run GM as k8s deployment(**recommended**): 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). 1\. Create the cluster role in case that gm can access/write the CRDs: ```shell # create the cluster role kubectl create -f build/gm/rbac/ ``` 2\. Prepare the config: ```shell # edit it with another number if you wish GM_PORT=9000 LC_PORT=9100 # here using github container registry for example # edit it with the truly container registry by your choice. IMAGE_REPO=ghcr.io/edgeai-neptune/neptune IMAGE_TAG=v1alpha1 LC_SERVER="http://localhost:$LC_PORT" ``` ```shell # copy and edit CONFIG_FILE. CONFIG_FILE=gm-config.yaml cp build/gm/gm-config.yaml $CONFIG_FILE # prepare the config with empty kubeconfig and empty master url meaning accessing k8s by rest.InClusterConfig(). # here using sed command, alternative you can edit the config file manully. sed -i 's@kubeConfig:.*@kubeConfig: ""@' $CONFIG_FILE sed -i 's@master:.*@master: ""@' $CONFIG_FILE sed -i "s@port:.*@port: $GM_PORT@" $CONFIG_FILE # setting tensorflow1.15 base image sed -i 's@\("tensorflow:1.15":\).*@\1 '"$WORKER_TF1_IMAGE@" $CONFIG_FILE # setting lc server sed -i "s@http://localhost:9100@$LC_SERVER@" $CONFIG_FILE ``` 3\. Build the GM image: ```shell # build image from source OR use the gm image previous built. # edit it with the truly base repo by your choice. GM_IMAGE=$IMAGE_REPO/gm:$IMAGE_TAG make gmimage IMAGE_REPO=$IMAGE_REPO IMAGE_TAG=$IMAGE_TAG # push image to registry, login to registry first if needed docker push $GM_IMAGE ``` 4\. Create gm configmap: ```shell # create configmap from $CONFIG_FILE CONFIG_NAME=gm-config # customize this configmap name kubectl create -n neptune configmap $CONFIG_NAME --from-file=$CONFIG_FILE ``` 5\. Deploy GM as deployment: ```shell # we assign gm to the node which edge node can access to. # here current terminal node name, i.e. the k8s master node. # remember the GM_IP GM_NODE_NAME=$(hostname) kubectl apply -f - < # here try to get node ip by kubectl gm_node_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="ExternalIP")].address }') gm_node_internal_ip=$(kubectl get node $GM_NODE_NAME -o jsonpath='{ .status.addresses[?(@.type=="InternalIP")].address }') GM_ADDRESS=${gm_node_ip:-$gm_node_internal_ip}:$gm_node_port kubectl create -f- <