Skip to content

Commit

Permalink
feat: kube deployment per module
Browse files Browse the repository at this point in the history
This changes the way runners are provisioned, and how runners are allocated. Runners are
now spawned knowing exactly which kube deployment they are for, and will always
immedatly download and run that deployment.

For kubernetes environments replicas are controlled by creating a kube deployment
for each FTL deployment, and adjusting the number of replicas.

For local scaling we create the runners directly for deployments as required.

This also introduces an initial kubernetes test.

fixes: #2449 #2276
  • Loading branch information
stuartwdouglas committed Sep 4, 2024
1 parent efc799d commit 87936e0
Show file tree
Hide file tree
Showing 113 changed files with 1,867 additions and 2,567 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ junit*.xml
/readme-tests
/docs/public
.ftl.lock
docker-build/
4 changes: 0 additions & 4 deletions Dockerfile.box
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ RUN go mod download -x

COPY . /src/

# Build runner template
RUN just build-kt-runtime

# Build runner
RUN just errtrace
# Reset timestamps so that the build state is reset
Expand All @@ -37,7 +34,6 @@ WORKDIR /root/

ENV PATH="/root/jre/bin:$PATH"
COPY --from=builder /hermit/pkg/openjre-18.0.2.1_1/ ./jre/
COPY --from=builder /src/build/template template
COPY --from=builder /src/build/release/ftl .
RUN mkdir deployments
# Where the module artifacts are stored
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile.runner
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ RUN go mod download -x

COPY . /src/

# Build runner template
RUN just build-kt-runtime

# Build runner
RUN just errtrace
# Reset timestamps so that the build state is reset
Expand All @@ -41,7 +38,6 @@ WORKDIR /root/

ENV PATH="/root/jre/bin:$PATH"
COPY --from=builder /hermit/pkg/openjre-18.0.2.1_1/ ./jre/
COPY --from=builder /src/build/template template
COPY --from=builder /src/build/release/ftl-runner .
COPY --from=builder /src/build/release/ftl .
RUN mkdir deployments
Expand All @@ -52,4 +48,4 @@ ENV FTL_ENDPOINT="http://host.docker.internal:8892"
ENV FTL_RUNNER_BIND="http://0.0.0.0:8893"
ENV FTL_RUNNER_ADVERTISE="http://127.0.0.1:8893"

CMD ["/root/ftl-runner", "--language=kotlin", "--language=go", "--template-dir=template", "--deployment-dir=deployments"]
CMD ["/root/ftl-runner", "--template-dir=template", "--deployment-dir=deployments"]
9 changes: 1 addition & 8 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set shell := ["bash", "-c"]
WATCHEXEC_ARGS := "-d 1s -e proto -e go -e sql -f sqlc.yaml"
RELEASE := "build/release"
VERSION := `git describe --tags --always | sed -e 's/^v//'`
RUNNER_TEMPLATE_ZIP := "backend/controller/scaling/localscaling/template.zip"
TIMESTAMP := `date +%s`
SCHEMA_OUT := "backend/protos/xyz/block/ftl/v1/schema/schema.proto"
ZIP_DIRS := "go-runtime/compile/build-template go-runtime/compile/external-module-template go-runtime/compile/main-work-template internal/projectinit/scaffolding go-runtime/scaffolding jvm-runtime/java/scaffolding jvm-runtime/kotlin/scaffolding"
Expand Down Expand Up @@ -79,7 +78,7 @@ build-sqlc:
@mk backend/controller/sql/{db.go,models.go,querier.go,queries.sql.go} backend/controller/cronjobs/sql/{db.go,models.go,querier.go,queries.sql.go} internal/configuration/sql/{db.go,models.go,querier.go,queries.sql.go} : backend/controller/sql/queries.sql backend/controller/sql/async_queries.sql backend/controller/cronjobs/sql/queries.sql internal/configuration/sql/queries.sql backend/controller/sql/schema sqlc.yaml -- "just init-db && sqlc generate"

# Build the ZIP files that are embedded in the FTL release binaries
build-zips: build-kt-runtime
build-zips:
@for dir in {{ZIP_DIRS}}; do (cd $dir && mk ../$(basename ${dir}).zip : . -- "rm -f $(basename ${dir}.zip) && zip -q --symlinks -r ../$(basename ${dir}).zip ."); done

# Rebuild frontend
Expand All @@ -105,12 +104,6 @@ publish-extension: package-extension
build-intellij-plugin:
@cd frontend/intellij && gradle buildPlugin

# Kotlin runtime is temporarily disabled; these instructions create a dummy zip in place of the kotlin runtime jar for
# the runner.
build-kt-runtime:
@mkdir -p build/template/ftl && touch build/template/ftl/temp.txt
@cd build/template && zip -q --symlinks -r ../../{{RUNNER_TEMPLATE_ZIP}} .

# Format console code.
format-frontend:
cd {{CONSOLE_ROOT}} && pnpm run lint:fix
Expand Down
4 changes: 2 additions & 2 deletions backend/controller/console/testdata/go/console/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 87936e0

Please sign in to comment.