Skip to content
This repository has been archived by the owner on Nov 28, 2021. It is now read-only.

Commit

Permalink
update develop docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ludanfeng committed Jul 22, 2020
1 parent ffd91c8 commit a3f0e06
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 197 deletions.
53 changes: 53 additions & 0 deletions docs/develop/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Install from source

quick installation of baetyl-cloud, you can build baetyl-cloud from source to get the latest features.

## Prerequisites

- The Go tools and modules

The minimum required go version is 1.13. Refer to [golang.org](https://golang.org/dl/) or [golang.google.cn](https://golang.google.cn/dl/) to download and install the Go tools. Now we use Go Modules to manage packages,you can refer [goproxy.baidu.com](https://goproxy.baidu.com/) to set GOPROXY if needs.

- The Docker Engine and Buildx

The minimum required Docker version is 19.03, because the Docker Buildx feature is introduced to build multi-platform images. Refer to [docker.com/install](https://docs.docker.com/install/)to install the Docker Engine and refer to [github.com/docker/buildx](https://github.com/docker/buildx) to enable the Docker Buildx.


## Download source code

Download the code from [Baetyl Github](https://github.com/baetyl/baetyl-cloud) and execute the following command:

```shell
git clone https://github.com/baetyl/baetyl-cloud.git
```

## Build baetyl-cloud

Go into the baetyl-cloud project directory and execute `make` to build the baetyl-cloud main program.

```shell
make
```

After the make command is completed, the baetyl-cloud main program will be generated in the project's `output` directory.

## Make image

If you use container mode to run baetyl-cloud, we recommend using officially released official images. If you want to make your own image, you can use the commands provided below, but only if the Buildx function mentioned in the first preparation is turned on.

Go into the baetyl-cloud project directory and execute `make image` to generate baetyl-cloud image.

```shell
make image
```

After the command is completed, you can execute `docker images` to view the generated image.

```shell
docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
cloud git-be2c5a9 d70a7faf5443 About an hour ago 40.7MB
```

Modify the image configuration in scripts/demo/charts/baetyl-cloud/values.yaml, and use helm install command to deploy baetyl-cloud.
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
# Baetyl-cloud Configuration Interpretation
# Configuration Interpretation

## baetyl-cloud configuration

The default configuration file is `etc/baetyl/service.yml` in the working directory, and the configuration definition is as follows:

```yaml
activeServer:
port: #The server port for device activate
ca: #The server root ca certificate file
cert: #The server certificate file
key: #The Server certificate's key file
adminServer:
port: #The management server port

nodeServer:
port: #The server port for Edge-Cloud synchronization
port: #The server port for edge-cloud synchronization
ca: #The server root ca certificate file
cert: #The server certificate file
key: #The Server certificate's key file

activeServer:
port: #The server port for device activate
ca: #The server root ca certificate file
cert: #The server certificate file
key: #The Server certificate's key file

plugin: #In baetyl-cloud design, auth, lincese, pki, shadow, and model storage are implemented in the form of plug-ins, supporting customization
auth: #Authentication plugin, default: defaultauth
license: #license plugin, defaultlicense is used by default
pki: #Certificate management plugin, default: defaultpki
shadow: #Shadow storage plugin, support database and kubernetes
modelStorage: # baetyl-cloud's CRD storage plugin, default: kubernetes
databaseStorage: #Database configuration, default: database
auth: #Authentication plugin, defaultauth is used by default, no authentication
license: #license plugin, defaultlicense is used by default, no license check.
pki: #Certificate management plugin, defaultpki is used by default, self-signed certificate.
shadow: #Shadow storage plugin, database is used by default.
modelStorage: #CRD storage plugin, kubernetes is used by default.
databaseStorage: #Database configuration, database is used by default.

logger:
filename: #Log file
Expand Down
94 changes: 94 additions & 0 deletions docs/develop/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Installation

Please download the baetyl-cloud project before installation. We take the scripts/demo in the project as an example to demonstrate the steps. The cloud management suite and the edge computing framework are all installed on the same machine.

```shell
git clone https://github.com/baetyl/baetyl-cloud.git
```

## Install database

Before installing baetyl-cloud, we need to install the database first, and execute the following command to install it.

```shell
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install mariadb --set rootUser.password=secretpassword,db.name=baetyl_cloud bitnami/mariadb
helm install phpmyadmin bitnami/phpmyadmin
```
**Note**: For the convenience of demonstration, we have hardcoded the password, please modify it yourself, and you can replace secretpassword globally.

## Initialize data

Confirm that mariadb and phpmyadmin are in the Running state.

```shell
kubectl get pod
# NAME READY STATUS RESTARTS AGE
# mariadb-master-0 1/1 Running 0 2m56s
# mariadb-slave-0 1/1 Running 0 2m56s
# phpmyadmin-55f4f964d7-ctmxj 1/1 Running 0 117s
```

Then execute the following command to keep the terminal from exiting.

```shell
export POD_NAME=$(kubectl get pods --namespace default -l "app=phpmyadmin,release=phpmyadmin" -o jsonpath="{.items[0].metadata.name}")
echo "phpMyAdmin URL: http://127.0.0.1:8080"
kubectl port-forward --namespace default svc/phpmyadmin 8080:80
```

Then use a browser to open http://127.0.0.1:8080/index.php, Server input: mariadb, Username input: root, Password input: secretpassword. After logging in, select the database baetyl_cloud, click the SQL button, and enter the sql statements of all files in the scripts/sql directory under the baetyl-cloud project into the page for execution. If no error is reported during execution, the data initialization is successful.

## Install baetyl-cloud

Enter the directory where the baetyl-cloud project is located and execute the following commands.

```shell
# helm 3
helm install baetyl-cloud ./scripts/demo/charts/baetyl-cloud/
```
Make sure that baetyl-cloud is in the Running state, and you can also check the log for errors.

```shell
kubectl get pod
# NAME READY STATUS RESTARTS AGE
# baetyl-cloud-57cd9597bd-z62kb 1/1 Running 0 97s

kubectl logs -f baetyl-cloud-57cd9597bd-z62kb
```

## Create and install edge node

Call the RESTful API to create a node.

```shell
curl -d "{\"name\":\"demo-node\"}" -H "Content-Type: application/json" -X POST http://0.0.0.0:30004/v1/nodes
# {"namespace":"baetyl-cloud","name":"demo-node","version":"1931564","createTime":"2020-07-22T06:25:05Z","labels":{"baetyl-node-name":"demo-node"},"ready":false}
```

Obtain the online installation script of the edge node.

```shell
curl http://0.0.0.0:30004/v1/nodes/demo-node/init
# {"cmd":"curl -skfL 'https://0.0.0.0:30003/v1/active/setup.sh?token=f6d21baa9b7b2265223a333630302c226b223a226e6f6465222c226e223a2264656d6f2d6e6f6465222c226e73223a2262616574796c2d636c6f7564222c227473223a313539353430323132367d' -osetup.sh && sh setup.sh"}
```

Execute the installation script on the machine where baetyl-cloud is deployed.

```shell
curl -skfL 'https://0.0.0.0:30003/v1/active/setup.sh?token=f6d21baa9b7b2265223a333630302c226b223a226e6f6465222c226e223a2264656d6f2d6e6f6465222c226e73223a2262616574796c2d636c6f7564222c227473223a313539353430323132367d' -osetup.sh && sh setup.sh
```

**Note**: If you need to install an edge node on a device other than the machine where baetyl-cloud is deployed, please modify the database, change the node-address and active-address in the baetyl_system_config table to real addresses.

Check the status of the edge node. Eventually, two edge services will be in the Running state. You can also call the cloud RESTful API to view the edge node status. You can see that the edge node is online ("ready":true).

```shell
kubectl get pod -A
# NAMESPACE NAME READY STATUS RESTARTS AGE
# baetyl-edge-system baetyl-core-8668765797-4kt7r 1/1 Running 0 2m15s
# baetyl-edge-system baetyl-function-5c5748957-nhn88 1/1 Running 0 114s

curl http://0.0.0.0:30004/v1/nodes/demo-node
# {"namespace":"baetyl-cloud","name":"demo-node","version":"1939112",...,"report":{"time":"2020-07-22T07:25:27.495362661Z","sysapps":...,"node":...,"nodestats":...,"ready":true}
```
182 changes: 0 additions & 182 deletions docs/develop/quick-install-baetyl-cloud.md

This file was deleted.

5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ Baetyl, extend cloud computing, data and service seamlessly to edge devices.
:maxdepth: 1
:caption: Develop Guides

develop/quick-install-baetyl-cloud.md
develop/baetyl-cloud-config-interpretation.md
develop/install.md
develop/conf.md
develop/api.md
develop/build.md

.. toctree::
:maxdepth: 1
Expand Down

0 comments on commit a3f0e06

Please sign in to comment.