googleforgames / agones

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

Can't connect to the game server example using minikube #3220

Open needmorecode opened 1 year ago

needmorecode commented 1 year ago

I tried to build the agones environment by following the official guide steps, but I can't connect to the game server using minikube. Here are the details.

At first, I tried to connect to the game server directly.

kubectl get gs
NAME                             STATE       ADDRESS        PORT   NODE       AGE
simple-game-server-kj67x-2xgq8   Ready       192.168.49.2   7532   minikube   63m
kubectl get pods
NAME                              READY   STATUS    RESTARTS        AGE
simple-game-server-kj67x-2xgq8    2/2     Running   0               67m

But connecting to the server using nc got no response.

nc -u 192.168.49.2 7532
Hello World!

Then I tried to connect to the server by service, as the guide suggests.

The service yaml is like this:

apiVersion: v1
kind: Service
metadata:
  name: agones-gameserver
spec:
  type: LoadBalancer
  selector:
    agones.dev/gameserver: simple-game-server-kj67x-2xgq8
  ports:
  - protocol: UDP
    port: 7001 # local port
    targetPort: 7654
kubectl get services
NAME                TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
agones-gameserver   LoadBalancer   10.96.60.254   <pending>     7001:31974/UDP   3m57s

Still no response was received.

nc -u 10.96.60.254 7001
Hello World!

Would anyone please give me a clue on this? By the way, my computer is Mac M1, and the minikube driver I used was Docker.

needmorecode commented 1 year ago

Also I tried using the Google Cloud. gcloud container clusters create agones-cluster --region=us-west1 --release-channel=regular --tags=game-server --scopes=gke-default --num-nodes=2 --enable-image-streaming --machine-type=e2-medium --disk-size=10 But I got the error message. "Instance 'gke-agones-cluster-default-pool-91a9459a-gg5p' creation failed: Quota 'IN_USE_ADDRESSES' exceeded. Limit: 4.0 in region us-east1."

I used the gcloud trial accout with 300$. Does the error means I have to pay to increase the quota?

markmandel commented 1 year ago

For minikube, did you follow some of the suggestions on connectivity at https://agones.dev/site/docs/installation/creating-cluster/minikube/ ?

Minikube can be tricky, just because of VM's inside of VMs. It's possible they have changed things there as well.

Re: Quota on Google Cloud - check the Quota page. You may have more quota in a different region - also don't forget the firewall settings!

mmsdocs commented 1 year ago

Hello guys, I'm having same problem with my local environment. While I was debbuging I noticed that all specs defined on my custom gameserver.yaml was setted on Pause Container created by kubernetes. Is that a expected behavior?

gameserver.yaml

apiVersion: "agones.dev/v1"
kind: GameServer
metadata:
  name: "name-gameserver"
spec:
  container: server
  ports:
    - name: default-tcp-udp
      # portPolicy: Static
      container: server
      containerPort: 7005
      # hostPort: 7005
      protocol: TCPUDP
  health:
    initialDelaySeconds: 20
    periodSeconds: 7
    failureThreshold: 3
  template:
    spec:
      containers:
        - name: server
          image: name/server:latest
          imagePullPolicy: Never

Labels of Game Server Container (Created by Agones using my local image) Captura de tela 2023-06-26 104410

Inspect from Pause Container (Created by K8s) Captura de tela 2023-06-26 104617 Captura de tela 2023-06-26 104634 Captura de tela 2023-06-26 104651

I tried to use Docker Desktop with Kubernetes Cluster, and the behavior is the same.

Software versions on my PC:

markmandel commented 1 year ago

@mmsdocs did you follow some of the suggestions on connectivity at https://agones.dev/site/docs/installation/creating-cluster/minikube/ ?

Also, since you are running your own container, have you tried any of the https://agones.dev/site/docs/guides/troubleshooting/ steps?

mmsdocs commented 1 year ago

I finally managed to use the load-balancer to expose the Game Server Ports to local Client. I was using the 'port' and 'targetPort' fields on wrong way.

cBournhonesque commented 6 months ago

I cannot get it working either: My gameserver:

image

My service.yaml:

image

I also ran minikube tunnel.

If I run minikube service list -p agones I don't get anything in the URL field:

image
markmandel commented 6 months ago

Same question as above @cBournhonesque , would be good to know.

did you follow some of the suggestions on connectivity at https://agones.dev/site/docs/installation/creating-cluster/minikube/ ?

Also, since you are running your own container, have you tried any of the https://agones.dev/site/docs/guides/troubleshooting/ steps?

ashutosji commented 5 months ago

I gone through minikube documentation and install Agones on minikube cluster. For me, everything was work very smoothly and i didn't face any issue.

These are the steps that i followed:

  1. minikube start --kubernetes-version v1.27.6 -p agones

😄 [agones] minikube v1.32.0 on Debian rodete (amd64) ✨ Automatically selected the docker driver 📌 Using Docker driver with root privileges 👍 Starting control plane node agones in cluster agones 🔥 Creating docker container (CPUs=2, Memory=16000MB) ... 🐳 Preparing Kubernetes v1.27.6 on Docker 24.0.7 ... 🔗 Configuring bridge CNI (Container Networking Interface) ... 🏄 Done! kubectl is now configured to use "agones" cluster and "default" namespace by default

  1. Installed Agones using helm: helm install my-release --namespace agones-system --create-namespace agones/agones
  2. Got an IP and Port to connect locally using this command: minikube service list -p agones
    |---------------|-----------------------------------|--------------|---------------------------|
    |   NAMESPACE   |               NAME                | TARGET PORT  |            URL            |
    |---------------|-----------------------------------|--------------|---------------------------|
    | agones-system | agones-allocator                  | https/443    | http://192.168.49.2:32431 |
    | agones-system | agones-allocator-metrics-service  | No node port |                           |
    | agones-system | agones-controller-metrics-service | No node port |                           |
    | agones-system | agones-controller-service         | No node port |                           |
    | agones-system | agones-extensions-metrics-service | No node port |                           |
    | agones-system | agones-ping-http-service          | http/80      | http://192.168.49.2:31667 |
    | agones-system | agones-ping-udp-service           | udp/50000    | http://192.168.49.2:32608 |
    | default       | kubernetes                        | No node port |                           |
    | kube-system   | kube-dns                          | No node port |                           |
    |---------------|-----------------------------------|--------------|---------------------------|
  3. Created GameServer by following this official docs: https://agones.dev/site/docs/getting-started/create-gameserver/#1-create-a-gameserver and got the GameGerver using this command:
    kubectl get gs
    NAME                       STATE       ADDRESS        PORT   NODE     AGE
    simple-game-server-t9svt   Ready   192.168.49.2   7190   agones   6s
  4. Described the GameServer using this command: kubectl describe gameserver
    Ports:
    Container:       simple-game-server
    Container Port:  7654
    Host Port:       7082
    Name:            default
    Port Policy:     Dynamic
    Protocol:        UDP
    Scheduling:        Packed
    Sdk Server:
    Grpc Port:  9357
    Http Port:  9358
    Log Level:  Info
  5. Connected with GameServer using netcat: nc -u ip port

Those who are facing issue while working with minikube, please follow the documentation of minikube and the troubleshoot guide and if you're still facing the the issue. Feel free to update this issue, we will definitely assist you.

github-actions[bot] commented 3 weeks ago

'This issue is marked as Stale due to inactivity for more than 30 days. To avoid being marked as 'stale' please add 'awaiting-maintainer' label or add a comment. Thank you for your contributions '