Skip to content

Commit

Permalink
release: Static image builder scripts (#10)
Browse files Browse the repository at this point in the history
* Script added to build Static binaries
* Build time is very slow for release builds
* Install and usage instructions updated to README.

Signed-off-by: Aravinda Vishwanathapura <[email protected]>
  • Loading branch information
aravindavk authored Dec 28, 2020
1 parent 2aa801d commit a451cbc
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 7 deletions.
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
help:
@echo "Show this Help Message"

deps:
cd server && shards install
cd node && shards install
cd cli && shards install

build:
cd server && VERSION=${VERSION} shards build
cd node && VERSION=${VERSION} shards build
cd cli && VERSION=${VERSION} shards build

prod-build:
cd moana-server && shards install --production && shards build --release --static
cd moana-node && shards install --production && shards build --release --static
cd cli && shards install --production && shards build --release --static
cd server && time -v shards install --production && VERSION=${VERSION} time -v shards build --static --release --stats --time
cd node && time -v shards install --production && VERSION=${VERSION} time -v shards build --static --release --stats --time
cd cli && time -v shards install --production && VERSION=${VERSION} time -v shards build --static --release --stats --time

build-arm64:
time ./build_arm64_static.sh

build-amd64:
time ./build_amd64_static.sh
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Moana

## Install (Server, Node agent and CLI)

Download the latest release with the command

```
curl -L https://github.com/kadalu/moana/releases/download/0.1.0/moana-server-`uname -m | sed 's|aarch64|arm64|' | sed 's|x86_64|amd64|'` -o moana-server
curl -L https://github.com/kadalu/moana/releases/download/0.1.0/moana-node-`uname -m | sed 's|aarch64|arm64|' | sed 's|x86_64|amd64|'` -o moana-node
curl -L https://github.com/kadalu/moana/releases/download/0.1.0/moana-`uname -m | sed 's|aarch64|arm64|' | sed 's|x86_64|amd64|'` -o moana
```

Make the `moana-server`, `moana-node` and `moana` as binary executable.

```
chmod +x ./moana-server
chmod +x ./moana-node
chmod +x ./moana
```

Move the binaries into your PATH.

```
sudo mv ./moana-server ./moana-node ./moana /usr/local/bin/
```

## Usage:

Start the Moana Server(in any one server or cloud)

```
$ moana-server
```

Start the Moana node agent in all Storage nodes.

```
$ # Create Required directories in the node
$ mkdir /var/lib/moana \
/var/run/moana \
/var/lib/moana/volfiles \
/var/log/moana
$ # Copy Systemd unit template file
$ cp extra/[email protected] /lib/systemd/system/
$ # Copy glusterfsd wrapper script
$ cp extra/kadalu-brick /usr/sbin/
$ # Start the Node agent
$ sudo moana-node
```

Run CLI from any node.

```
$ export MOANA_URL=http://moana-server-url:3000
$ moana cluster list
```

## Create and view the Cluster

```
$ moana cluster create mycluster
Cluster created successfully.
ID: 230da85c-82fd-43a1-a517-fd6d67bce827
Saved as default Cluster
$ moana cluster list
ID Name
*230da85c-82fd-43a1-a517-fd6d67bce827 mycluster
```

## Request a node to join the Cluster

```
$ # moana node join <endpoint>
$ moana node join http://node1.example.com:3001
Node joined successfully.
ID: 894de25c-70b2-48c5-8c18-188440d3953a
$ moana node list
ID Name Endpoint
894de25c-70b2-48c5-8c18-188440d3953a node1.example.com http://node1.example.com:3001
```

**Note**: The endpoint should be reachable from CLI and also for other nodes of the Cluster.

## Create a Volume

```
$ mkdir /bricks
$ moana volume create gvol1 node1.example.com:/bricks/b1
Volume creation request sent successfully.
Task ID: 0f8ea18a-bbd2-403a-b752-ea3fce74e8c6
```

Volume create request will be handled by Moana Task framework, respective node agent will pick up the Volume create task and internally sends Volume create request to all participating nodes. Node agent will also update the Task status to Moana Server. States of each task are:

* Queued - When assigned to a node, but Task is not yet picked up.
* Received - Task is received by the Node and execution is pending
* Completed/Failed - Task is complete or failed.

Check the state of the task using,

```
$ moana task list
Task ID State Assigned To Type
0f8ea18a-bbd2-403a-b752-ea3fce74e8c6 Completed 894de25c-70b2-48c5-8c18-188440d3953a volume_create
```

Once the task is complete, Volume list will show the Volume details

```
$ moana volume list
ID Name Type State
97a7546b-5ab5-45b0-9861-acd9b6097519 gvol1 Distribute Created
```
20 changes: 20 additions & 0 deletions build_amd64_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
VERSION=${VERSION-devel}
CMDS="
apk add --update --no-cache --force-overwrite \
sqlite-dev sqlite-static
cd server
time -v shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
mv bin/moana-server bin/moana-server-amd64
cd ../node
time -v shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
mv bin/moana-node bin/moana-node-amd64
cd ../cli
time -v shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
mv bin/moana bin/moana-amd64
"

docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:0.35.1-alpine /bin/sh -c "$CMDS"
38 changes: 38 additions & 0 deletions build_arm64_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh -eu

# Based on https://gist.github.com/j8r/34f1a344336901960c787517b5b6d616

LOCAL_PROJECT_PATH=${1-$PWD}
VERSION=${VERSION-devel}
CMDS="
echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >>/etc/apk/repositories
apk add --update --no-cache --force-overwrite \
crystal@edge \
gc-dev gcc gmp-dev libatomic_ops libevent-static musl-dev pcre-dev \
libxml2-dev openssl-dev openssl-libs-static tzdata yaml-dev zlib-static \
make git \
llvm10-dev llvm10-static g++ \
shards@edge \
yaml-static \
sqlite-dev sqlite-static
cd server
shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
chown 1000:1000 -R bin
mv bin/moana-server bin/moana-server-arm64
cd ../node
shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
chown 1000:1000 -R bin
mv bin/moana-node bin/moana-node-arm64
cd ../cli
shards install --production
VERSION=${VERSION} time -v shards build --static --release --stats --time
chown 1000:1000 -R bin
mv bin/moana bin/moana-arm64
"

# Compile Crystal project statically for arm64 (aarch64)
docker pull multiarch/qemu-user-static:register
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -it -v $LOCAL_PROJECT_PATH:/workspace -w /workspace --rm multiarch/alpine:aarch64-latest-stable /bin/sh -c "$CMDS"
4 changes: 0 additions & 4 deletions build_linux64_static.sh

This file was deleted.

0 comments on commit a451cbc

Please sign in to comment.