agones.dev/agones@v1.54.0/build/Makefile (about) 1 # Copyright 2017 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 # 16 # Makefile for building, testing and developing Agones 17 # 18 19 # __ __ _ _ _ 20 # \ \ / /_ _ _ __(_) __ _| |__ | | ___ ___ 21 # \ \ / / _` | '__| |/ _` | '_ \| |/ _ \ __| 22 # \ V / (_| | | | | (_| | |_) | | __\__ \ 23 # \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/ 24 # 25 26 # base version target. This is usually the next release. 27 base_version = 1.54.0 28 29 # 30 # All of the following can be overwritten with environment variables 31 # or passed through directly when invoking the relevent Make targets 32 # 33 34 # Version defaults to the short hash of the latest commit 35 VERSION ?= $(base_version)-dev-$(shell git rev-parse --short=7 HEAD) 36 37 # kubectl configuration to use 38 KUBECONFIG ?= ~/.kube/config 39 # The (gcloud) test cluster that is being worked against 40 GCP_CLUSTER_NAME ?= test-cluster 41 GCP_CLUSTER_ZONE ?= us-west1-c 42 GCP_CLUSTER_LOCATION ?= $(GCP_CLUSTER_ZONE) 43 GCP_BUCKET_CHARTS ?= agones-chart 44 # the profile to use when developing on minikube 45 MINIKUBE_PROFILE ?= agones 46 GO_BUILD_TAGS ?= none 47 BUILDX_WINDOWS_BUILDER = windows-builder 48 BUILDX_ARM64_BUILDER = arm64-builder 49 WINDOWS_DOCKER_PUSH_ARGS = 50 # Versions of Windows Server to support, default is Windows Server 2019. 51 # For the full list of tags see https://hub.docker.com/_/microsoft-windows-servercore. 52 # GKE-Windows version map: https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#version_mapping 53 WINDOWS_VERSIONS = ltsc2019 ltsc2022 54 55 # https://github.com/microsoft/Windows-Containers/issues/493: Pin the LTSC2019 image to an older sha 56 LTSC2019_IMAGE_TAG = "@sha256:6fdf140282a2f809dae9b13fe441635867f0a27c33a438771673b8da8f3348a4" 57 58 BASE.windows := mcr.microsoft.com/windows/servercore 59 60 # Specify stress test level 1..100 61 # STRESS_TEST_LEVEL=n requires capacity between 50*n up to 100*n simple-game-server Game Servers. 62 STRESS_TEST_LEVEL ?= 20 63 64 # kind cluster name to use 65 KIND_PROFILE ?= agones 66 KIND_CONTAINER_NAME=$(KIND_PROFILE)-control-plane 67 68 # Game Server image to use while doing end-to-end tests 69 GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.39 70 71 # Enable all beta feature gates. Keep in sync with `true` (beta) entries in pkg/util/runtime/features.go:featureDefaults 72 BETA_FEATURE_GATES ?= "CountsAndLists=true&GKEAutopilotExtendedDurationPods=true&PortPolicyNone=true&PortRanges=true&RollingUpdateFix=true&ScheduledAutoscaler=true" 73 74 75 # Enable all alpha feature gates. Keep in sync with `false` (alpha) entries in pkg/util/runtime/features.go:featureDefaults 76 ALPHA_FEATURE_GATES ?= "PlayerAllocationFilter=true&FleetAutoscaleRequestMetaData=true&PlayerTracking=true&SidecarContainers=true&WasmAutoscaler=true&Example=true" 77 78 # Build with Windows support 79 WITH_WINDOWS=1 80 # Build with arm64support 81 WITH_ARM64=1 82 83 # Directory that this Makefile is in. 84 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 85 build_path := $(dir $(mkfile_path)) 86 agones_path := $(realpath $(build_path)/..) 87 site_path := $(agones_path)/site 88 89 kubeconfig_path := $(dir $(KUBECONFIG)) 90 kubeconfig_file := $(notdir $(KUBECONFIG)) 91 92 helm_config := ~/.config/helm 93 helm_cache := ~/.cache/helm 94 95 agones_package = agones.dev/agones 96 mount_path = /go/src/$(agones_package) 97 common_mounts = -v $(build_path)/.config/gcloud:/root/.config/gcloud \ 98 -v $(kubeconfig_path):/root/.kube \ 99 -v $(helm_config):/root/.config/helm \ 100 -v $(helm_cache):/root/.cache/helm \ 101 -v $(agones_path):$(mount_path) \ 102 -v $(build_path)/.gomod:/go/pkg/mod 103 104 # Its possible for this to change in the future, so it gets its own variable. 105 REGISTRY ?= local 106 CHARTS_REGISTRY ?= 107 workdir_path = $(mount_path) 108 109 build_version = $(call sha,$(build_path)/build-image/Dockerfile) 110 build_tag = agones-build:$(build_version) 111 controller_tag = $(REGISTRY)/agones-controller:$(VERSION) 112 extensions_tag = $(REGISTRY)/agones-extensions:$(VERSION) 113 sidecar_tag = $(REGISTRY)/agones-sdk:$(VERSION) 114 allocator_tag = $(REGISTRY)/agones-allocator:$(VERSION) 115 ping_tag = $(REGISTRY)/agones-ping:$(VERSION) 116 processor_tag = $(REGISTRY)/agones-processor:$(VERSION) 117 118 ifeq ($(WITH_WINDOWS), 1) 119 sidecar_linux_amd64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-linux-amd64 120 sidecar_linux_arm64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-linux-arm64 121 else 122 sidecar_linux_amd64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-amd64 123 sidecar_linux_arm64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-arm64 124 endif 125 126 allocator_amd64_tag = $(allocator_tag)-amd64 127 allocator_arm64_tag = $(allocator_tag)-arm64 128 controller_amd64_tag = $(controller_tag)-amd64 129 controller_arm64_tag = $(controller_tag)-arm64 130 extensions_amd64_tag = $(extensions_tag)-amd64 131 extensions_arm64_tag = $(extensions_tag)-arm64 132 ping_amd64_tag = $(ping_tag)-amd64 133 ping_arm64_tag = $(ping_tag)-arm64 134 processor_amd64_tag = $(processor_tag)-amd64 135 processor_arm64_tag = $(processor_tag)-arm64 136 137 # build list of images to include in the manifest for the sidecar image. 138 push_sidecar_manifest = $(sidecar_linux_amd64_tag) 139 push_allocator_manifest = $(allocator_amd64_tag) 140 push_controller_manifest = $(controller_amd64_tag) 141 push_extensions_manifest = $(extensions_amd64_tag) 142 push_ping_manifest = $(ping_amd64_tag) 143 push_processor_manifest = $(processor_amd64_tag) 144 145 gomod_on = GO111MODULE=on 146 147 go_version_flags = -ldflags "-X agones.dev/agones/pkg.Version=$(VERSION)" 148 DOCKER_RUN ?= docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -e "$(gomod_on)" -w $(workdir_path) $(DOCKER_RUN_ARGS) $(build_tag) 149 150 ifdef DOCKER_RUN 151 ensure-build-image += ensure-build-image 152 endif 153 154 git_safe = git config --global --add safe.directory $(mount_path) 155 156 # When performing full build, always rebuild go packages and compress more 157 ifdef FULL_BUILD 158 go_rebuild_flags = -a 159 zip_flags = -9 160 endif 161 162 ifndef FULL_BUILD 163 # keep a cache of files built by Go across docker invocations in a local directory. 164 common_mounts += -v $(build_path)/.gocache:/root/.cache/go-build 165 go_rebuild_flags = 166 167 # do not compress files in zips, slightly faster 168 zip_flags = -0 169 endif 170 171 go_build_cmd = go build -mod=vendor -buildvcs=false 172 GO_BUILD_LINUX_AMD64=docker run --rm -e "CGO_ENABLED=0" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd) 173 GO_BUILD_LINUX_ARM64=docker run --rm -e "CGO_ENABLED=0" -e "GOOS=linux" -e "GOARCH=arm64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd) 174 GO_BUILD_DARWIN_AMD64=docker run --rm -e "GOOS=darwin" -e "GOARCH=amd64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd) 175 GO_BUILD_DARWIN_ARM64=docker run --rm -e "GOOS=darwin" -e "GOARCH=arm64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd) 176 GO_BUILD_WINDOWS_AMD64=docker run --rm -e "GOOS=windows" -e "GOARCH=amd64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd) 177 178 RACE_DETECTOR_ARGS=-race 179 180 ifdef NO_RACE_DETECTOR 181 RACE_DETECTOR_ARGS= 182 endif 183 184 go_test_args = -mod=vendor $(RACE_DETECTOR_ARGS) 185 go_test_cmd = go test $(go_test_args) 186 GO_TEST=$(DOCKER_RUN) $(go_test_cmd) 187 GO_E2E_TEST_ARGS=--kubeconfig /root/.kube/$(kubeconfig_file) 188 189 gotestsum_json=/tmp/agones.gotestsum.json 190 ifdef GOTESTSUM_VERBOSE 191 gotestsum_format=--format=testname \ 192 --post-run-command="sh -c 'echo; echo --- RAW VERBOSE OUTPUT ---; jq -j \"select(.Output != null) | (\\\"VERBOSE: \\\" + .Output)\" < $(gotestsum_json); echo --- END RAW VERBOSE OUTPUT ---'" 193 else 194 gotestsum_format=--format=standard-quiet 195 endif 196 gotestsum_cmd=gotestsum $(gotestsum_format) --jsonfile=$(gotestsum_json) --hide-summary=skipped --rerun-fails=2 $(GOTESTSUM_ARGS) 197 GOTESTSUM=$(DOCKER_RUN) $(gotestsum_cmd) 198 199 PERF_OUTPUT_DIR=$(mount_path)/build/.perf 200 201 go_build_base_path=$(mount_path) 202 203 ifdef LOCAL_GO 204 # use local Go tooling, which greatly speeds up incremental rebuilds, in particular on macOS 205 # Note that agones.dev must be in GOPATH 206 GO_BUILD_LINUX_AMD64=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(gomod_on) $(go_build_cmd) 207 GO_BUILD_WINDOWS_AMD64=GOOS=windows GOARCH=amd64 $(gomod_on) $(go_build_cmd) 208 GO_BUILD_DARWIN_AMD64=GOOS=darwin GOARCH=amd64 $(gomod_on) $(go_build_cmd) 209 GO_TEST=$(go_test_cmd) -v 210 GOTESTSUM=$(gotestsum_cmd) 211 GO_E2E_TEST_ARGS= 212 PERF_OUTPUT_DIR=$(build_path)/.perf 213 go_build_base_path=$(agones_path) 214 endif 215 216 ZIP_SDK=docker run --rm $(common_mounts) -w $(workdir_path)/cmd/sdk-server/bin/ $(build_tag) zip $(zip_flags) 217 ifdef LOCAL_ZIP 218 ZIP_SDK=cd $(agones_path)/cmd/sdk-server/bin && zip -0 219 endif 220 221 unameprocessor := $(shell uname -p) 222 ifeq ($(unameprocessor),arm) 223 DOCKER_BUILD_ARGS += --platform linux/x86_64 224 DOCKER_RUN_ARGS += --platform linux/x86_64 225 endif 226 227 # ___ ____ ___ _ _ 228 # / _ \/ ___| |_ _|_ __ ___| |_ _ __| | ___ 229 # | | | \___ \ | || '_ \ / __| | | | |/ _` |/ _ \ 230 # | |_| |___) | | || | | | (__| | |_| | (_| | __/ 231 # \___/|____/ |___|_| |_|\___|_|\__,_|\__,_|\___| 232 # 233 234 uname := $(shell uname -s) 235 ifneq ($(findstring Microsoft,$(shell uname -r)),) 236 osinclude := windows.mk 237 else ifeq ($(uname),Linux) 238 osinclude := linux.mk 239 else ifeq ($(uname),Darwin) 240 osinclude := macos.mk 241 endif 242 243 include ./includes/$(osinclude) 244 245 # ___ _ _ 246 # |_ _|_ __ ___| |_ _ __| | ___ ___ 247 # | || '_ \ / __| | | | |/ _` |/ _ \ __| 248 # | || | | | (__| | |_| | (_| | __\__ \ 249 # |___|_| |_|\___|_|\__,_|\__,_|\___|___/ 250 # 251 252 # personal includes, excluded from the git repository 253 -include ./local-includes/*.mk 254 255 include ./includes/build-image.mk 256 include ./includes/release.mk 257 include ./includes/google-cloud.mk 258 include ./includes/minikube.mk 259 include ./includes/kind.mk 260 include ./includes/website.mk 261 include ./includes/sdk.mk 262 include ./includes/allocation.mk 263 include ./includes/examples.mk 264 265 # _____ _ 266 # |_ _|_ _ _ __ __ _ ___| |_ ___ 267 # | |/ _` | '__/ _` |/ _ \ __/ __| 268 # | | (_| | | | (_| | __/ |_\__ \ 269 # |_|\__,_|_| \__, |\___|\__|___/ 270 # |___/ 271 272 # Dynamic variables that impact targets below. 273 # Do not move as these need to be evaluated after the `local-includes` folder to allow for local override. 274 275 ifeq ($(WITH_WINDOWS), 1) 276 push_sidecar_manifest += $(foreach windows_version, $(WINDOWS_VERSIONS), $(sidecar_tag)-windows_amd64-$(windows_version)) 277 endif 278 ifeq ($(WITH_ARM64), 1) 279 push_sidecar_manifest += $(sidecar_linux_arm64_tag) 280 push_allocator_manifest += $(allocator_arm64_tag) 281 push_controller_manifest += $(controller_arm64_tag) 282 push_extensions_manifest += $(extensions_arm64_tag) 283 push_ping_manifest += $(ping_arm64_tag) 284 push_processor_manifest += $(processor_arm64_tag) 285 endif 286 287 # build all 288 build: build-images build-sdks 289 290 # build the docker images 291 build-images: build-controller-image build-extensions-image build-agones-sdk-image build-ping-image build-allocator-image build-processor-image 292 293 # package the current agones helm chart 294 build-chart: RELEASE_VERSION ?= $(base_version) 295 build-chart: CHART_DIR ?= install/helm/agones/ 296 build-chart: $(ensure-build-image) 297 docker run --rm $(common_mounts) -w $(workdir_path) $(build_tag) bash -c \ 298 "mkdir -p install/helm/bin/ && rm -rf install/helm/bin/* && \ 299 helm package -d install/helm/bin/ --version $(RELEASE_VERSION) $(CHART_DIR)" 300 301 # push a specific release useful to push previous missing release 302 push-release-chart: RELEASE_VERSION ?= $(base_version) 303 push-release-chart: $(ensure-build-image) 304 rm -rf /tmp/agones $(agones_path)/install/.helm-$(RELEASE_VERSION)/ 305 mkdir -p $(agones_path)/install/.helm-$(RELEASE_VERSION)/ 306 cd /tmp && git clone --single-branch -b release-$(RELEASE_VERSION) git@github.com:googleforgames/agones.git 307 mv /tmp/agones/install/helm/agones $(agones_path)/install/.helm-$(RELEASE_VERSION)/ 308 CHART_DIR=install/.helm-$(RELEASE_VERSION)/agones $(MAKE) push-chart 309 310 # Run all tests 311 test: $(ensure-build-image) test-go test-sdks test-install-yaml site-test helm-lint test-build-scripts 312 313 # Run go tests 314 test-go: $(ensure-build-image) 315 $(GO_TEST) $(agones_package)/pkg/... \ 316 $(agones_package)/sdks/... $(agones_package)/cmd/... 317 318 # Run unit tests for all build scripts. Run script tests that have their own Go module separately. 319 test-build-scripts: $(ensure-build-image) 320 $(GO_TEST) $(agones_package)/build/scripts/... 321 $(DOCKER_RUN) bash -c "cd build/scripts/previousversion && go test -v ." 322 $(DOCKER_RUN) bash -c "cd build/scripts/site-config-update-version && go test -v ." 323 324 # Runs end-to-end tests on the current configured cluster 325 # For minikube user the minikube-test-e2e targets 326 test-e2e: 327 $(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-integration 328 $(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-failure 329 $(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-ha-extensions 330 $(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-allocator-crash 331 332 333 # e2e test args: 334 # - Use ARGS to pass args to `go test` (but not the test binary itself) 335 # - Use GO_E2E_TEST_ARGS to pass args to the test binary 336 # - When E2E_USE_GOTESTSUM is enabled, use GOTESTSUM_ARGS to pass args to gotestsum 337 # If GAMESERVERS_NAMESPACE is empty - random namespace will be created 338 test-e2e-integration: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES) 339 test-e2e-integration: CLOUD_PRODUCT ?= generic 340 test-e2e-integration: GAMESERVERS_NAMESPACE ?= "" 341 test-e2e-integration: GO_E2E_TEST_INTEGRATION_ARGS ?=\ 342 --cloud-product=$(CLOUD_PRODUCT) \ 343 --gameserver-image=$(GS_TEST_IMAGE) \ 344 --pullsecret=$(IMAGE_PULL_SECRET) \ 345 --feature-gates=$(FEATURE_GATES) \ 346 --namespace=$(GAMESERVERS_NAMESPACE) 347 test-e2e-integration: $(ensure-build-image) 348 echo "Starting e2e integration test!" 349 ifdef E2E_USE_GOTESTSUM 350 $(GOTESTSUM) --packages=$(agones_package)/test/e2e -- $(go_test_args) -timeout=45m $(ARGS) -args \ 351 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 352 else 353 $(GO_TEST) -timeout=30m $(ARGS) $(agones_package)/test/e2e -args \ 354 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 355 endif 356 echo "Finishing e2e integration test!" 357 358 test-e2e-failure: CLOUD_PRODUCT ?= generic 359 test-e2e-failure: GO_E2E_TEST_INTEGRATION_ARGS ?=\ 360 --cloud-product=$(CLOUD_PRODUCT) \ 361 --gameserver-image=$(GS_TEST_IMAGE) \ 362 --pullsecret=$(IMAGE_PULL_SECRET) 363 test-e2e-failure: $(ensure-build-image) 364 echo "Starting e2e controller failure test!" 365 ifdef E2E_USE_GOTESTSUM 366 $(GOTESTSUM) --packages=$(agones_package)/test/e2e/controller -- $(go_test_args) $(ARGS) -parallel=1 -args \ 367 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 368 else 369 $(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/controller -args \ 370 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 371 endif 372 echo "Finishing e2e controller failure test!" 373 374 test-e2e-ha-extensions: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES) 375 test-e2e-ha-extensions: CLOUD_PRODUCT ?= generic 376 test-e2e-ha-extensions: GO_E2E_TEST_INTEGRATION_ARGS ?=\ 377 --cloud-product=$(CLOUD_PRODUCT) \ 378 --gameserver-image=$(GS_TEST_IMAGE) \ 379 --feature-gates=$(FEATURE_GATES) \ 380 --pullsecret=$(IMAGE_PULL_SECRET) 381 test-e2e-ha-extensions: $(ensure-build-image) 382 echo "Starting e2e extensions high availability test!" 383 ifdef E2E_USE_GOTESTSUM 384 $(GOTESTSUM) --packages=$(agones_package)/test/e2e/extensions -- $(go_test_args) $(ARGS) -parallel=1 -args \ 385 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 386 else 387 $(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/extensions -args \ 388 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 389 endif 390 echo "Finishing e2e extensions high availability test!" 391 392 test-e2e-allocator-crash: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES) 393 test-e2e-allocator-crash: CLOUD_PRODUCT ?= generic 394 test-e2e-allocator-crash: GO_E2E_TEST_INTEGRATION_ARGS ?=\ 395 --cloud-product=$(CLOUD_PRODUCT) \ 396 --gameserver-image=$(GS_TEST_IMAGE) \ 397 --feature-gates=$(FEATURE_GATES) \ 398 --pullsecret=$(IMAGE_PULL_SECRET) 399 test-e2e-allocator-crash: $(ensure-build-image) 400 echo "Starting e2e allocation pod deletion test!" 401 ifdef E2E_USE_GOTESTSUM 402 $(GOTESTSUM) --packages=$(agones_package)/test/e2e/allocator -- $(go_test_args) $(ARGS) -parallel=1 -args \ 403 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 404 else 405 $(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/allocator -args \ 406 $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS) 407 endif 408 echo "Finishing e2e allocation pod deletion test!" 409 410 # Runs end-to-end stress tests on the current configured cluster 411 # For minikube user the minikube-stress-test-e2e targets 412 stress-test-e2e: $(ensure-build-image) 413 $(GO_TEST) $(agones_package)/test/e2e $(ARGS) \ 414 -timeout 1h \ 415 -run '.*StressTest.*' \ 416 -args \ 417 $(GO_E2E_TEST_ARGS) \ 418 --gameserver-image=$(GS_TEST_IMAGE) \ 419 --pullsecret=$(IMAGE_PULL_SECRET) \ 420 --stress $(STRESS_TEST_LEVEL) \ 421 --perf-output $(PERF_OUTPUT_DIR) \ 422 --version $(VERSION) 423 424 # Run test on install yaml - make sure there is no change 425 # mostly this is for CI 426 test-install-yaml: 427 -mkdir -p /tmp/agones-install 428 cp $(agones_path)/install/yaml/install.yaml /tmp/agones-install/install.yaml 429 sort /tmp/agones-install/install.yaml > /tmp/agones-install/install.yaml.sorted 430 $(MAKE) gen-install 431 sort $(agones_path)/install/yaml/install.yaml > /tmp/agones-install/install.current.yaml.sorted 432 diff /tmp/agones-install/install.yaml.sorted /tmp/agones-install/install.current.yaml.sorted 433 434 # Push all the images up to $(REGISTRY) 435 push: push-controller-image push-extensions-image push-agones-sdk-image push-ping-image push-allocator-image push-processor-image 436 437 # Installs the current development version of Agones into the Kubernetes cluster 438 install: ALWAYS_PULL_SIDECAR := true 439 install: IMAGE_PULL_POLICY := "Always" 440 install: PING_SERVICE_TYPE := "LoadBalancer" 441 install: ALLOCATOR_SERVICE_TYPE := "LoadBalancer" 442 install: CRD_CLEANUP := true 443 install: LOG_LEVEL := "debug" 444 install: EXTERNAL_IP ?= $(shell $(DOCKER_RUN) kubectl get services agones-allocator -n agones-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}') 445 install: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES) 446 install: SERVICE_MONITOR := false 447 install: HELM_ARGS ?= 448 install: $(ensure-build-image) install-custom-pull-secret 449 -$(DOCKER_RUN) bash -c ' \ 450 HELM_STATUS=$$(helm status agones -n agones-system --output json 2>/dev/null || echo "{}") && \ 451 STATUS=$$(echo "$$HELM_STATUS" | jq -r ".info.status // \"not-found\"" 2>/dev/null || echo "not-found") && \ 452 DESCRIPTION=$$(echo "$$HELM_STATUS" | jq -r ".info.description // \"no details\"" 2>/dev/null || echo "no details") && \ 453 if [[ "$$STATUS" =~ ^(failed|pending-.*)$$ ]]; then \ 454 echo "Uninstalling problematic Agones release in $$STATUS state: $$DESCRIPTION..." && \ 455 helm uninstall agones --namespace=agones-system --wait --timeout=20m; \ 456 fi || true' 457 $(DOCKER_RUN) \ 458 helm upgrade --install --atomic --wait --timeout 10m --namespace=agones-system \ 459 --create-namespace \ 460 --set agones.image.tag=$(VERSION),agones.image.registry=$(REGISTRY) \ 461 --set agones.image.controller.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.controller.pullSecret=$(IMAGE_PULL_SECRET) \ 462 --set agones.image.extensions.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.allocator.pullPolicy=$(IMAGE_PULL_POLICY) \ 463 --set agones.image.ping.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.sdk.alwaysPull=$(ALWAYS_PULL_SIDECAR) \ 464 --set agones.ping.http.serviceType=$(PING_SERVICE_TYPE),agones.ping.udp.serviceType=$(PING_SERVICE_TYPE) \ 465 --set agones.allocator.service.serviceType=$(ALLOCATOR_SERVICE_TYPE) \ 466 --set agones.controller.logLevel=$(LOG_LEVEL) \ 467 --set agones.crds.cleanupOnDelete=$(CRD_CLEANUP) \ 468 --set agones.featureGates=$(FEATURE_GATES) \ 469 --set agones.allocator.service.loadBalancerIP=$(EXTERNAL_IP) \ 470 --set agones.metrics.serviceMonitor.enabled=$(SERVICE_MONITOR) \ 471 $(HELM_ARGS) \ 472 agones $(mount_path)/install/helm/agones/ 473 474 update-allocation-certs: NAMESPACE ?= default 475 update-allocation-certs: install 476 update-allocation-certs: 477 -mkdir -p $(agones_path)/build/allocation 478 $(DOCKER_RUN) bash -c 'kubectl get secret allocator-client.default -n $(NAMESPACE) -ojsonpath="{.data.tls\.crt}" | base64 -d > $(mount_path)/build/allocation/client.crt' 479 $(DOCKER_RUN) bash -c 'kubectl get secret allocator-client.default -n $(NAMESPACE) -ojsonpath="{.data.tls\.key}" | base64 -d > $(mount_path)/build/allocation/client.key' 480 $(DOCKER_RUN) bash -c 'kubectl get secret allocator-tls-ca -n agones-system -ojsonpath="{.data.tls-ca\.crt}" | base64 -d > $(mount_path)/build/allocation/ca.crt' 481 482 uninstall: $(ensure-build-image) 483 $(DOCKER_RUN) \ 484 helm uninstall agones --namespace=agones-system 485 486 # Build a static binary for the gameserver controller 487 ifeq ($(WITH_ARM64), 1) 488 build-controller-binary: $(ensure-build-image) build-controller-binary-linux-amd64 build-controller-binary-linux-arm64 489 else 490 build-controller-binary: $(ensure-build-image) build-controller-binary-linux-amd64 491 endif 492 493 build-controller-binary-linux-amd64: $(ensure-build-image) 494 $(GO_BUILD_LINUX_AMD64) \ 495 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/controller/bin/controller.linux.amd64 \ 496 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/controller 497 build-controller-binary-linux-arm64: $(ensure-build-image) 498 $(GO_BUILD_LINUX_ARM64) \ 499 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/controller/bin/controller.linux.arm64 \ 500 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/controller 501 502 # Build a static binary for the gamerserver extensions 503 ifeq ($(WITH_ARM64), 1) 504 build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64 build-extensions-binary-linux-arm64 505 else 506 build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64 507 endif 508 509 build-extensions-binary-linux-amd64: $(ensure-build-image) 510 $(GO_BUILD_LINUX_AMD64) \ 511 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.amd64 \ 512 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions 513 build-extensions-binary-linux-arm64: $(ensure-build-image) 514 $(GO_BUILD_LINUX_ARM64) \ 515 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.arm64 \ 516 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions 517 518 # Lint the go source code and yaml files. 519 # use LINT_TIMEOUT to manipulate the linter timeout 520 lint: LINT_TIMEOUT ?= 15m 521 lint: $(ensure-build-image) 522 docker run -t -e "TERM=xterm-256color" -e "$(gomod_on)" --rm $(common_mounts) -w $(workdir_path) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \ 523 "$(git_safe) && \ 524 golangci-lint run ./examples/... && \ 525 golangci-lint run --timeout $(LINT_TIMEOUT) ./... && \ 526 yamllint ." 527 528 # Extract licenses from source tree 529 build-licenses: 530 docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/extract-licenses.sh 531 532 # Tarball source for dependencies that are required to be distributed with the image (MPL) 533 build-required-src-dist: 534 docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/build-required-src-dist.sh 535 536 # Create docker builder used in creating arm64 images 537 # According to the docker documentation, to build the images for ARM64 arch CPU 538 # we would need to use buildx command which uses builder https://docs.docker.com/desktop/multi-arch/ 539 # We primarily need this for M1 Macs, see: https://medium.com/geekculture/docker-build-with-mac-m1-d668c802ab96 540 create-arm64-builder: 541 docker buildx use $(BUILDX_ARM64_BUILDER) || docker buildx create --name $(BUILDX_ARM64_BUILDER) --use 542 543 # Build the image for the gameserver controller 544 build-controller-image: build-controller-image-amd64 545 ifeq ($(WITH_ARM64), 1) 546 build-controller-image: build-controller-image-arm64 547 endif 548 549 build-controller-image-amd64: $(ensure-build-image) build-controller-binary build-licenses build-required-src-dist 550 docker build $(agones_path)/cmd/controller/ --tag=$(controller_amd64_tag) $(DOCKER_BUILD_ARGS) 551 # creating docker builder and then using that builder to build controller image in buildx command 552 build-controller-image-arm64: $(ensure-build-image) build-controller-binary create-arm64-builder 553 docker buildx build --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/controller/ --tag=$(controller_arm64_tag) $(DOCKER_BUILD_ARGS) 554 555 # push the gameservers controller image 556 push-controller-image: push-controller-image-amd64 557 ifeq ($(WITH_ARM64), 1) 558 push-controller-image: push-controller-image-arm64 559 endif 560 # Docker >=24.0.6 561 docker buildx imagetools create --tag $(controller_tag) $(push_controller_manifest) 562 563 push-controller-image-amd64: build-controller-image-amd64 564 docker push $(controller_amd64_tag) 565 push-controller-image-arm64: build-controller-image-arm64 566 $(MAKE) DOCKER_BUILD_ARGS=--push build-controller-image-arm64 567 568 # build the static binary for the gameserver sidecar 569 build-agones-sdk-binary: $(ensure-build-image) build-agones-sdk-binary-linux-amd64 build-agones-sdk-binary-linux-arm64 build-agones-sdk-binary-windows build-agones-sdk-binary-darwin-amd64 build-agones-sdk-binary-darwin-arm64 570 $(ZIP_SDK) \ 571 agonessdk-server-$(VERSION).zip sdk-server.darwin.amd64 sdk-server.darwin.arm64 sdk-server.linux.amd64 sdk-server.linux.arm64 sdk-server.windows.amd64.exe 572 573 # build the static binary for the gameserver sidecar for Linux 574 build-agones-sdk-binary-linux-amd64: $(ensure-build-image) 575 $(GO_BUILD_LINUX_AMD64) \ 576 -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.linux.amd64 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/sdk-server 577 build-agones-sdk-binary-linux-arm64: $(ensure-build-image) 578 $(GO_BUILD_LINUX_ARM64) \ 579 -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.linux.arm64 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/sdk-server 580 581 582 # build the static binary for the gameserver sidecar for Darwin (macOS) 583 build-agones-sdk-binary-darwin-amd64: $(ensure-build-image) 584 $(GO_BUILD_DARWIN_AMD64) \ 585 -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.darwin.amd64 $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server 586 build-agones-sdk-binary-darwin-arm64: $(ensure-build-image) 587 $(GO_BUILD_DARWIN_ARM64) \ 588 -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.darwin.arm64 $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server 589 590 # build the windows binary for the gameserver sidecar for Windows 591 build-agones-sdk-binary-windows: $(ensure-build-image) 592 $(GO_BUILD_WINDOWS_AMD64) \ 593 -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.windows.amd64.exe $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server 594 595 ensure-windows-buildx: 596 docker buildx use $(BUILDX_WINDOWS_BUILDER) || docker buildx create --platform windows/amd64 --name $(BUILDX_WINDOWS_BUILDER) --use 597 598 # Build the image for the gameserver extensions 599 build-extensions-image: build-extensions-image-amd64 600 ifeq ($(WITH_ARM64), 1) 601 build-extensions-image: build-extensions-image-arm64 602 endif 603 604 build-extensions-image-amd64: $(ensure-build-image) build-extensions-binary build-licenses build-required-src-dist 605 docker build $(agones_path)/cmd/extensions/ --tag=$(extensions_amd64_tag) $(DOCKER_BUILD_ARGS) 606 # creating docker builder and then using that builder to build extensions image in buildx command 607 build-extensions-image-arm64: $(ensure-build-image) build-extensions-binary create-arm64-builder 608 docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/extensions/ --tag=$(extensions_arm64_tag) $(DOCKER_BUILD_ARGS) 609 610 # push the gameservers extensions image 611 push-extensions-image: push-extensions-image-amd64 612 ifeq ($(WITH_ARM64), 1) 613 push-extensions-image: push-extensions-image-arm64 614 endif 615 # Docker >=24.0.6 616 docker buildx imagetools create --tag $(extensions_tag) $(push_extensions_manifest) 617 618 # push extensions image 619 push-extensions-image-amd64: build-extensions-image-amd64 620 docker push $(extensions_amd64_tag) 621 push-extensions-image-arm64: build-extensions-image-arm64 622 $(MAKE) DOCKER_BUILD_ARGS=--push build-extensions-image-arm64 623 624 # Build the image for the gameserver sidecar and SDK binaries 625 build-agones-sdk-image: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist build-agones-sdk-image-amd64 626 ifeq ($(WITH_ARM64), 1) 627 build-agones-sdk-image: build-agones-sdk-image-arm64 628 endif 629 ifeq ($(WITH_WINDOWS), 1) 630 build-agones-sdk-image: build-agones-sdk-image-windows 631 endif 632 633 build-agones-sdk-image-amd64: $(ensure-build-image) build-agones-sdk-binary-linux-amd64 634 docker build $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_linux_amd64_tag) $(DOCKER_BUILD_ARGS) 635 # creating docker builder and then using that builder to build sdk image in buildx command 636 build-agones-sdk-image-arm64: $(ensure-build-image) build-agones-sdk-binary-linux-arm64 create-arm64-builder 637 docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_linux_arm64_tag) $(DOCKER_BUILD_ARGS) 638 639 build-agones-sdk-image-windows: build-agones-sdk-binary 640 build-agones-sdk-image-windows: $(foreach winver, $(WINDOWS_VERSIONS), build-agones-sdk-image-windows-$(winver)) 641 642 # Build the image for the gameserver sidecar and SDK binaries 643 build-agones-sdk-image-windows-%: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist ensure-windows-buildx 644 docker buildx build --provenance false --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER) -f $(agones_path)/cmd/sdk-server/Dockerfile.windows --tag=$(sidecar_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* --build-arg IMAGE_TAG=$(if $(filter ltsc2019,$*),$(LTSC2019_IMAGE_TAG)) $(DOCKER_BUILD_ARGS) $(agones_path)/cmd/sdk-server/ $(WINDOWS_DOCKER_PUSH_ARGS) 645 646 # Build a static binary for the ping service 647 build-ping-binary: build-ping-binary-amd64 648 ifeq ($(WITH_ARM64), 1) 649 build-ping-binary: build-ping-binary-arm64 650 endif 651 652 build-ping-binary-amd64: $(ensure-build-image) 653 $(GO_BUILD_LINUX_AMD64) \ 654 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/ping/bin/ping.linux.amd64 \ 655 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/ping 656 build-ping-binary-arm64: $(ensure-build-image) 657 $(GO_BUILD_LINUX_ARM64) \ 658 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/ping/bin/ping.linux.arm64 \ 659 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/ping 660 661 # Pushes up the ping image 662 push-ping-image: push-ping-image-amd64 663 ifeq ($(WITH_ARM64), 1) 664 push-ping-image: push-ping-image-arm64 665 endif 666 # Docker >=24.0.6 667 docker buildx imagetools create --tag $(ping_tag) $(push_ping_manifest) 668 669 670 push-ping-image-amd64: $(ensure-build-image) build-ping-image-amd64 671 docker push $(ping_amd64_tag) 672 push-ping-image-arm64: 673 $(MAKE) DOCKER_BUILD_ARGS=--push build-ping-image-arm64 674 675 # Build the image for the ping service 676 build-ping-image: build-ping-image-amd64 677 ifeq ($(WITH_ARM64), 1) 678 build-ping-image: build-ping-image-arm64 679 endif 680 681 build-ping-image-amd64: $(ensure-build-image) build-ping-binary build-licenses build-required-src-dist 682 docker build $(agones_path)/cmd/ping/ --tag=$(ping_amd64_tag) $(DOCKER_BUILD_ARGS) 683 # creating docker builder and then using that builder to build ping image in buildx command 684 build-ping-image-arm64: $(ensure-build-image) build-ping-binary create-arm64-builder 685 docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/ping/ --tag=$(ping_arm64_tag) $(DOCKER_BUILD_ARGS) 686 687 # Build a static binary for the allocator service 688 build-allocator-binary: $(ensure-build-image) build-allocator-binary-linux-amd64 689 ifeq ($(WITH_ARM64), 1) 690 build-allocator-binary: build-allocator-binary-linux-arm64 691 endif 692 693 build-allocator-binary-linux-amd64: $(ensure-build-image) 694 $(GO_BUILD_LINUX_AMD64) \ 695 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/allocator/bin/allocator.linux.amd64 \ 696 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/allocator 697 build-allocator-binary-linux-arm64: 698 $(GO_BUILD_LINUX_ARM64) \ 699 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/allocator/bin/allocator.linux.arm64 \ 700 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/allocator 701 702 # Pushes up the allocator image 703 push-allocator-image: push-allocator-image-amd64 704 ifeq ($(WITH_ARM64), 1) 705 push-allocator-image: push-allocator-image-arm64 706 endif 707 # Docker >=24.0.6 708 docker buildx imagetools create --tag $(allocator_tag) $(push_allocator_manifest) 709 710 push-allocator-image-amd64: build-allocator-image-amd64 711 docker push $(allocator_amd64_tag) 712 push-allocator-image-arm64: build-allocator-image-arm64 713 $(MAKE) DOCKER_BUILD_ARGS=--push build-allocator-image-arm64 714 715 # Build the image for the allocator service 716 build-allocator-image: build-allocator-image-amd64 717 ifeq ($(WITH_ARM64), 1) 718 build-allocator-image: build-allocator-image-arm64 719 endif 720 721 build-allocator-image-amd64: $(ensure-build-image) build-allocator-binary build-licenses build-required-src-dist 722 docker build $(agones_path)/cmd/allocator/ --tag=$(allocator_amd64_tag) $(DOCKER_BUILD_ARGS) 723 # creating docker builder and then using that builder to build allocator image in buildx command 724 build-allocator-image-arm64: $(ensure-build-image) build-allocator-binary create-arm64-builder 725 docker buildx build --provenance false $(agones_path)/cmd/allocator/ --builder $(BUILDX_ARM64_BUILDER) --tag=$(allocator_arm64_tag) --build-arg ARCH=arm64 --platform linux/arm64 $(DOCKER_BUILD_ARGS) 726 727 # push the processor image 728 build-processor-binary: $(ensure-build-image) build-processor-binary-linux-amd64 729 ifeq ($(WITH_ARM64), 1) 730 build-processor-binary: build-processor-binary-linux-arm64 731 endif 732 733 build-processor-binary-linux-amd64: $(ensure-build-image) 734 $(GO_BUILD_LINUX_AMD64) \ 735 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/processor/bin/processor.linux.amd64 \ 736 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/processor 737 build-processor-binary-linux-arm64: $(ensure-build-image) 738 $(GO_BUILD_LINUX_ARM64) \ 739 -tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/processor/bin/processor.linux.arm64 \ 740 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/processor 741 742 # Build the image for the processor service 743 build-processor-image: build-processor-image-amd64 744 ifeq ($(WITH_ARM64), 1) 745 build-processor-image: build-processor-image-arm64 746 endif 747 748 build-processor-image-amd64: $(ensure-build-image) build-processor-binary build-licenses build-required-src-dist 749 docker build $(agones_path)/cmd/processor/ --tag=$(processor_amd64_tag) $(DOCKER_BUILD_ARGS) 750 # creating docker builder and then using that builder to build processor image in buildx command 751 build-processor-image-arm64: $(ensure-build-image) build-processor-binary create-arm64-builder 752 docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/processor/ --tag=$(processor_arm64_tag) $(DOCKER_BUILD_ARGS) 753 754 # Pushes up the processor image 755 push-processor-image: push-processor-image-amd64 756 ifeq ($(WITH_ARM64), 1) 757 push-processor-image: push-processor-image-arm64 758 endif 759 # Docker >=24.0.6 760 docker buildx imagetools create --tag $(processor_tag) $(push_processor_manifest) 761 762 push-processor-image-amd64: build-processor-image-amd64 763 docker push $(processor_amd64_tag) 764 push-processor-image-arm64: build-processor-image-arm64 765 $(MAKE) DOCKER_BUILD_ARGS=--push build-processor-image-arm64 766 767 # push the gameservers sidecar image 768 push-agones-sdk-image: push-agones-sdk-linux-image-amd64 769 ifeq ($(WITH_WINDOWS), 1) 770 push-agones-sdk-image: push-agones-sdk-windows 771 endif 772 ifeq ($(WITH_ARM64), 1) 773 push-agones-sdk-image: push-agones-sdk-linux-image-arm64 774 endif 775 $(MAKE) push-agones-sdk-manifest 776 777 push-agones-sdk-manifest: 778 docker manifest create --amend $(sidecar_tag) $(push_sidecar_manifest) 779 $(MAKE) push_windows_manifest 780 docker manifest push --purge $(sidecar_tag) 781 782 push_windows_manifest: 783 ifeq ($(WITH_WINDOWS), 1) 784 for osversion in $(WINDOWS_VERSIONS); do \ 785 full_version=`docker manifest inspect ${BASE.windows}:$$osversion | grep "os.version" | head -n 1 | awk -F\" '{print $$4}'` || true; \ 786 docker manifest annotate --os windows --arch amd64 --os-version $$full_version \ 787 $(sidecar_tag) $(sidecar_tag)-windows_amd64-$$osversion; \ 788 done 789 endif 790 791 push-agones-sdk-windows: WINDOWS_DOCKER_PUSH_ARGS=--push 792 push-agones-sdk-windows: build-agones-sdk-image-windows 793 794 push-agones-sdk-linux-image-arm64: $(ensure-build-image) 795 $(MAKE) DOCKER_BUILD_ARGS=--push build-agones-sdk-image-arm64 796 797 push-agones-sdk-linux-image-amd64: build-agones-sdk-image-amd64 798 docker push $(sidecar_linux_amd64_tag) 799 800 # Generate the Embedded CRD openapi 801 gen-embedded-openapi: $(ensure-build-image) 802 docker run --rm $(common_mounts) --workdir=$(mount_path)/build/scripts/k8s-export-openapi $(DOCKER_RUN_ARGS) $(build_tag) \ 803 go run -mod=mod ./main.go 804 805 # Generate the static install script 806 gen-install: $(ensure-build-image) 807 docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \ 808 'helm template agones-manual --namespace agones-system $(mount_path)/install/helm/agones \ 809 --set agones.controller.generateTLS=false \ 810 --set agones.allocator.generateTLS=false \ 811 --set agones.allocator.generateClientTLS=false \ 812 --set agones.crds.cleanupOnDelete=false \ 813 > $(mount_path)/install/yaml/install.yaml' 814 815 # Generate the client, conversions, deepcopy, and defaults code for our CustomResourceDefinition 816 gen-crd-code: $(ensure-build-image) 817 docker run --rm \ 818 $(common_mounts) -w $(workdir_path) $(build_tag) bash -c "\ 819 $(git_safe) && \ 820 /root/gen-crd-code.sh && \ 821 cd $(workdir_path)/pkg && goimports -w ." 822 823 # Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist) 824 # Can use DOCKER_RUN_ARGS for extra arguments. 825 shell: $(ensure-build-image) 826 docker run -it --rm \ 827 $(common_mounts) \ 828 -w $(workdir_path) \ 829 -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" \ 830 $(DOCKER_RUN_ARGS) \ 831 $(build_tag) bash -l 832 833 # run a container with pkgsite 834 pkgsite: 835 docker run -p 8888:8888 --rm $(common_mounts) -w $(workdir_path) \ 836 $(build_tag) pkgsite -http=":8888" . 837 838 # start cpu profiling pprof with a web ui 839 pprof-cpu-web: 840 docker run --rm -it --network=host $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) \ 841 go tool pprof -http :6061 http://localhost:6060 842 843 # start heap profiling 844 pprof-heap-web: 845 docker run --rm -it --network=host $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) \ 846 go tool pprof -http :6062 http://localhost:6060/debug/pprof/heap 847 848 # setup prometheus in the current cluster by default Persistent Volume Claims are requested. 849 setup-prometheus: PVC ?= true 850 setup-prometheus: PV_SIZE ?= 64Gi 851 setup-prometheus: SCRAPE_INTERVAL=30s 852 setup-prometheus: 853 $(DOCKER_RUN) helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 854 $(DOCKER_RUN) helm repo update 855 $(DOCKER_RUN) helm upgrade prom prometheus-community/prometheus --install --wait \ 856 --namespace metrics --create-namespace \ 857 --set server.global.scrape_interval=$(SCRAPE_INTERVAL),server.persistentVolume.enabled=$(PVC),server.persistentVolume.size=$(PV_SIZE) \ 858 $(HELM_ARGS) -f $(mount_path)/build/prometheus.yaml 859 860 uninstall-prometheus: $(ensure-build-image) 861 $(DOCKER_RUN) \ 862 helm uninstall prom --namespace=metrics 863 864 # setup grafana in the current cluster with datasource and dashboards ready for use with agones 865 # by default Persistent Volume Claims are requested. 866 setup-grafana: PVC ?= true 867 setup-grafana: PV_SIZE ?= 64Gi 868 setup-grafana: PASSWORD ?= admin 869 setup-grafana: 870 $(DOCKER_RUN) helm repo add grafana https://grafana.github.io/helm-charts 871 $(DOCKER_RUN) helm repo update 872 $(DOCKER_RUN) kubectl apply -f $(mount_path)/build/grafana/ 873 $(DOCKER_RUN) helm upgrade grafana grafana/grafana --install --wait \ 874 --namespace metrics --create-namespace \ 875 --set persistence.enabled=$(PVC),server.persistentVolume.size=$(PV_SIZE) \ 876 --set adminPassword=$(PASSWORD) $(HELM_ARGS) -f $(mount_path)/build/grafana.yaml 877 878 uninstall-grafana: $(ensure-build-image) 879 $(DOCKER_RUN) helm uninstall grafana --namespace=metrics 880 $(DOCKER_RUN) kubectl delete -f $(mount_path)/build/grafana/ 881 882 # setup prometheus-stack in the current cluster by default Persistent Volume Claims are requested. 883 setup-prometheus-stack: PVC ?= true 884 setup-prometheus-stack: PV_SIZE ?= 64Gi 885 setup-prometheus-stack: SCRAPE_INTERVAL=30s 886 setup-prometheus-stack: PASSWORD ?= admin 887 setup-prometheus-stack: 888 $(DOCKER_RUN) helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 889 $(DOCKER_RUN) helm repo update 890 $(DOCKER_RUN) helm upgrade prometheus-stack prometheus-community/kube-prometheus-stack --install --wait --version 19.0.2 \ 891 --namespace monitoring --create-namespace \ 892 --set prometheus.server.global.scrape_interval=$(SCRAPE_INTERVAL) \ 893 --set prometheus.server.persistentVolume.enabled=$(PVC) \ 894 --set prometheus.server.persistentVolume.size=$(PV_SIZE) \ 895 --set grafana.adminPassword=$(PASSWORD) \ 896 $(HELM_ARGS) -f $(mount_path)/build/prometheus-stack.yaml 897 898 uninstall-prometheus-stack: $(ensure-build-image) 899 $(DOCKER_RUN) \ 900 helm uninstall prometheus-stack --namespace=monitoring 901 902 helm-repo-update: 903 $(DOCKER_RUN) helm repo update 904 905 clean-test-cluster: $(ensure-build-image) $(uninstall) 906 907 install-custom-pull-secret: 908 # if IMAGE_PULL_SECRET_FILE is specified, create the agones-system namespace and install the secret 909 @if [ "$(IMAGE_PULL_SECRET_FILE)" != "" ]; then \ 910 echo "Creating agones-system namespace..." ;\ 911 $(DOCKER_RUN) kubectl create namespace agones-system; \ 912 echo "Installing secret $(IMAGE_PULL_SECRET_FILE) in agones-system namespace..."; \ 913 docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -v $(dir $(IMAGE_PULL_SECRET_FILE)):/root/secret $(DOCKER_RUN_ARGS) $(build_tag) \ 914 kubectl apply --namespace agones-system -f /root/secret/$(notdir $(IMAGE_PULL_SECRET_FILE)); \ 915 echo "Installing secret $(IMAGE_PULL_SECRET_FILE) in default namespace..."; \ 916 docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -v $(dir $(IMAGE_PULL_SECRET_FILE)):/root/secret $(DOCKER_RUN_ARGS) $(build_tag) \ 917 kubectl apply --namespace default -f /root/secret/$(notdir $(IMAGE_PULL_SECRET_FILE)); \ 918 fi 919 920 update-go-deps: 921 $(DOCKER_RUN) go get -u agones.dev/agones 922 $(DOCKER_RUN) go mod tidy 923 $(DOCKER_RUN) go mod vendor 924 925 test-gen-crd-code: 926 mkdir -p build/tmp/apis | mkdir -p build/tmp/client; \ 927 cp -r ../pkg/apis/* build/tmp/apis | cp -r ../pkg/client/* build/tmp/client; \ 928 make gen-crd-code; \ 929 $(MAKE) diff-directory DIRECTORY=apis 930 $(MAKE) diff-directory DIRECTORY=client 931 # Delete build/tmp if the directory is empty 932 if [ ! "$(ls -A build/tmp)" ]; then \ 933 echo "No differences found. Deleting empty directory build/tmp."; \ 934 rm -r build/tmp; \ 935 fi 936 937 diff-directory: 938 diff_output=$$(diff -bBr build/tmp/$(DIRECTORY) ../pkg/$(DIRECTORY)); \ 939 if [ -z "$$diff_output" ]; then \ 940 echo "No differences found. Deleting build/tmp/$(DIRECTORY)"; \ 941 rm -r build/tmp/$(DIRECTORY); \ 942 else \ 943 echo "Differences found."; \ 944 echo "$$diff_output"; \ 945 fi 946 947 install-release: $(ensure-build-image) 948 docker run -it --rm \ 949 $(common_mounts) \ 950 $(DOCKER_RUN_ARGS) \ 951 $(build_tag) /go/src/agones.dev/agones/build/install-release.sh 952 953 # Validates the Helm values.yaml file against the values.schema.json file. 954 helm-lint: 955 $(DOCKER_RUN) bash -c 'cd $(mount_path)/install/helm/agones && helm lint .'