PlayFab / thundernetes

Thundernetes makes it easy to run your game servers on Kubernetes
https://playfab.github.io/thundernetes
Apache License 2.0
307 stars 46 forks source link

Configurable Allocation API Port #419

Closed nottagg closed 1 year ago

nottagg commented 1 year ago

fixes #379

Did not get this in time for the hackathon so I'll have to settle with it being my first real OSS PR instead. Never worked with Go or K8s so if there's some unclean code, I can adjust it as needed.

Changes:

Kustomize is moving away from env variables (see - https://github.com/kubernetes-sigs/kustomize/issues/3485 ) and there was an issue with kustomize removing double quotes when replacing variables in the yaml. The workaround in this PR is sending the env variable as both a string and integer (9eae5ff16e91511cc79b7de7efc26bbe9efc8a06). It might be worth exploring revamping the kustomization.yaml files in the future.

ghost commented 1 year ago

CLA assistant check
All CLA requirements met.

nottagg commented 1 year ago

Closes #392 I also upped the version of kustomize as it made things a lot faster (and while I was trying to trouble shoot the double quote issue). After looking over #392 this PR should close it as I pushed up the new installfiles

dgkanatsios commented 1 year ago

@nottagg thanks for the PR and sorry we haven't yet taken a look at it. Promise that I'll do it soon, thanks for understanding!

dgkanatsios commented 1 year ago

@nottagg apologies again for the delay. I really am not a fan of injecting both the integer and the string form of the port, have spent all day trying to find an alternative. FWIW, the problem is not with kustomize env variables, we are not using them. What we use is envsubst to replace the env values in the YAML files. envsubst (or the shell? not 100% sure about that) unfortunately replaces the entire "${ENV_NAME}" removing the double quotes. Will continue looking for an alternative. At the same, we can always replace the value 5000 with a port that does not collide with any known apps. Thanks again, appreciate the hard work in this!

dgkanatsios commented 1 year ago

Now that I think about it though, an alternative solution would be NOT to define the port in the Makefile. We can do something like that on the pkg/operator/config/manager/manager.yaml file:

# rest of YAML file...
 - name: ALLOC_API_SVC_PORT
    value: "5000"
  - name: TLS_SECRET_NAMESPACE
    valueFrom:
      fieldRef:
        fieldPath: metadata.namespace
name: manager
securityContext:
  allowPrivilegeEscalation: false
livenessProbe:
  httpGet:
    path: /healthz
    port: 8081
  initialDelaySeconds: 15
  periodSeconds: 20
readinessProbe:
  httpGet:
    path: /readyz
    port: 8081
  initialDelaySeconds: 5
  periodSeconds: 10
resources:
  requests:
    cpu: 100m
    memory: 500Mi
  limits:
    cpu: 1000m
    memory: 500Mi
ports:
  - containerPort: 5000
    hostPort: 5000
# rest of YAML file...

People that use the port 5000 can manually change it on this file. Agreed, it's more cumbersome than customizing directly but I think it partially solves the problem. Can we do it this way? Left some more comments as well. Thanks again!

nottagg commented 1 year ago

Hi Dimitris. No problem with the delay! I'm just happy to be a part of a OSS project I thoroughly enjoy. Thanks for all of the feedback!

dgkanatsios commented 1 year ago

thank you!

dgkanatsios commented 1 year ago

ping @nottagg, we'd like to push 0.6 next week and we'd love to include your changes!

dgkanatsios commented 1 year ago

hey @nottagg, thanks again for working on this! Let me know when it's ready to review again

dgkanatsios commented 1 year ago

thanks @nottagg!