Skip to content

Commit

Permalink
stellar#4493: doc the image builds, and other pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Aug 8, 2022
1 parent d2090df commit 06030fe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
24 changes: 24 additions & 0 deletions exp/lighthorizon/build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Light Horizon services deployment

Light Horizon is composed of a few micro services:
* index-batch - contains map and reduce binaries to parallize tx-meta reads and index writes.
* index-single - contains single binary that reads tx-meta and writes indexes.
* ledgerexporter - contains single binary that reads from captive core and writes tx-meta
* web - contains single binary that runs web api which reads from tx-meta and index.

See [godoc](https://godoc.org/github.com/stellar/go/exp/lighthorizon) for details on each service.

## Buiding docker images of each service
Each service is packaged into a Docker image, use the helper script included here to build:
`./build.sh <service_name> <dockerhub_registry_name> <tag_name> <push_to_repo[true|false]>`

example to build just the mydockerhubname/lighthorizon-index-single:latest image to docker local images, no push to registry:
`./build.sh index-single mydockerhubname latest false`

example to build images for all the services and push them to mydockerhubname/lighthorizon-<servicename>:testversion:
`./build.sh all mydockerhubname testversion true`

## Deploy service images on kubernetes(k8s)
* `k8s/ledgerexporter.yml` - creates a deployment with ledgerexporter image and supporting resources, such as configmap, secret, pvc for captive core on-disk storage. Review the settings to confirm they work in your environment before deployment.
* `k8s/lighthorizon_index.yml` - creates a deployment with index-single image and supporting resources, such as configmap, secret. Review the settings to confirm they work in your environment before deployment.
* `k8s/lighthorizon_web.yml` - creates a deployment with the web image and supporting resources, such as configmap, ingress rule. Review the settings to confirm they work in your environment before deployment.
32 changes: 18 additions & 14 deletions exp/lighthorizon/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,50 @@ cd "$DIR/../../.."
# module name is the sub-folder name under ./build
MODULE=$1
DOCKER_REPO_PREFIX=$2
DOCKER_PUSH=$3
DOCKER_TAG=$3
DOCKER_PUSH=$4

if [ ! -z "$DOCKER_REPO_PREFIX" ]; then
DOCKER_REPO_PREFIX="$DOCKER_REPO_PREFIX/"
if [ -z "$MODULE" ] ||\
[ -z "$DOCKER_REPO_PREFIX" ] ||\
[ -z "$DOCKER_TAG" ] ||\
[ -z "$DOCKER_PUSH" ]; then
echo "invalid parameters, requires './build.sh <service_name> <tag_name> <dockerhub_registry_name> <push_to_repo[true|false]>'"
exit 1
fi

build_target () {
DOCKER_TAG="$DOCKER_REPO_PREFIX"lighthorizon-"$MODULE_NAME"
docker build --tag $DOCKER_TAG --platform linux/amd64 -f "exp/lighthorizon/build/$MODULE_NAME/Dockerfile" .
DOCKER_LABEL="$DOCKER_REPO_PREFIX"/lighthorizon-"$MODULE":"$DOCKER_TAG"
docker build --tag $DOCKER_LABEL --platform linux/amd64 -f "exp/lighthorizon/build/$MODULE/Dockerfile" .
if [ "$DOCKER_PUSH" == "true" ]; then
docker push $DOCKER_TAG
docker push $DOCKER_LABEL
fi
}

MODULE_NAME=$MODULE
case $MODULE in
index_batch)
index-batch)
build_target
;;
ledgerexporter)
build_target
;;
index_single)
index-single)
build_target
;;
web)
build_target
;;
all)
MODULE_NAME=index-batch
MODULE=index-batch
build_target
MODULE_NAME=web
MODULE=web
build_target
MODULE_NAME=index-single
MODULE=index-single
build_target
MODULE_NAME=ledgerexporter
MODULE=ledgerexporter
build_target
;;
*)
echo -n "unknown MODULE build parameter, must be one of all|index_batch|web|index_single|ledgerexporter"
echo "unknown MODULE build parameter ('$MODULE'), must be one of all|index-batch|web|index-single|ledgerexporter"
exit 1
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion exp/lighthorizon/build/index-batch/start
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ elif [ "$RUN_MODE" == "map" ]; then
echo "Running Map, TARGET INDEX: $INDEX_TARGET FIRST CHECKPOINT: $FIRST_CHECKPOINT"
/map
else
echo "error: undefined RUN_MODE env variable, must be map or reduce"
echo "error: undefined RUN_MODE env variable ('$RUN_MODE'), must be 'map' or 'reduce'"
exit 1
fi
2 changes: 1 addition & 1 deletion exp/lighthorizon/build/k8s/lighthorizon_index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
START: "41809728"
END: "0"
WATCH: "true"
MODULES: "transactions,accounts"
MODULES: "accounts"
WORKERS: "3"
---
apiVersion: v1
Expand Down
1 change: 1 addition & 0 deletions exp/lighthorizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if left empty, uses a temporary directory`)
L := log.WithField("service", "horizon-lite")
logLevel, err := logrus.ParseLevel(*logLevelParam)
if err != nil {
log.Warnf("Failed to parse -log-level '%s', defaulting to 'info'.", *logLevelParam)
logLevel = log.InfoLevel
}

Expand Down

0 comments on commit 06030fe

Please sign in to comment.