From 9eae5ff16e91511cc79b7de7efc26bbe9efc8a06 Mon Sep 17 00:00:00 2001 From: nottagg Date: Mon, 26 Sep 2022 12:24:22 -0500 Subject: [PATCH] Separated listening ports into int and str --- Makefile | 7 +++++-- pkg/operator/Makefile | 2 +- pkg/operator/config/manager/manager.yaml | 10 +++++----- pkg/operator/main.go | 5 +++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d7971982..69cca6bc 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ NS ?= ghcr.io/playfab/ +LISTENINGPORT ?= 5005 export IMAGE_NAME_OPERATOR=thundernetes-operator export IMAGE_NAME_NODE_AGENT=thundernetes-nodeagent @@ -97,7 +98,8 @@ create-install-files: IMAGE_NAME_NODE_AGENT=$(NS)$(IMAGE_NAME_NODE_AGENT) \ IMAGE_NAME_NODE_AGENT_WIN=$(NS)$(IMAGE_NAME_NODE_AGENT_WIN) \ LOG_LEVEL=info \ - LISTENING_PORT=5000 \ + STR_LISTENING_PORT=\"$(LISTENINGPORT)\" \ + INT_LISTENING_PORT=$(LISTENINGPORT) \ make -C pkg/operator create-install-files create-install-files-dev: @@ -109,7 +111,8 @@ create-install-files-dev: IMAGE_NAME_NODE_AGENT=$(NS)$(IMAGE_NAME_NODE_AGENT) \ IMAGE_NAME_NODE_AGENT_WIN=$(NS)$(IMAGE_NAME_NODE_AGENT_WIN) \ LOG_LEVEL=debug \ - LISTENING_PORT=5000 \ + STR_LISTENING_PORT=\"$(LISTENINGPORT)\" \ + INT_LISTENING_PORT=$(LISTENINGPORT) \ make -C pkg/operator create-install-files clean: diff --git a/pkg/operator/Makefile b/pkg/operator/Makefile index 35598c40..71418f76 100644 --- a/pkg/operator/Makefile +++ b/pkg/operator/Makefile @@ -133,7 +133,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions -KUSTOMIZE_VERSION ?= v3.8.7 +KUSTOMIZE_VERSION ?= v4.5.7 CONTROLLER_TOOLS_VERSION ?= v0.9.0 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" diff --git a/pkg/operator/config/manager/manager.yaml b/pkg/operator/config/manager/manager.yaml index 6371dce8..41418d09 100644 --- a/pkg/operator/config/manager/manager.yaml +++ b/pkg/operator/config/manager/manager.yaml @@ -45,7 +45,7 @@ spec: - name: API_SERVICE_SECURITY value: ${API_SERVICE_SECURITY} - name: LISTENING_PORT - value: "${LISTENING_PORT}" #This is currently broken. After kustomize runs, double quotes are removed and can't be escaped + value: ${STR_LISTENING_PORT} - name: THUNDERNETES_INIT_CONTAINER_IMAGE value: ${IMAGE_NAME_INIT_CONTAINER}:${IMAGE_TAG} - name: THUNDERNETES_INIT_CONTAINER_IMAGE_WIN @@ -77,8 +77,8 @@ spec: cpu: 1000m memory: 500Mi ports: - - containerPort: ${LISTENING_PORT} - hostPort: ${LISTENING_PORT} + - containerPort: ${INT_LISTENING_PORT} + hostPort: ${INT_LISTENING_PORT} - containerPort: 8080 serviceAccountName: controller-manager terminationGracePeriodSeconds: 10 @@ -92,8 +92,8 @@ spec: control-plane: controller-manager ports: - protocol: TCP - port: ${LISTENING_PORT} - targetPort: ${LISTENING_PORT} + port: ${INT_LISTENING_PORT} + targetPort: ${INT_LISTENING_PORT} type: LoadBalancer --- apiVersion: v1 diff --git a/pkg/operator/main.go b/pkg/operator/main.go index 1f0d7f86..891cab15 100644 --- a/pkg/operator/main.go +++ b/pkg/operator/main.go @@ -60,9 +60,9 @@ type Config struct { LogLevel string `env:"LOG_LEVEL" envDefault:"info"` MinPort int32 `env:"MIN_PORT" envDefault:"10000"` MaxPort int32 `env:"MAX_PORT" envDefault:"12000"` + ListeningPort int32 `env:"LISTENING_PORT" envDefault:"5000"` InitContainerImageLinux string `env:"THUNDERNETES_INIT_CONTAINER_IMAGE,notEmpty"` InitContainerImageWin string `env:"THUNDERNETES_INIT_CONTAINER_IMAGE_WIN,notEmpty"` - ListeningPort int32 `env:"LISTENING_PORT" envDefault:"5000"` } var ( @@ -83,6 +83,7 @@ func main() { if err := env.Parse(cfg); err != nil { log.Fatal(err, "Cannot load configuration from environment variables") } + listeningPort := cfg.ListeningPort // load the rest of the configuration from command-line flags var metricsAddr string @@ -125,7 +126,7 @@ func main() { crt, key := getCrtKeyIfTlsEnabled(k8sClient, cfg) // initialize the allocation API service, which is also a controller. So we add it to the manager - aas := controllers.NewAllocationApiServer(crt, key, mgr.GetClient(), cfg.ListeningPort) + aas := controllers.NewAllocationApiServer(crt, key, mgr.GetClient(), int32(listeningPort)) if err = aas.SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create HTTP allocation API Server", "Allocation API Server", "HTTP Allocation API Server") os.Exit(1)