From 08bb8b4c5faef121988f79e025d2809f09ed15de Mon Sep 17 00:00:00 2001 From: llhuii Date: Thu, 1 Apr 2021 11:55:39 +0800 Subject: [PATCH] Add all-in-one installation script 1. add all-in-one installation script. also support uninstall operation. 2. update the installation docs using the all-in-one script Signed-off-by: llhuii --- docs/setup/install.md | 228 +++---------------------- scripts/installation/install.sh | 292 ++++++++++++++++++++++++++++++++ 2 files changed, 314 insertions(+), 206 deletions(-) create mode 100644 scripts/installation/install.sh diff --git a/docs/setup/install.md b/docs/setup/install.md index a3e4e767d..3fd4908de 100644 --- a/docs/setup/install.md +++ b/docs/setup/install.md @@ -1,86 +1,15 @@ -* [Prerequisites](#prerequisites) -* [Download project source](#download-source) -* [Create CRDs](#create-crds) -* [Deploy GM](#deploy-gm) - * [Prepare GM config](#prepare-gm-config) - * [Run GM as k8s deployment](#run-gm-as-a-k8s-deployment) -* [Deploy LC](#deploy-lc) - -## Deploy Sedna - ### Prerequisites - - [GIT][git_tool] -- [GO][go_tool] version v1.15+. -- [Kubernetes][kubernetes] 1.16+. -- [KubeEdge][kubeedge] version v.15+. +- [KUBECTL][kubectl] with right kubeconfig +- [Kubernetes][kubernetes] 1.16+ cluster running +- [KubeEdge][kubeedge] v.15+ running GM will be deployed to a node which has satisfied these requirements: 1. Has a IP address which the edge can access to. 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/kubeedge/sedna.git -cd sedna -git checkout main -``` - -### Create CRDs - -```shell -# create these crds including dataset, model, joint-inference etc. -kubectl create -f build/crds/ -``` - -### Deploy GM - -#### Prepare GM config -The content of `build/gm/gm-config.yaml`: -```yaml -kubeConfig: "" -master: "" -namespace: "" -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. `localController`: - - `server`: to be injected into the worker to connect LC. - -Edit the config file if you wish. - -Note: if you just want to use the default values, don't need to run the below commands. -```shell -# edit build/gm/gm-config.yaml, here using sed command. -# alternative you can edit the config file manully. -GM_CONFIG_FILE=build/gm/gm-config.yaml - -# 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. -LC_BIND_PORT=9100 - -LC_SERVER="http://localhost:$LC_BIND_PORT" - -# setting lc server -sed -i "s@http://localhost:9100@$LC_SERVER@" $GM_CONFIG_FILE -``` - -#### Run GM as a K8S Deployment: - -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 roles in order to GM can access/write the CRDs: -```shell -# create the cluster role -kubectl create -f build/gm/rbac/ -``` - -2\. Deploy GM as deployment: +#### Deploy Sedna Currently we need to deploy GM to a k8s node which edge node can access to. @@ -94,155 +23,42 @@ sedna-control-plane Ready control-plane,master 3d21h v1.20.2 ``` In this example the node `sedna-control-plane` has a internal-ip 172.18.0.2, and `edge-node` can access it. -So we can set `GM_NODE_NAME=sedna-control-plane` in below instructions: +So we can set `SEDNA_GM_NODE=sedna-control-plane` in below instructions: ```shell # set the right node where edge node can be access -# GM_NODE_NAME=sedna-control-plane -GM_NODE_NAME=CHANGE-ME-HERE - -# create configmap from $GM_CONFIG_FILE -GM_CONFIG_FILE=${GM_CONFIG_FILE:-build/gm/gm-config.yaml} +# SEDNA_GM_NODE=sedna-control-plane +SEDNA_GM_NODE=CHANGE-ME-HERE -GM_CONFIG_FILE_NAME=$(basename $GM_CONFIG_FILE) -kubectl create -n sedna configmap gm-config --from-file=$GM_CONFIG_FILE - - -kubectl apply -f - < - -# Here is the automatical way: 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 get ds lc -n sedna +``` -kubectl create -f- < $config_file << EOF +kubeConfig: "" +master: "" +namespace: "" +websocket: + address: 0.0.0.0 + port: 9000 +localController: + server: http://localhost:${SEDNA_LC_BIND_PORT:-9100} +EOF + fi + + kubectl $action -n sedna configmap $cm_name --from-file=$config_file +} + +do_gm() { + cd ${TMP_DIR} + + kubectl $action -f build/crds + + kubectl $action -f build/gm/rbac/ + + if [ "$action" == delete ] ; then + kubectl label node/$GM_NODE_NAME sedna- | sed 's/labeled$/un&/' || true + return + fi + + kubectl label node/$GM_NODE_NAME sedna=gm || true + + cm_name=gm-config + config_file_name=gm.yaml + prepare_gm_config_map $cm_name $config_file_name + + + kubectl $action -f - </dev/null +} + +check_action() { + action=${SEDNA_ACTION:-create} + support_action_list="create delete" + if ! echo "$support_action_list" | grep -w -q "$action"; then + echo "\`$action\` not in support action list: create/delete!" >&2 + echo "You need to specify it by setting $(red_text SEDNA_ACTION) environment variable when running this script!" >&2 + exit 2 + fi + +} + +check_gm_node() { + GM_NODE_NAME=${SEDNA_GM_NODE:-} + + if [ -z "$GM_NODE_NAME" ] || ! kubectl get node $GM_NODE_NAME; then + echo "ERROR: $(red_text GM node name \`$GM_NODE_NAME\` does not exist in k8s cluster)!" >&2 + echo "You need to specify it by setting $(red_text SEDNA_GM_NODE) environment variable when running this script!" >&2 + exit 1 + fi +} + +do_check() { + check_kubectl + check_action + check_gm_node +} + +show_debug_infos() { + cat - <