Skip to content

Commit 77e3dea

Browse files
authored
SplitControllerAndExtensions: Fork controller binary and add extensions deployments (googleforgames#2866)
* Initial separation of `agones-controller` and `agones-extensions` * Makefile edits, script changes, etc. * Add deployment for `agones-extensions` under feature gate `SplitControllerAndExtensions` * Follow feature checklist and add `SplitControllerAndExtensions` to feature.go
1 parent 05da749 commit 77e3dea

File tree

12 files changed

+832
-5
lines changed

12 files changed

+832
-5
lines changed

build/Makefile

+51-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ workdir_path = $(mount_path)
102102
build_version = $(call sha,$(build_path)/build-image/Dockerfile)
103103
build_tag = agones-build:$(build_version)
104104
controller_tag = $(REGISTRY)/agones-controller:$(VERSION)
105+
extensions_tag = $(REGISTRY)/agones-extensions:$(VERSION)
105106
sidecar_tag = $(REGISTRY)/agones-sdk:$(VERSION)
106107
allocator_tag = $(REGISTRY)/agones-allocator:$(VERSION)
107108
ping_tag = $(REGISTRY)/agones-ping:$(VERSION)
@@ -118,13 +119,16 @@ allocator_amd64_tag = $(allocator_tag)-amd64
118119
allocator_arm64_tag = $(allocator_tag)-arm64
119120
controller_amd64_tag = $(controller_tag)-amd64
120121
controller_arm64_tag = $(controller_tag)-arm64
122+
extensions_amd64_tag = $(extensions_tag)-amd64
123+
extensions_arm64_tag = $(extensions_tag)-arm64
121124
ping_amd64_tag = $(ping_tag)-amd64
122125
ping_arm64_tag = $(ping_tag)-arm64
123126

124127
# build list of images to include in the manifest for the sidecar image.
125128
push_sidecar_manifest = $(sidecar_linux_amd64_tag)
126129
push_allocator_manifest = $(allocator_amd64_tag)
127130
push_controller_manifest = $(controller_amd64_tag)
131+
push_extensions_manifest = $(extensions_amd64_tag)
128132
push_ping_manifest = $(ping_amd64_tag)
129133
gomod_on = GO111MODULE=on
130134

@@ -250,14 +254,15 @@ ifeq ($(WITH_ARM64), 1)
250254
push_sidecar_manifest += $(sidecar_linux_arm64_tag)
251255
push_allocator_manifest += $(allocator_arm64_tag)
252256
push_controller_manifest += $(controller_arm64_tag)
257+
push_extensions_manifest += $(extensions_arm64_tag)
253258
push_ping_manifest += $(ping_arm64_tag)
254259
endif
255260

256261
# build all
257262
build: build-images build-sdks
258263

259264
# build the docker images
260-
build-images: build-controller-image build-agones-sdk-image build-ping-image build-allocator-image
265+
build-images: build-controller-image build-extensions-image build-agones-sdk-image build-ping-image build-allocator-image
261266

262267
# package the current agones helm chart
263268
build-chart: RELEASE_VERSION ?= $(base_version)
@@ -342,7 +347,7 @@ test-install-yaml:
342347
diff /tmp/agones-install/install.yaml.sorted /tmp/agones-install/install.current.yaml.sorted
343348

344349
# Push all the images up to $(REGISTRY)
345-
push: push-controller-image push-agones-sdk-image push-ping-image push-allocator-image
350+
push: push-controller-image push-extensions-image push-agones-sdk-image push-ping-image push-allocator-image
346351

347352
# Installs the current development version of Agones into the Kubernetes cluster
348353
install: ALWAYS_PULL_SIDECAR := true
@@ -401,6 +406,22 @@ build-controller-binary-linux-arm64: $(ensure-build-image)
401406
-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/controller/bin/controller.linux.arm64 \
402407
$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/controller
403408

409+
# Build a static binary for the gamerserver extensions
410+
ifeq ($(WITH_ARM64), 1)
411+
build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64 build-extensions-binary-linux-arm64
412+
else
413+
build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64
414+
endif
415+
416+
build-extensions-binary-linux-amd64: $(ensure-build-image)
417+
$(GO_BUILD_LINUX_AMD64) \
418+
-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.amd64 \
419+
$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions
420+
build-extensions-binary-linux-arm64: $(ensure-build-image)
421+
$(GO_BUILD_LINUX_ARM64) \
422+
-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.arm64 \
423+
$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions
424+
404425
# Lint the go source code.
405426
# use LINT_TIMEOUT to manipulate the linter timeout
406427
lint: LINT_TIMEOUT ?= 15m
@@ -481,6 +502,34 @@ build-agones-sdk-binary-windows: $(ensure-build-image)
481502
ensure-windows-buildx:
482503
-docker buildx create --name=$(BUILDX_WINDOWS_BUILDER)
483504

505+
# Build the image for the gameserver extensions
506+
build-extensions-image: build-extensions-image-amd64
507+
ifeq ($(WITH_ARM64), 1)
508+
build-extensions-image: build-extensions-image-arm64
509+
endif
510+
511+
build-extensions-image-amd64: $(ensure-build-image) build-extensions-binary build-licenses build-required-src-dist
512+
docker build $(agones_path)/cmd/extensions/ --tag=$(extensions_amd64_tag) $(DOCKER_BUILD_ARGS)
513+
# creating docker builder and then using that builder to build extensions image in buildx command
514+
build-extensions-image-arm64: $(ensure-build-image) build-extensions-binary create-arm64-builder
515+
docker buildx build --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/extensions/ --tag=$(extensions_arm64_tag) $(DOCKER_BUILD_ARGS)
516+
517+
# push the gameservers extensions image
518+
push-extensions-image: push-extensions-image-amd64
519+
ifeq ($(WITH_ARM64), 1)
520+
push-extensions-image: push-extensions-image-arm64
521+
endif
522+
# Ensure that extensions manifest is removed before creating new one.
523+
-DOCKER_CLI_EXPERIMENTAL=enabled docker manifest rm $(extensions_tag)
524+
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(extensions_tag) $(push_extensions_manifest)
525+
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(extensions_tag)
526+
527+
# push extensions image
528+
push-extensions-image-amd64: build-extensions-image-amd64
529+
docker push $(extensions_amd64_tag)
530+
push-extensions-image-arm64: build-extensions-image-arm64
531+
$(MAKE) DOCKER_BUILD_ARGS=--push build-extensions-image-arm64
532+
484533
# Build the image for the gameserver sidecar and SDK binaries
485534
build-agones-sdk-image: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist build-agones-sdk-image-amd64
486535
ifeq ($(WITH_ARM64), 1)

build/build-required-src-dist.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tar -zcf ${TMP_DEPS_SRC} -C ${SRC_ROOT}/vendor/ \
2626
github.com/hashicorp/golang-lru \
2727
github.com/hashicorp/hcl
2828

29-
for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ${SRC_ROOT}/cmd/allocator/bin/ ; do
29+
for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/extensions/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ${SRC_ROOT}/cmd/allocator/bin/ ; do
3030
mkdir -p ${ddir}
3131
cp ${TMP_DEPS_SRC} ${ddir}
3232
done

build/extract-licenses.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ while read -r entry; do
4747
append_license ${LIBRARY} ${entry}
4848
done <<< "$(find vendor/ -regextype posix-extended -iregex '.*LICENSE(\.txt)?')"
4949

50-
for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ${SRC_ROOT}/cmd/allocator/bin/ ; do
50+
for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/extensions/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ${SRC_ROOT}/cmd/allocator/bin/ ; do
5151
mkdir -p ${ddir}
5252
cp ${TMP_LICENSES} ${ddir}
5353
done

cmd/extensions/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2022 Google LLC All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM alpine:3.14
16+
17+
ARG ARCH=amd64
18+
RUN apk --update add ca-certificates && \
19+
adduser -D -u 1000 agones
20+
21+
COPY --chown=agones:agones ./bin/extensions.linux.$ARCH /home/agones/extensions
22+
COPY --chown=agones:agones ./bin/LICENSES ./bin/dependencies-src.tgz /home/agones/
23+
24+
USER 1000
25+
ENTRYPOINT ["/home/agones/extensions"]

0 commit comments

Comments
 (0)