diff --git a/.gitignore b/.gitignore index 423a54b..6cc5e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ poc-cb-net/cmd/test-client/check-response-time-of-cb-tumblebug-api/check-respons poc-cb-net/cmd/agent/secret/ *.pem *.pub +bin/ diff --git a/Dockerfile-service b/Dockerfile-service index 6a7bde4..811eb7c 100644 --- a/Dockerfile-service +++ b/Dockerfile-service @@ -28,9 +28,12 @@ FROM alpine:latest WORKDIR /app RUN mkdir -p config +RUN mkdir -p docs # Copy the execution file COPY --from=builder /cb-larva/poc-cb-net/cmd/service/service . +# Copy the swagger.json for Swagger dashboard +COPY --from=builder /cb-larva/poc-cb-net/docs/cloud_barista_network.swagger.json ./docs/ # Ports for the cb-network service EXPOSE 8053 diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..c928259 --- /dev/null +++ b/build.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# root path of cb-larva +echo "1. Set CBLARVA_ROOT path" +sleep 2 +SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}` +export CBLARVA_ROOT=`cd $SCRIPT_DIR && pwd` +echo ${CBLARVA_ROOT} +echo "" + +# create directory +echo "2. Create directories for binaries and assets" +sleep 2 +mkdir ${CBLARVA_ROOT}/bin +mkdir ${CBLARVA_ROOT}/bin/config +mkdir ${CBLARVA_ROOT}/bin/web +mkdir ${CBLARVA_ROOT}/bin/docs + +echo "tree -L 2 -N ${CBLARVA_ROOT}/bin" +sleep 2 +tree -L 2 -N ${CBLARVA_ROOT}/bin +echo "" + +# build all cb-network system components +echo "3. Build binaries" +sleep 2 +cd ${CBLARVA_ROOT}/poc-cb-net +make +echo "" + +# copy binaries and assets to 'bin' +echo "4. Copy binaries and assets to 'bin'" +sleep 2 +cd ${CBLARVA_ROOT}/bin + +# copy cb-network controller binary +cp ${CBLARVA_ROOT}/poc-cb-net/cmd/controller/controller ./ + +# copy service binary and asset +cp ${CBLARVA_ROOT}/poc-cb-net/cmd/service/service ./ +cp ${CBLARVA_ROOT}/poc-cb-net/docs/cloud_barista_network.swagger.json ./docs/ + +# copy cb-network admin-web binary and assets +cp ${CBLARVA_ROOT}/poc-cb-net/cmd/admin-web/admin-web ./ +cp -r ${CBLARVA_ROOT}/poc-cb-net/web/* ./web/ + +# copy config files +cp ${CBLARVA_ROOT}/poc-cb-net/config/template-config.yaml ./config/config.yaml +cp ${CBLARVA_ROOT}/poc-cb-net/config/template-log_conf.yaml ./config/log_conf.yaml + +echo "tree -L 2 -N ${CBLARVA_ROOT}/bin" +sleep 2 +tree -L 2 +echo "" + +echo "Done to build" +sleep 2 +echo "" +echo "[Note] Please, edit 'config.yaml' and 'log_conf.yaml' before running binaries" +echo "[Note] Please, edit 'config.yaml' and 'log_conf.yaml' before running binaries" +echo "[Note] Please, edit 'config.yaml' and 'log_conf.yaml' before running binaries" diff --git a/poc-cb-net/Makefile b/poc-cb-net/Makefile index 1c0215b..c698ec1 100644 --- a/poc-cb-net/Makefile +++ b/poc-cb-net/Makefile @@ -1,12 +1,20 @@ +default: controller service admin_web agent demo_client -default: - @echo "Build" +controller: go build -mod=mod -o ./cmd/controller/controller ./cmd/controller/controller.go + +service: go build -mod=mod -o ./cmd/service/service ./cmd/service/service.go + +admin_web: go build -mod=mod -o ./cmd/admin-web/admin-web ./cmd/admin-web/admin-web.go + +agent: go build -mod=mod -o ./cmd/agent/agent ./cmd/agent/agent.go + +demo_client: go build -mod=mod -o ./cmd/test-client/demo-client ./cmd/test-client/demo-client.go - + production: @echo "Build for production" # Note - Using cgo write normal Go code that imports a pseudo-package "C". I may not need on cross-compiling. diff --git a/poc-cb-net/README.KR.md b/poc-cb-net/README.KR.md index 068c638..d670e37 100644 --- a/poc-cb-net/README.KR.md +++ b/poc-cb-net/README.KR.md @@ -6,11 +6,7 @@ - [Cloud-Barista Network 개요](#cloud-barista-network-개요) - [Cloud Adaptive Network 소개](#cloud-adaptive-network-소개) - [cb-network 시스템 시작하기](#cb-network-시스템-시작하기) - - [필수 사항(Prerequisites)](#필수-사항prerequisites) - - [소스 코드 기반 cb-network controller 구동](#소스-코드-기반-cb-network-controller-구동) - - [소스 코드 기반 cb-network service 구동](#소스-코드-기반-cb-network-service-구동) - - [소스 코드 기반 admin-web 구동](#소스-코드-기반-admin-web-구동) - - [소스 코드 기반 cb-network agent 구동](#소스-코드-기반-cb-network-agent-구동) + - [실행 방법](#eyes-실행-방법) - [데모: 멀티클라우드에 기존 서비스를 올리기 위한 첫 걸음](#데모-멀티클라우드에-기존-서비스를-올리기-위한-첫-걸음) @@ -59,7 +55,7 @@ CSP의 네트워크로부터 독립적인 클라우드바리스타를 위한 가 ## cb-network 시스템 시작하기 cb-network 시스템을 시작하기 위해 필요한 준비사항 및 각 컴포넌트 실행 방법에 대해 설명한다. -**기본적으로, cb-network 시스템의 모든 컴포넌트는 각각 독립 실행 될 수 있다.** 따라서, 각 구성 요소는 아래에서 독립적으로 설명한다. (주로 구성과 관련된) 동일한 설명이 반복됩니다. +**기본적으로, cb-network 시스템의 모든 컴포넌트는 각각 독립 노드에서 실행 될 수 있다.** 하지만, 복잡한 설명을 줄이기 위해 가급적 묶어서 구동한다.
@@ -79,398 +75,9 @@ cb-network 시스템을 시작하기 위해 필요한 준비사항 및 각 컴 `cb-network agent`는 각각 서로 다른 호스트(VM)에서 구동해야 한다. -### 필수 사항(Prerequisites) -#### 패키지/도구 설치 -```bash -sudo apt update -y -sudo apt install git -y -``` - -#### Golang 설치 -참고: [Go Setup Script](https://github.com/cloud-barista/cb-coffeehouse/tree/master/scripts/golang) -```bash -wget https://raw.githubusercontent.com/cloud-barista/cb-coffeehouse/master/scripts/golang/go-installation.sh -source go-installation.sh '1.17.6' -``` - -#### CB-Larva 저장소 클론 -```bash -git clone https://github.com/cloud-barista/cb-larva.git -``` - -#### Distributed key-value store 배치 -cb-network 시스템은 분산 키-값 저장소를 필요로 합니다. 여기서는 `etcd`를 활용했습니다. -비고 - 테스트를 위해 단일-노드 클러스터를 배치했습니다. -비고 - 실제 서비스를 위해서는 멀티-노드 클러스터를 배치하십시오. - -아래 링크 참고: -- [etcd 3.5 - Run etcd clusters inside containers](https://etcd.io/docs/v3.5/op-guide/container/) -- [etcd 3.5 - Quickstart](https://etcd.io/docs/v3.5/quickstart/) -- [etcd 3.5 - Demo](https://etcd.io/docs/v3.5/demo/) - -##### etcd 다운로드 및 빌드 -```bash -cd ~ -git clone https://github.com/etcd-io/etcd.git -cd etcd -git checkout tags/v3.5.0 -b v3.5.0 -./build.sh -``` - -##### etcd 구동 -외부 접근은 위해서 `--advertise-client-urls` and `--listen-client-urls` 를 설정해야 합니다. - -**아래 [PUBLIC_IP]를 실행환경의 Public IP로 변경하십시오.** -```bash -./bin/etcd --advertise-client-urls http://[PUBLIC_IP]:2379 --listen-client-urls http://0.0.0.0:2379 -``` - ---- - -### 소스 코드 기반 cb-network controller 구동 -아래 과정은 Ubuntu 18.04의 "home" 디렉토리를 기준으로 진행 하였습니다. - -#### cb-network controller 관련 설정파일 준비 -##### config.yaml -- config.yaml 생성(제공된 `template-config.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- 아래 템플릿에서 `etcd_cluster`의 **"xxxx" 부분 수정** -- config.yaml 템플릿: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- log_conf.yaml 생성(제공된 `template-log_conf.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- 필요시 아래 템플릿에서 `cblog` > `loglevel` 수정 -- log_conf.yaml 템플릿: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### cb-network controller 빌드 -빌드 과정에서 필요한 패키지를 자동으로 설치합니다. (go module이 참 편리하네요 ㅎㅎ) -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/controller -go build controller.go -``` - -#### cb-network controller 실행 -```bash -sudo ./controller -``` - ---- - -### 소스 코드 기반 cb-network service 구동 -아래 과정은 Ubuntu 18.04의 "home" 디렉토리를 기준으로 진행 하였습니다. - -#### cb-network service 관련 설정파일 준비 -##### config.yaml -- config.yaml 생성(제공된 `template-config.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- 아래 템플릿에서 `etcd_cluster` 및 `grpc` 의 **"xxxx" 부분 수정** -- config.yaml 템플릿: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- log_conf.yaml 생성(제공된 `template-log_conf.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- 필요시 아래 템플릿에서 `cblog` > `loglevel` 수정 -- log_conf.yaml 템플릿: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### cb-network service 빌드 -빌드 과정에서 필요한 패키지를 자동으로 설치합니다. -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/service -go build service.go -``` - -#### cb-network service 실행 -```bash -sudo ./service -``` - ---- - -### 소스 코드 기반 admin-web 구동 -아래 과정은 Ubuntu 18.04의 "home" 디렉토리를 기준으로 진행 하였습니다. - -#### admin-web 관련 설정파일 준비 -##### config.yaml -- config.yaml 생성(제공된 `template-config.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- 아래 템플릿에서 `etcd_cluster`, `admin_web` 및 `grpc` 의 **"xxxx" 부분 수정** -- config.yaml 템플릿: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- log_conf.yaml 생성(제공된 `template-log_conf.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- 필요시 아래 템플릿에서 `cblog` > `loglevel` 수정 -- log_conf.yaml 템플릿: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### admin-web 빌드 -빌드 과정에서 필요한 패키지를 자동으로 설치합니다. -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/admin-web -go build admin-web.go -``` - -#### admin-web 실행 -```bash -sudo ./admin-web -``` - ---- - -### 소스 코드 기반 cb-network agent 구동 -아래 과정은 Ubuntu 18.04의 "home" 디렉토리를 기준으로 진행 하였습니다. - -#### cb-network agent 관련 설정파일 준비 -##### config.yaml -- config.yaml 생성(제공된 `template-config.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- 아래 템플릿에서 `etcd_cluster` 및 `cb_network`의 **"xxxx" 부분 수정** - - **[필수] `cb_network` > `host_id`을 직접 설정하는 경우, agent마다 다른 `host_id`를 부여해야함** -- config.yaml 템플릿: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- log_conf.yaml 생성(제공된 `template-log_conf.yaml`을 활용) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- 필요시 아래 템플릿에서 `cblog` > `loglevel` 수정 -- log_conf.yaml 템플릿: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### cb-network agent 빌드 -빌드 과정에서 필요한 패키지를 자동으로 설치합니다. - -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/agent -go build agent.go -``` - -#### cb-network agent -```bash -sudo ./agent -``` - +### :eyes: 실행 방법 +- [소스코드 기반 실행](https://github.com/cloud-barista/cb-larva/wiki/Install-based-on-source-code) +- [컨테이너 기반 실행](https://github.com/cloud-barista/cb-larva/wiki/Install-based-on-container) ## 데모: 멀티클라우드에 기존 서비스를 올리기 위한 첫 걸음 @@ -478,7 +85,7 @@ sudo ./agent 비고 - 영상에서 사용한 demo-client를 구동하는 방법은 아래를 참고해 주세요. -[![멀티클라우드에 기존 서비스를 올리기 위한 첫 걸음](https://user-images.githubusercontent.com/7975459/145988454-7e537dcf-b2e2-4560-91ce-eb8455d48772.png)](https://drive.google.com/file/d/1GFuPe-s7IUCbIfLAv-Jkd8JaiQci66nR/view?usp=sharing "Click to watch") +[![멀티클라우드에 기존 서비스를 올리기 위한 첫 걸음](https://user-images.githubusercontent.com/7975459/145988454-7e537dcf-b2e2-4560-91ce-eb8455d48772.png)](https://drive.google.com/file/d/16LK840e8Kh1d116MH_3bWdFXVrfrKnK8/view?usp=sharing "Click to watch") ### 소스 코드 기반 demo-client 구동 아래 과정은 Ubuntu 18.04의 "home" 디렉토리를 기준으로 진행 하였습니다. @@ -497,11 +104,16 @@ sudo ./agent ```yaml # A config for an etcd cluster (required for all cb-netwwork components): etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] + endpoints: [ "localhost:2379" ] # e.g., [ "123.123.123.123:2379", "124.124.124.124:2379", ... ] + + # A config for the cb-network service and cb-network admin-web as follows: + service: + endpoint: "localhost:8053" # e.g., "123.123.123.123:8053" + port: "8053" # A config for the cb-network admin-web as follows: admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" + host: "localhost" # e.g., "123.123.123.123" port: "8054" # A config for the cb-network agent as follows: @@ -513,12 +125,6 @@ sudo ./agent tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". is_encrypted: false # false is default. - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - # A config for the demo-client as follows: service_call_method: "grpc" # i.e., "rest" / "grpc" diff --git a/poc-cb-net/README.md b/poc-cb-net/README.md index 522f3f2..a26653b 100644 --- a/poc-cb-net/README.md +++ b/poc-cb-net/README.md @@ -6,10 +6,7 @@ - [An overview of Cloud-Barista Network](#an-overview-of-cloud-barista-network) - [Introduction to Cloud Adaptive Network](#introduction-to-cloud-adaptive-network) - [Getting started with cb-network system](#getting-started-with-cb-network-system) - - [How to run a cb-network controller based on source code](#how-to-run-a-cb-network-controller-based-on-source-code) - - [How to run a cb-network service based on source code](#how-to-run-a-cb-network-service-based-on-source-code) - - [How to run an admin-web based on source code](#how-to-run-an-admin-web-based-on-source-code) - - [How to run a cb-network agent based on source code](#how-to-run-a-cb-network-agent-based-on-source-code) + - [How to run](#eyes-how-to-run) - [Demo: 1st step, to run existing services in multi-cloud](#demo-1st-step-to-run-existing-services-in-multi-cloud) @@ -58,8 +55,7 @@ Simply, **CLADNet (cb-cladnet)** provides a common network for multiple VMs and ## Getting started with cb-network system This section describes the preparations required to start the cb-network system and how to run each component. -**Basically, all components of cb-network system can be executed independently.** Therefore, each component is independently described below. The same explanation will be repeated (mainly related to the configuration). - +**Basically, all components of cb-network system can be executed independently.** However, we run as many components as possible on the same node for better understanding.
@@ -78,396 +74,9 @@ In this description, `distributed key-value store`, `cb-network controller`, `cb Each `cb-network agent` must be run on a different host (VM). -### Prerequisites -#### Install packages/tools -```bash -sudo apt update -y -sudo apt install git -y -``` - -#### Install Golang -Please refer to [Go Setup Script](https://github.com/cloud-barista/cb-coffeehouse/tree/master/scripts/golang) -```bash -wget https://raw.githubusercontent.com/cloud-barista/cb-coffeehouse/master/scripts/golang/go-installation.sh -source go-installation.sh '1.17.6' -``` - -#### Clone CB-Larva repository -```bash -git clone https://github.com/cloud-barista/cb-larva.git -``` - -#### Deploy the distributed key-value store -The cb-network system requires a distributed key-value store. `etcd` is used. -NOTE - For test, a single-node cluster of etcd is deployed. -NOTE - For production, a multi-node cluster is recommended. - -Please, refer to the official links: -- [etcd 3.5 - Run etcd clusters inside containers](https://etcd.io/docs/v3.5/op-guide/container/) -- [etcd 3.5 - Quickstart](https://etcd.io/docs/v3.5/quickstart/) -- [etcd 3.5 - Demo](https://etcd.io/docs/v3.5/demo/) - -##### Download and build etcd -```bash -cd ~ -git clone https://github.com/etcd-io/etcd.git -cd etcd -git checkout tags/v3.5.0 -b v3.5.0 -./build.sh -``` - -##### Start etcd -For remote access, `--advertise-client-urls` and `--listen-client-urls` must be setup. - -**Please, replace [PUBLIC_IP] with a public IP of your environment.** -```bash -./bin/etcd --advertise-client-urls http://[PUBLIC_IP]:2379 --listen-client-urls http://0.0.0.0:2379 -``` - ---- - -### How to run a cb-network controller based on source code -It was deployed and tested on the "home" directory of Ubuntu 18.04. It's possible to change project root path. - -#### Prepare the config for cb-network controller -##### config.yaml -- Create `config.yaml` (Use the provided `template-config.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- **Edit the "xxxx" part** of `etcd_cluster` in the text below -- The config.yaml template: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- Create `config.yaml` (Use the provided `template-log_conf.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- Edit `cblog` > `loglevel` if necessary -- The log_conf.yaml template: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### Build cb-network controller -In the building process, the required packages are automatically installed based on the "go module". (Go module is very useful, isn't it?) -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/controller -go build controller.go -``` - -#### Run cb-network controller -```bash -sudo ./controller -``` - ---- - -### How to run a cb-network service based on source code -It was deployed and tested on the "home" directory of Ubuntu 18.04. It's possible to change project root path. - -#### Prepare the config for the cb-network service -##### config.yaml -- Create `config.yaml` (Use the provided `template-config.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- **Edit the "xxxx" part** of `etcd_cluster` and `grpc` in the text below -- The config.yaml template: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- Create `config.yaml` (Use the provided `template-log_conf.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- Edit `cblog` > `loglevel` if necessary -- The log_conf.yaml template: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### Build the cb-network service -In the building process, the required packages are automatically installed based on the "go module". -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/service -go build service.go -``` - -#### Run the cb-network service -```bash -sudo ./service -``` - ---- - -### How to run an admin-web based on source code -It was deployed and tested on the "home" directory of Ubuntu 18.04. It's possible to change project root path. - -#### Prepare the config for the admin-web -##### config.yaml -- Create `config.yaml` (Use the provided `template-config.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- **Edit the "xxxx" part** of `etcd_cluster`, `admin_web`, and `grpc` in the text below -- The config.yaml template: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- Create `config.yaml` (Use the provided `template-log_conf.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- Edit `cblog` > `loglevel` if necessary -- The log_conf.yaml template: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### Build the admin-web -In the building process, the required packages are automatically installed based on the "go module". -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/admin-web -go build admin-web.go -``` - -#### Run the admin-web -```bash -sudo ./admin-web -``` - ---- - -### How to run a cb-network agent based on source code -It was deployed and tested on the "home" directory of Ubuntu 18.04. It's possible to change project root path. - -#### Prepare the config for cb-network agent -##### config.yaml -- Create `config.yaml` (Use the provided `template-config.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-config.yaml config.yaml - ``` -- **Edit the "xxxx" part** of `etcd_cluster` and `cb_network` in the text below -- The config.yaml template: - ```yaml - # A config for an etcd cluster (required for all cb-netwwork components): - etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] - - # A config for the cb-network admin-web as follows: - admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" - port: "8054" - - # A config for the cb-network agent as follows: - cb_network: - cladnet_id: "xxxx" - host: # for each host - name: "" # if name is "" (empty string), the cb-network agent will use hostname. - network_interface_name: "" # if network_interface_name is "" (empty string), the cb-network agent will use "cbnet0". - tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". - is_encrypted: false # false is default. - - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: - service_call_method: "grpc" # i.e., "rest" / "grpc" - - ``` - -##### log_conf.yaml -- Create `config.yaml` (Use the provided `template-log_conf.yaml`) - ```bash - cd ${HOME}/cb-larva/poc-cb-net/config - cp template-log_conf.yaml log_conf.yaml - ``` -- Edit `cblog` > `loglevel` if necessary -- The log_conf.yaml template: - ```yaml - #### Config for CB-Log Lib. #### - - cblog: - ## true | false - loopcheck: true # This temp method for development is busy wait. cf) cblogger.go:levelSetupLoop(). - - ## debug | info | warn | error - loglevel: debug # If loopcheck is true, You can set this online. - - ## true | false - logfile: false - - ## Config for File Output ## - logfileinfo: - filename: ./log/cblogs.log - # filename: $CBLOG_ROOT/log/cblogs.log - maxsize: 10 # megabytes - maxbackups: 50 - maxage: 31 # days - ``` - -#### Build cb-network agent -In the building process, the required packages are automatically installed based on the "go module". -```bash -cd ${HOME}/cb-larva/poc-cb-net/cmd/agent -go build agent.go -``` - -#### Run cb-network agent -```bash -sudo ./agent -``` - +### :eyes: How to run +- [Install based on source code](https://github.com/cloud-barista/cb-larva/wiki/Install-based-on-source-code) +- [Install based on container](https://github.com/cloud-barista/cb-larva/wiki/Install-based-on-container) ## Demo: 1st step, to run existing services in multi-cloud @@ -475,7 +84,7 @@ Please refer to the video for more details :-) NOTE - Please refer to the below for how to run the demo-client used in the video. -[![1st step to run existing services in multi-cloud](https://user-images.githubusercontent.com/7975459/145988454-7e537dcf-b2e2-4560-91ce-eb8455d48772.png)](https://drive.google.com/file/d/1GFuPe-s7IUCbIfLAv-Jkd8JaiQci66nR/view?usp=sharing "Click to watch") +[![1st step to run existing services in multi-cloud](https://user-images.githubusercontent.com/7975459/145988454-7e537dcf-b2e2-4560-91ce-eb8455d48772.png)](https://drive.google.com/file/d/16LK840e8Kh1d116MH_3bWdFXVrfrKnK8/view?usp=sharing "Click to watch") ### How to run a demo-client based on source code It was deployed and tested on the "home" directory of Ubuntu 18.04. It's possible to change project root path. @@ -496,11 +105,16 @@ If it is running on another node, it is required to modify source code (related ```yaml # A config for an etcd cluster (required for all cb-netwwork components): etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] + endpoints: [ "localhost:2379" ] # e.g., [ "123.123.123.123:2379", "124.124.124.124:2379", ... ] + + # A config for the cb-network service and cb-network admin-web as follows: + service: + endpoint: "localhost:8053" # e.g., "123.123.123.123:8053" + port: "8053" # A config for the cb-network admin-web as follows: admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" + host: "localhost" # e.g., "123.123.123.123" port: "8054" # A config for the cb-network agent as follows: @@ -512,13 +126,7 @@ If it is running on another node, it is required to modify source code (related tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". is_encrypted: false # false is default. - # A config for the grpc as follows: - grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - - # A config for the demo-client as follows: + # A config for the demo-client as follows: service_call_method: "grpc" # i.e., "rest" / "grpc" ``` diff --git a/poc-cb-net/cmd/admin-web/admin-web.go b/poc-cb-net/cmd/admin-web/admin-web.go index efbe052..8a1e3a3 100644 --- a/poc-cb-net/cmd/admin-web/admin-web.go +++ b/poc-cb-net/cmd/admin-web/admin-web.go @@ -590,7 +590,7 @@ func main() { grpc.WithTransportCredentials(insecure.NewCredentials()), } - grpcConn, err := grpc.Dial(config.GRPC.ServiceEndpoint, options...) + grpcConn, err := grpc.Dial(config.Service.Endpoint, options...) if err != nil { log.Fatalf("Cannot connect to gRPC Server: %v", err) } diff --git a/poc-cb-net/cmd/service/service.go b/poc-cb-net/cmd/service/service.go index f92b580..02e4e5a 100644 --- a/poc-cb-net/cmd/service/service.go +++ b/poc-cb-net/cmd/service/service.go @@ -466,7 +466,7 @@ func main() { grpc.WithTransportCredentials(insecure.NewCredentials()), } - addr := fmt.Sprintf(":%s", config.GRPC.ServerPort) + addr := fmt.Sprintf(":%s", config.Service.Port) err = pb.RegisterSystemManagementServiceHandlerFromEndpoint(context.Background(), gwmux, addr, options) if err != nil { CBLogger.Fatalf("Failed to register gateway: %v", err) @@ -481,7 +481,7 @@ func main() { mux.Handle("/", gwmux) // Display API documents (gRPC protocol documentation, REST API documentation by Swagger) - swaggerURL := fmt.Sprintf("http://%s/swagger/index.html", config.GRPC.ServiceEndpoint) + swaggerURL := fmt.Sprintf("http://%s/swagger/index.html", config.Service.Endpoint) grpcDocURL := "https://github.com/cloud-barista/cb-larva/blob/main/poc-cb-net/docs/cloud-adaptive-network-service.md" CBLogger.Infof("Serving gRPC-Gateway(gRPC, REST), Swagger dashboard on %v", addr) diff --git a/poc-cb-net/cmd/test-client/config/template-config.yaml b/poc-cb-net/cmd/test-client/config/template-config.yaml index 53f3fad..ab69526 100644 --- a/poc-cb-net/cmd/test-client/config/template-config.yaml +++ b/poc-cb-net/cmd/test-client/config/template-config.yaml @@ -1,6 +1,11 @@ # A config for an etcd cluster (required for all cb-netwwork components): etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx", "xxx.xxx.xxx.xxx:xxx" ] + endpoints: [ "localhost:2379" ] # e.g., [ "123.123.123.123:2379", "124.124.124.124:2379", ... ] + +# A config for the cb-network service and cb-network admin-web as follows: +service: + endpoint: "localhost:8053" # e.g., "123.123.123.123:8053" + port: "8053" # A config for the cb-network admin-web as follows: admin_web: @@ -16,11 +21,5 @@ cb_network: tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". is_encrypted: false # false is default. -# A config for the grpc as follows: -grpc: - service_endpoint: "localhost:8053" - server_port: "8053" - gateway_port: "8052" - # A config for the demo-client as follows: service_call_method: "grpc" # i.e., "rest" / "grpc" diff --git a/poc-cb-net/config/template-config.yaml b/poc-cb-net/config/template-config.yaml index c2de9d4..f241ed5 100644 --- a/poc-cb-net/config/template-config.yaml +++ b/poc-cb-net/config/template-config.yaml @@ -1,10 +1,15 @@ # A config for an etcd cluster (required for all cb-netwwork components): etcd_cluster: - endpoints: [ "xxx.xxx.xxx.xxx:2379", "xxx.xxx.xxx.xxx:2379", "xxx.xxx.xxx.xxx:2379" ] # e.g., "123.123.123.123:2379" + endpoints: [ "localhost:2379" ] # e.g., [ "123.123.123.123:2379", "124.124.124.124:2379", ... ] + +# A config for the cb-network service and cb-network admin-web as follows: +service: + endpoint: "localhost:8053" # e.g., "123.123.123.123:8053" + port: "8053" # A config for the cb-network admin-web as follows: admin_web: - host: "xxx.xxx.xxx.xxx" # e.g., "localhost" + host: "localhost" # e.g., "123.123.123.123" port: "8054" # A config for the cb-network agent as follows: @@ -16,11 +21,5 @@ cb_network: tunneling_port: "" # if network_interface_port is "" (empty string), the cb-network agent will use "8055". is_encrypted: false # false is default. -# A config for the grpc as follows: -grpc: - service_endpoint: "xxx.xxx.xxx.xxx:8053" # e.g., "localhost:8053" - server_port: "8053" - gateway_port: "8052" - # A config for the demo-client as follows: service_call_method: "grpc" # i.e., "rest" / "grpc" diff --git a/poc-cb-net/pkg/cb-network/model/config.go b/poc-cb-net/pkg/cb-network/model/config.go index c6061f2..a03a2d3 100644 --- a/poc-cb-net/pkg/cb-network/model/config.go +++ b/poc-cb-net/pkg/cb-network/model/config.go @@ -14,6 +14,14 @@ type ETCDConfig struct { Endpoints []string `yaml:"endpoints"` } +// A config for the cb-network service and cb-network admin-web as follows: + +// ServiceConfig represnets the configuration information for a gRPC server +type ServiceConfig struct { + Endpoint string `yaml:"endpoint"` + Port string `yaml:"port"` +} + // A config for the cb-network controller as follows: // AdminWebConfig represents the configuration information for a AdminWeb @@ -38,21 +46,12 @@ type HostConfig struct { IsEncrypted bool `yaml:"is_encrypted"` } -// A config for the grpc as follows: - -// GRPCConfig represnets the configuration information for a gRPC server -type GRPCConfig struct { - ServiceEndpoint string `yaml:"service_endpoint"` - ServerPort string `yaml:"server_port"` - GatewayPort string `yaml:"gateway_port"` -} - // Config represents the configuration information for cb-network type Config struct { ETCD ETCDConfig `yaml:"etcd_cluster"` AdminWeb AdminWebConfig `yaml:"admin_web"` CBNetwork CBNetworkConfig `yaml:"cb_network"` - GRPC GRPCConfig `yaml:"grpc"` + Service ServiceConfig `yaml:"service"` ServiceCallMethod string `yaml:"service_call_method"` } diff --git a/poc-cb-net/scripts/1.deploy-cb-network-agent.sh b/poc-cb-net/scripts/1.deploy-cb-network-agent.sh index 981e453..dd70c64 100644 --- a/poc-cb-net/scripts/1.deploy-cb-network-agent.sh +++ b/poc-cb-net/scripts/1.deploy-cb-network-agent.sh @@ -53,6 +53,11 @@ cat <