From a451cbcfaeb3b3851aa7bc57a5c304ee5d499b7f Mon Sep 17 00:00:00 2001 From: Aravinda Vishwanathapura Date: Mon, 28 Dec 2020 15:44:38 +0530 Subject: [PATCH] release: Static image builder scripts (#10) * 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 --- Makefile | 22 ++++++-- README.md | 116 ++++++++++++++++++++++++++++++++++++++++ build_amd64_static.sh | 20 +++++++ build_arm64_static.sh | 38 +++++++++++++ build_linux64_static.sh | 4 -- 5 files changed, 193 insertions(+), 7 deletions(-) create mode 100755 build_amd64_static.sh create mode 100755 build_arm64_static.sh delete mode 100755 build_linux64_static.sh diff --git a/Makefile b/Makefile index f7dd7f7..a68daa2 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index e69de29..34a46fc 100644 --- a/README.md +++ b/README.md @@ -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/kadalu-brick@.service /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 +$ 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 +``` diff --git a/build_amd64_static.sh b/build_amd64_static.sh new file mode 100755 index 0000000..ea4f1b6 --- /dev/null +++ b/build_amd64_static.sh @@ -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" diff --git a/build_arm64_static.sh b/build_arm64_static.sh new file mode 100755 index 0000000..d736df7 --- /dev/null +++ b/build_arm64_static.sh @@ -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" diff --git a/build_linux64_static.sh b/build_linux64_static.sh deleted file mode 100755 index e6404c9..0000000 --- a/build_linux64_static.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -time docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:0.35.1-alpine /bin/sh -c 'cd cli && shards install --production && shards build --release --static' -time docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:0.35.1-alpine /bin/sh -c 'cd moana-server && shards install --production && shards build --release --static' -time docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:0.35.1-alpine /bin/sh -c 'cd moana-node && shards install --production && shards build --release --static'