-
Notifications
You must be signed in to change notification settings - Fork 799
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
Custom Controller Example Page on Agones Website #3725
Merged
Merged
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5aa9712
Custom Controller Example Page on Agones Website
Kalaiselvi84 1e0a881
remove \n
Kalaiselvi84 9c59d9a
Review changes
Kalaiselvi84 26e96eb
modify docs
Kalaiselvi84 aba9d67
modify docs
Kalaiselvi84 5b95402
Merge branch 'main' into cc-docs
Kalaiselvi84 0a875de
Review changes
Kalaiselvi84 8d07715
Merge branch 'main' into cc-docs
Kalaiselvi84 6639538
Include example code link
Kalaiselvi84 f67ccee
Merge branch 'main' into cc-docs
Kalaiselvi84 9e56a12
changes based on the review suggestion
Kalaiselvi84 0ddf43c
update create custom controller section
Kalaiselvi84 73df972
branch update
Kalaiselvi84 90227c6
Merge branch 'main' into cc-docs
Kalaiselvi84 cffcb76
tweak
Kalaiselvi84 d2b0da8
apply suggested changes
Kalaiselvi84 9c49ce4
Merge branch 'main' into cc-docs
Kalaiselvi84 f7c0672
Merge branch 'main' into cc-docs
markmandel 7a88ceb
Merge branch 'main' into cc-docs
agones-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Custom Controller for Agones Game Servers | ||
|
||
This is an example of how to write a customer controller integrated with Agones resources. | ||
|
||
This example shows how to create, deploy and run a Custom Kubernetes Controller for Agones that logs changes to GameServers and modifies their labels. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
title: "Custom Controller for Agones Game Servers" | ||
linkTitle: "Custom Controller" | ||
date: | ||
publishDate: | ||
description: > | ||
This Custom Controller example shows how to create, deploy and run a Custom Kubernetes Controller for Agones that logs changes to GameServers and modifies their labels. | ||
--- | ||
|
||
markmandel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Prerequisite | ||
|
||
To get started, ensure the following prerequisites are met: | ||
|
||
- You have a running Kubernetes cluster. | ||
|
||
- Agones is installed on your cluster. Refer [Agones guide](https://agones.dev/site/docs/installation/install-agones/). | ||
|
||
- (Optional) Review {{< ghlink href="examples/custom-controller" >}}Custom Controller code{{< /ghlink >}} to see the details of this example. | ||
|
||
## Create a Custom Controller | ||
|
||
Let's create a custom controller on your cluster using the following command: | ||
|
||
```bash | ||
kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/custom-controller/deployment.yaml | ||
``` | ||
|
||
When you run this command, it quickly sets up your controller by doing four things: | ||
- Creating a service account for secure communication with Kubernetes | ||
- Defining a role with the right permissions to handle game servers and events | ||
- Linking this role to the account for broad access | ||
- Launching two controllers for reliability. | ||
Kalaiselvi84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Verify the Controller | ||
|
||
To ensure the custom controller is operational, execute the following command. You should see two instances of the controller actively running with the prefix `custom-controller`: | ||
|
||
```bash | ||
kubectl get pods -n agones-system | ||
``` | ||
Kalaiselvi84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You should see a successful output similar to this: | ||
|
||
``` | ||
NAME READY STATUS RESTARTS AGE | ||
custom-controller-74c798cfd8-ld6wk 1/1 Running 0 84s | ||
custom-controller-74c798cfd8-whpp2 1/1 Running 0 84s | ||
``` | ||
|
||
## Create a Fleet | ||
|
||
Let's create a Fleet using the following command: | ||
|
||
```bash | ||
kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/simple-game-server/fleet.yaml | ||
``` | ||
|
||
You should see a successful output similar to this : | ||
|
||
``` | ||
fleet.agones.dev/simple-game-server created | ||
``` | ||
|
||
This has created a Fleet record inside Kubernetes, which in turn creates two warm [GameServers]({{< ref "/docs/Reference/gameserver.md" >}}) | ||
Kalaiselvi84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
that are available to be allocated for a game session. | ||
|
||
```bash | ||
kubectl get fleet | ||
``` | ||
It should look something like this: | ||
|
||
``` | ||
NAME SCHEDULING DESIRED CURRENT ALLOCATED READY AGE | ||
simple-game-server Packed 2 3 0 2 9m | ||
``` | ||
|
||
You can also see the GameServers that have been created by the Fleet by running `kubectl get gameservers`, | ||
the GameServer will be prefixed by `simple-game-server`. | ||
|
||
``` | ||
NAME STATE ADDRESS PORT NODE AGE | ||
simple-game-server-llg4x-rx6rc Ready 192.168.122.205 7752 minikube 9m | ||
simple-game-server-llg4x-v6g2r Ready 192.168.122.205 7623 minikube 9m | ||
``` | ||
|
||
For the full details of the YAML file head to the [Fleet Specification Guide]({{< ref "/docs/Reference/fleet.md" >}}) | ||
|
||
{{< alert title="Note" color="info">}} The game servers deployed from a `Fleet` resource will be deployed in the same namespace. The above example omits specifying a namespace, which implies both the `Fleet` and the associated `GameServer` resources will be deployed to the `default` namespace. {{< /alert >}} | ||
|
||
## Monitor the log events for the custom controller pod | ||
|
||
To monitor the log events of the custom controller pod during the creation, modification, and deletion of game servers, use the following command: | ||
Kalaiselvi84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
kubectl logs -f deployments/custom-controller -n agones-system | ||
``` | ||
|
||
**Note**: If this controller fails for any reason, we've also implemented leader election such that the backup controller will automatically assume the leadership role, ensuring uninterrupted logging of event details. | ||
|
||
## Cleaning Up | ||
|
||
When you're done with the Agones fleet and the custom controller, it's a good practice to clean up the resources to prevent unnecessary resource consumption. Follow these steps to remove them: | ||
|
||
### Remove the Fleet | ||
|
||
To delete the Agones fleet you deployed, execute the following command. This will remove the fleet along with all the game server instances it manages: | ||
|
||
```bash | ||
kubectl delete -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/simple-game-server/fleet.yaml | ||
``` | ||
|
||
### Remove the Custom Controller | ||
|
||
To remove the custom controller from your cluster, execute the following command. This will delete the deployment that you created earlier. | ||
|
||
```bash | ||
kubectl delete -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/custom-controller/deployment.yaml | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the other ones, this should link to the documentation page we're writing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made all the suggested changes.