Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to a game server using Docker Desktop (with integrated K8s cluster or Minikube) #1990

Closed
panicq opened this issue Feb 10, 2021 · 6 comments · Fixed by #2137
Closed
Labels
kind/bug These are bugs.
Milestone

Comments

@panicq
Copy link

panicq commented Feb 10, 2021

What happened:

I installed Agones using helm on the K8s cluster delivered with Docker Desktop (windows, using WLS2). My goal is to be able to test a local cluster on my dev machine (so no cloud).
I was able to integrate the SDK and start a game server correctly. I have the logs of the server and can see that the SDK is working. When I kubectl get gs I can see an IP and port and that the server status is READY

Unfortunately I cannot connect to this IP/Port from my game client (outside the cluster).

What you expected to happen:

To connect from my game client using the given ip/port (from a simple kubectl get gs).

How to reproduce it (as minimally and precisely as possible):
Install agones on docker desktop (WLS2) and follow the game server documentation page:
https://agones.dev/site/docs/getting-started/create-gameserver/
Or use your own server.

Anything else we need to know?:

Here is what I tried:

  • Connecting using host.docker.internal
  • Using minikube I was able to get to the same point on this cluster. I also tried connecting using the minkube ip
  • Starting the nodejs example from the website -> Failed to resolve ip/port...

Note that I'm able to connect to a standard UDP Loadbalancer Service with docker desktop, so in that case the IP/Port of the service is correctly exposed.

Environment: Local
Agones version: agones.dev/v1
Kubernetes version 1.19
Install method (yaml/helm): helm
Others: Docker Desktop on Windows with WLS2

@panicq panicq added the kind/bug These are bugs. label Feb 10, 2021
@markmandel
Copy link
Member

markmandel commented Feb 10, 2021

A not too shabby workaround if you are on Windows and the multiple layers of virtualistion make it hard to get a direct connection - you could create a Service just for local development to point to a specific GameServer instance, like so, basically to act as a traffic tunnel for local development:

apiVersion: v1
kind: Service
metadata:
  name: agones-gameserver
spec:
  type: LoadBalancer
  selector:
    agones.dev/gameserver: ${GAMESERVER_NAME}
  ports:
  - protocol: UDP
    port: 7000 # local port
    targetPort: ${GAMESERVER_CONTAINER_PORT}

If you want to connect to a different GameServer, kubectl edit service agones-gameserver and edit the ${GAMESERVER_NAME} value to point to the new GameServer instance and/or the ${GAMESERVER_CONTAINER_PORT} value, if it had changed (most likely it probably won't I expect).

@jgramoll
Copy link

jgramoll commented May 1, 2021

@markmandel I'm trying to use your solution of using a kubernetes Service, but still not working for me. How did you connect to the Service after you created it? I tried connecting to all combinations of Service cluster-ip, external-ip, port, nodeport.

@markmandel
Copy link
Member

markmandel commented May 4, 2021

@markmandel I'm trying to use your solution of using a kubernetes Service, but still not working for me. How did you connect to the Service after you created it? I tried connecting to all combinations of Service cluster-ip, external-ip, port, nodeport.

Each local K8s has a way to lookup the local ip and port of the service as described above.

From there it was a case of connecting to that address.

https://minikube.sigs.k8s.io/docs/handbook/accessing/

I'm on Linux, so don't have access to Docker Desktop, but the same technique should work.

https://medium.com/@lizrice/accessing-an-application-on-kubernetes-in-docker-1054d46b64b1

I assume this would still work as described.

@DanMo9
Copy link

DanMo9 commented May 22, 2021

Any updates on this issue? Without this it makes developing with Agones much harder locally.

Is the only solution to we have to manually edit this service to expose the port?

Do you have any idea if this is a Minikube issue or an Agones issue?

@markmandel
Copy link
Member

Any updates on this issue? Without this it makes developing with Agones much harder locally.

Is the only solution to we have to manually edit this service to expose the port?

Do you have any idea if this is a Minikube issue or an Agones issue?

If the local K8s environment doesn't provide a way to connect directly to the node and hostPost, there isn't much we can do on our end.

See: https://minikube.sigs.k8s.io/docs/handbook/accessing/

If you can find workarounds that are a better fit than the above, please provide them -- PRs on documentation are always appreciated.

@aLekSer
Copy link
Collaborator

aLekSer commented May 25, 2021

Slightly different answer to the topic, but still someone might be interested.
There was a need to move out heavy kind image burden from Mac to speed up development (in the absence of GKE).
I was checking what my old PC can provide. I set up Docker desktop on windows, opened port for Docker. And was able to run Kind from other laptop which was MacOS. Part of the E2E tests was working fine with this setup.

By the way was also checking Agones install with K3D:

export DOCKER_HOST=tcp://192.168.<YourIP>:2375
 k3d cluster create mycluster

markmandel added a commit to markmandel/agones that referenced this issue Jun 17, 2021
This includes:
* Correct commands for the newer versions of minikube
* Guidance on increasing cpu and/or memory as needed
* Workarounds if one can't connect locally to a GameServer

Closes googleforgames#1536
Closes googleforgames#1990
roberthbailey pushed a commit that referenced this issue Jun 17, 2021
This includes:
* Correct commands for the newer versions of minikube
* Guidance on increasing cpu and/or memory as needed
* Workarounds if one can't connect locally to a GameServer

Closes #1536
Closes #1990
@roberthbailey roberthbailey added this to the 1.16.0 milestone Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug These are bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants