googleforgames / agones

Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
https://agones.dev
Apache License 2.0
6.05k stars 801 forks source link

How to connect gameserver that has no container port on it. #3024

Closed portlek closed 1 year ago

portlek commented 1 year ago

So basically, i'm creating a Minecraft server which has Proxies and also gameplay servers. I don't want to expose gameplay servers to players but proxies do. Proxies are registering gameplay servers internally to move the player whenever it connects to the proxy. My gameserver fleet yaml looks like this:

apiVersion: agones.dev/v1
kind: Fleet
metadata:
  name: hub-fleet
  namespace: minecraft
spec:
  replicas: 2
  scheduling: Packed
  template:
    spec:
      ports:
        - name: minecraft-port
          containerPort: 25565 // I want to make this port only accessible within the kubernetes network like ClusterIp type service.
          protocol: TCP
      template:
        spec:
          serviceAccountName: minecraft-account
          containers:
            - name: hub-gameserver
              image: MY_IMAGE

I know 'ports' is nullable since 1.30.0 (i guess?) but when i remove the ports, how i supposed to send people to this gameplay server? Or if there is a way to make the port something like 'ClusterIp' rather than like a NodeIp would be great too.

I've tried to create a new container port within the gameserver pod, i guess kubernetes does not allow that.

aimuz commented 1 year ago

The ports part fill in the ports you want to expose. If your game service wants to be exposed through the proxy service, you should fill in the ports of the proxy in ports. You can run multiple containers in one pod.

Take for example

apiVersion: agones.dev/v1
kind: Fleet
metadata:
  name: hub-fleet
  namespace: minecraft
spec:
  replicas: 2
  scheduling: Packed
  template:
    spec:
      ports:
        - name: proxy-port
          containerPort: 1234
          protocol: TCP
      template:
        spec:
          serviceAccountName: minecraft-account
          containers:
            - name: proxy # port: 1234
              image: MY_IMAGE
            - name: hub-gameserver #  port: 25565
              image: MY_IMAGE
portlek commented 1 year ago

interesting concept but proxy and hub are separate servers, proxies will be like 2 or 3 but hub servers will be like 10-20 so i don't want to combine these two gameserver types. it's not like 1 proxy server for 1 hub server. it's like all proxy servers will manage all gameservers.

markmandel commented 1 year ago

Several options:

  1. Don't open the firewall to the allocated range for Agones to the nodes. Then you can use the addresses provided by Agones.
  2. Traffic within the cluster between pods is unrestricted - you just need a DNS or the internal IP of the backing Pod to send the data to. a. If you want to access a GameServer by stable DNS: https://agones.dev/site/docs/reference/gameserver/#stable-network-id
  3. Have you seen: https://github.com/saulmaldonado/agones-minecraft
portlek commented 1 year ago

Thanks for the info, will take a look at 1. and 2. options and try. 3. option is not for me since i use custom dedicated servers.

markmandel commented 1 year ago

I'm going to close this now as I think this question is answered.