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

Update simple game server example documentation #3776

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions site/content/en/docs/Getting Started/edit-first-gameserver-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Change the following line in `main.go`:

From:
```go
respond(conn, sender, "ACK: "+txt+"\n")
response = "ACK TCP: " + response + "\n"
```

To:
```go
respond(conn, sender, "ACK: Echo says "+txt+"\n")
response = "ACK TCP Echo Says: " + response + "\n"
```

### Build Server
Expand All @@ -49,16 +49,9 @@ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bin/server -a -v main.go

## Using Docker File

### Create a new docker image
### Create a new docker image and push the image to GCP Registry
```bash
docker build -t gcr.io/[PROJECT_ID]/agones-simple-game-server:modified .
```

Note: you can change the image name "agones-simple-game-server" to something else.

### If using GKE, push the image to GCP Registry
```bash
docker push gcr.io/[PROJECT_ID]/agones-simple-game-server:modified
make WITH_WINDOWS=0 WITH_ARM64=0 REPOSITORY={$REGISTRY} push
```

Note: Review [Authentication Methods](https://cloud.google.com/container-registry/docs/advanced-authentication)
Expand All @@ -76,8 +69,8 @@ Modify the following line from gameserver.yaml to use the new configuration.
```yaml
spec:
containers:
- name: agones-simple-game-server
image: gcr.io/[PROJECT_ID]/agones-simple-game-server:modified
- name: simple-game-server
image: ${REGISTRY}/simple-game-server:${TAG}
```

### If using GKE, deploy Server to GKE
Expand All @@ -86,7 +79,7 @@ Apply the latest settings to the Kubernetes container.
```bash
gcloud config set container/cluster [CLUSTER_NAME]
gcloud container clusters get-credentials [CLUSTER_NAME]
kubectl apply -f gameserver.yaml
kubectl create -f gameserver.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think apply should work - why change to create?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always ran into the following issue error: from simple-game-server-: cannot use generate name with apply and turns out that kubectl apply doesn't support generateName. Found some old random issues about it, tektoncd/pipeline#2170, kubernetes/kubernetes#44501 and argoproj/argo-cd#1639. The workaround is to use kubectl create -f.

```

### If using Minikube, deploy the Server to Minikube
Expand All @@ -103,7 +96,7 @@ kubectl describe gameserver
Let's retrieve the IP address and the allocated port of your Game Server:

```bash
kubectl get gs simple-game-server -o jsonpath='{.status.address}:{.status.ports[0].port}'
kubectl get gs -o jsonpath='{.items[0].status.address}:{.items[0].status.ports[0].port}'
```

You can now communicate with the Game Server :
Expand All @@ -117,7 +110,7 @@ If you do not have netcat installed
```
nc -u {IP} {PORT}
Hello World!
ACK: Echo says Hello World!
ACK TCP: Echo says Hello World!
EXIT
```

Expand Down
Loading