diff --git a/cmd/e2e/utilities_test.go b/cmd/e2e/utilities_test.go index a6cf5649..4a067e5a 100644 --- a/cmd/e2e/utilities_test.go +++ b/cmd/e2e/utilities_test.go @@ -42,6 +42,7 @@ const ( timeout = time.Second * 30 interval = time.Millisecond * 250 thundernetesSystemNamespace = "thundernetes-system" + testNodeCount = 3 ) type AllocationResult struct { @@ -97,8 +98,8 @@ func validateThatAllocatedServersHaveReadyForPlayersUnblocked(ctx context.Contex return err } - if len(nodeAgentPodList.Items) != 3 { - return fmt.Errorf("expected 3 NodeAgent Pods, got %d", len(nodeAgentPodList.Items)) + if len(nodeAgentPodList.Items) != testNodeCount { + return fmt.Errorf("expected %d NodeAgent Pods, got %d", testNodeCount, len(nodeAgentPodList.Items)) } for _, gameServer := range activeGameServers { diff --git a/cmd/gameserverapi/deploy/e2e/nodeselector.yaml b/cmd/gameserverapi/deploy/e2e/nodeselector.yaml deleted file mode 100644 index da95e008..00000000 --- a/cmd/gameserverapi/deploy/e2e/nodeselector.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# this YAML file, when used with kustomize, it adds the nodeSelector field to the controller deployment -# it's used in e2e tests, so that the controller is scheduled on a different Node than the GameServer Pods -apiVersion: apps/v1 -kind: Deployment -metadata: - name: thundernetes-gameserverapi - namespace: thundernetes-system -spec: - template: - spec: - nodeSelector: - kubernetes.io/hostname: kind-worker \ No newline at end of file diff --git a/cmd/gameserverapi/deploy/default/deploy.yaml b/cmd/gameserverapi/deployment/default/deploy.yaml similarity index 95% rename from cmd/gameserverapi/deploy/default/deploy.yaml rename to cmd/gameserverapi/deployment/default/deploy.yaml index 1a989f35..4fc1c11d 100644 --- a/cmd/gameserverapi/deploy/default/deploy.yaml +++ b/cmd/gameserverapi/deployment/default/deploy.yaml @@ -16,7 +16,7 @@ spec: app: thundernetes-gameserverapi spec: containers: - - image: thundernetes-gameserverapi + - image: thundernetes-gameserverapi:${IMAGE_TAG} name: gameserverapi imagePullPolicy: IfNotPresent resources: diff --git a/cmd/gameserverapi/deploy/default/kustomization.yaml b/cmd/gameserverapi/deployment/default/kustomization.yaml similarity index 100% rename from cmd/gameserverapi/deploy/default/kustomization.yaml rename to cmd/gameserverapi/deployment/default/kustomization.yaml diff --git a/cmd/gameserverapi/deploy/e2e/kustomization.yaml b/cmd/gameserverapi/deployment/e2e/kustomization.yaml similarity index 100% rename from cmd/gameserverapi/deploy/e2e/kustomization.yaml rename to cmd/gameserverapi/deployment/e2e/kustomization.yaml diff --git a/cmd/gameserverapi/deployment/e2e/nodeselector.yaml b/cmd/gameserverapi/deployment/e2e/nodeselector.yaml new file mode 100644 index 00000000..8f39ac84 --- /dev/null +++ b/cmd/gameserverapi/deployment/e2e/nodeselector.yaml @@ -0,0 +1,13 @@ +# When this YAML file is used with kustomize, it adds the nodeSelector field to the controller deployment +# It's used in e2e tests, so that the gameserverapi is scheduled on a specific Node, so that we can do the +# listening service port forwarding (5001) correctly +apiVersion: apps/v1 +kind: Deployment +metadata: + name: thundernetes-gameserverapi + namespace: thundernetes-system +spec: + template: + spec: + nodeSelector: + kubernetes.io/hostname: kind-worker \ No newline at end of file diff --git a/e2e/run.sh b/e2e/run.sh index f1582d7c..c595d65c 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -47,9 +47,8 @@ echo "-----Compiling, building and deploying the operator to local Kubernetes cl IMG=${IMAGE_NAME_OPERATOR}:${IMAGE_TAG} API_SERVICE_SECURITY=usetls make -C "${DIR}"/../pkg/operator deploye2e echo "-----Deploying GameServer API-----" -cd cmd/gameserverapi/deploy/default -"${DIR}"/../pkg/operator/bin/kustomize edit set image thundernetes-gameserverapi=thundernetes-gameserverapi:${IMAGE_TAG} -"${DIR}"/../pkg/operator/bin/kustomize build ../e2e | kubectl apply -f - +cd cmd/gameserverapi/deployment/default +"${DIR}"/../pkg/operator/bin/kustomize build ../e2e | IMAGE_TAG=${IMAGE_TAG} envsubst | kubectl apply -f - echo "-----Waiting for Controller deployment-----" kubectl wait --for=condition=available --timeout=300s deployment/thundernetes-controller-manager -n thundernetes-system diff --git a/pkg/operator/Makefile b/pkg/operator/Makefile index f8119f29..72dd7405 100644 --- a/pkg/operator/Makefile +++ b/pkg/operator/Makefile @@ -84,7 +84,6 @@ docker-push: ## Push docker image with the manager. .PHONY: create-install-files create-install-files: - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} ## Create install files for thundernetes installed without API security $(KUSTOMIZE) build config/default | API_SERVICE_SECURITY=none envsubst > ${INSTALL_FILES_FOLDER}/operator.yaml ## Create install files for thundernetes installed with API security @@ -111,12 +110,10 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified .PHONY: deploy deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} $(KUSTOMIZE) build config/default | envsubst | kubectl apply -f - .PHONY: deploye2e deploye2e: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} $(KUSTOMIZE) build config/e2e | envsubst | kubectl apply -f - .PHONY: undeploy diff --git a/pkg/operator/config/e2e/nodeselector.yaml b/pkg/operator/config/e2e/nodeselector.yaml index 5a78d9df..b33e9db3 100644 --- a/pkg/operator/config/e2e/nodeselector.yaml +++ b/pkg/operator/config/e2e/nodeselector.yaml @@ -1,5 +1,6 @@ -# this YAML file, when used with kustomize, it adds the nodeSelector field to the controller deployment -# it's used in e2e tests, so that the controller is scheduled on a different Node than the GameServer Pods +# When this YAML file is used with kustomize, it adds the nodeSelector field to the controller deployment +# It's used in e2e tests, so that the controller is scheduled on a specific Node, so that we can do the +# allocation API service port forwarding (5000) correctly apiVersion: apps/v1 kind: Deployment metadata: diff --git a/pkg/operator/config/manager/kustomization.yaml b/pkg/operator/config/manager/kustomization.yaml index ba65f4ce..c427e413 100755 --- a/pkg/operator/config/manager/kustomization.yaml +++ b/pkg/operator/config/manager/kustomization.yaml @@ -6,9 +6,3 @@ configMapGenerator: - files: - controller_manager_config.yaml name: manager-config -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: ghcr.io/playfab/thundernetes-operator - newTag: 0.4.1 diff --git a/pkg/operator/config/manager/manager.yaml b/pkg/operator/config/manager/manager.yaml index 2bdf8f38..31f9080e 100644 --- a/pkg/operator/config/manager/manager.yaml +++ b/pkg/operator/config/manager/manager.yaml @@ -33,7 +33,7 @@ spec: - /manager args: - --leader-elect - image: controller:latest + image: ${IMG} imagePullPolicy: IfNotPresent env: - name: MIN_PORT