Skip to content

Commit

Permalink
Separated listening ports into int and str
Browse files Browse the repository at this point in the history
  • Loading branch information
nottagg committed Sep 26, 2022
1 parent 2a6cbae commit 9eae5ff
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

NS ?= ghcr.io/playfab/
LISTENINGPORT ?= 5005

export IMAGE_NAME_OPERATOR=thundernetes-operator
export IMAGE_NAME_NODE_AGENT=thundernetes-nodeagent
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions pkg/operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9eae5ff

Please sign in to comment.