Skip to content

Commit

Permalink
docs: Update documentation to align format across project (as much as…
Browse files Browse the repository at this point in the history
… possible) (#1759)
  • Loading branch information
bryantbiggs committed Sep 12, 2023
1 parent 4cf6f14 commit 2d96b78
Show file tree
Hide file tree
Showing 40 changed files with 1,008 additions and 1,853 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Looking at the existing issues is a great way to find something to contribute on

This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
opensource-codeofconduct@amazon.com with any additional questions or comments.
<opensource-codeofconduct@amazon.com> with any additional questions or comments.

## Security issue notifications

Expand Down
7 changes: 7 additions & 0 deletions docs/_partials/destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```sh
terraform destroy -target="module.eks_blueprints_addons" -auto-approve
terraform destroy -target="module.eks" -auto-approve
terraform destroy -auto-approve
```

See [here](https://aws-ia.github.io/terraform-aws-eks-blueprints/main/getting-started/#destroy) for more details on cleaning up the resources created.
2 changes: 1 addition & 1 deletion docs/patterns/sso-iam-identity-center.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title: SSO - IAM Identity Center
---

{%
include-markdown "../../patterns/single-sign-on/iam-identity-center/README.md"
include-markdown "../../patterns/sso-iam-identity-center/README.md"
%}
2 changes: 1 addition & 1 deletion docs/patterns/sso-okta.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title: SSO - Okta
---

{%
include-markdown "../../patterns/single-sign-on/okta/README.md"
include-markdown "../../patterns/sso-okta/README.md"
%}
159 changes: 34 additions & 125 deletions patterns/agones-game-controller/README.md
Original file line number Diff line number Diff line change
@@ -1,154 +1,63 @@
# Amazon EKS Deployment with Agones Gaming Kubernetes Controller

This example shows how to deploy and run Gaming applications on Amazon EKS with Agones Kubernetes Controller
This pattern shows how to deploy and run gaming applications on Amazon EKS using the Agones Kubernetes Controller

- Deploy Private VPC, Subnets and all the required VPC endpoints
- Deploy EKS Cluster with one managed node group in an VPC
- Deploy Agones Kubernetes Controller using Helm Providers
- Deploy a simple gaming server and test the application

# What is Agones

Agones is an Open source Kubernetes Controller with custom resource definitions and is used to create, run, manage and scale dedicated game server processes within Kubernetes clusters using standard Kubernetes tooling and APIs.
Agones is an open source Kubernetes controller that provisions and manages dedicated game server
processes within Kubernetes clusters using standard Kubernetes tooling and APIs.
This model also allows any matchmaker to interact directly with Agones via the Kubernetes API to provision a dedicated game server

# What is GameLift

Amazon GameLift enables developers to deploy, operate, and scale dedicated, low-cost servers in the cloud for session-based, multiplayer games.
Built on AWS global computing infrastructure, GameLift helps deliver high-performance, high-reliability, low-cost game servers while dynamically scaling your resource usage to meet worldwide player demand.

## How to Deploy

### Prerequisites:

Ensure that you have installed the following tools in your Mac or Windows Laptop before start working with this module and run Terraform Plan and Apply

1. [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
2. [Kubectl](https://Kubernetes.io/docs/tasks/tools/)
3. [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli)

### Deployment Steps

#### Step 1: Clone the repo using the command below

```sh
git clone https://github.com/aws-ia/terraform-aws-eks-blueprints.git
```

#### Step 2: Run Terraform INIT

Initialize a working directory with configuration files

```sh
cd patterns/game-tech/agones-game-controller
terraform init
```

#### Step 3: Run Terraform PLAN

Verify the resources created by this execution

```sh
export AWS_REGION=<ENTER YOUR REGION> # Select your own region
terraform plan
```

#### Step 4: Finally, Terraform APPLY

**Deploy the pattern**

```sh
terraform apply
```

Enter `yes` to apply.
Built on AWS global computing infrastructure, GameLift helps deliver high-performance, high-reliability,
low-cost game servers while dynamically scaling your resource usage to meet worldwide player demand. See below
for more information on how GameLift FleetIQ can be integrated with Agones deployed on Amazon EKS.

Amazon GameLift FleetIQ optimizes the use of low-cost Spot Instances for cloud-based game hosting with Amazon EC2.
With GameLift FleetIQ, you can work directly with your hosting resources in Amazon EC2 and Auto Scaling while
taking advantage of GameLift optimizations to deliver inexpensive, resilient game hosting for your players
and makes the use of low-cost Spot Instances viable for game hosting

#### Configure `kubectl` and test cluster
This [blog](https://aws.amazon.com/blogs/gametech/introducing-the-gamelift-fleetiq-adapter-for-agones/) walks
through the details of deploying EKS Cluster using eksctl and deploy Agones with GameLift FleetIQ.

EKS Cluster details can be extracted from terraform output or from AWS Console to get the name of cluster.
This following command used to update the `kubeconfig` in your local machine where you run kubectl commands to interact with your EKS Cluster.
## Deploy

#### Step 5: Run `update-kubeconfig` command
See [here](https://aws-ia.github.io/terraform-aws-eks-blueprints/main/getting-started/#prerequisites) for the prerequisites and steps to deploy this pattern.

`~/.kube/config` file gets updated with cluster details and certificate from the below command
## Validate

$ aws eks --region <enter-your-region> update-kubeconfig --name <cluster-name>

#### Step 6: List all the worker nodes by running the command below

$ kubectl get nodes

#### Step 7: List all the pods running in `agones-system` namespace

$ kubectl get pods -n agones-system

#### Step 8: Install K9s (OPTIONAL)

This step is to install K9s client tool to interact with EKS Cluster

curl -sS https://webinstall.dev/k9s | bash

Just type k9s after the installation and then you will see the output like this

k9s

![Alt Text](https://github.com/aws-ia/terraform-aws-eks-blueprints/blob/9c6f8ea3e710f7b0137be07835653a2bf4f9fdfe/images/k9s-agones-cluster.png "K9s")


#### Step 9: Deploying the Sample game server
1. Deploy the sample game server

```sh
kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/release-1.32.0/examples/simple-game-server/gameserver.yaml


kubectl get gs
```

Output looks like below

```text
NAME STATE ADDRESS PORT NODE AGE
simple-game-server-7r6jr Ready 34.243.345.22 7902 ip-10-1-23-233.eu-west-1.compute.internal 11h
```

#### Step 10: Testing the Sample Game Server

sudo yum install netcat

nc -u <ADDRESS> <PORT>

e.g., nc -u 34.243.345.22 7902
2. Test the sample game server using [`netcat`](https://netcat.sourceforge.net/)

Output looks like below
```sh
echo -n "UDP test - Hello EKS Blueprints!" | nc -u 34.243.345.22 7902
```

TeamRole:~/environment/eks-blueprints (main) $ echo -n "UDP test - Hello Workshop" | nc -u 34.243.345.22 7902
Hello Workshop
ACK: Hello Workshop
```text
Hello EKS Blueprints!
ACK: Hello EKS Blueprints!
EXIT
ACK: EXIT
```

# Deploy GameLift FleetIQ

Amazon GameLift FleetIQ optimizes the use of low-cost Spot Instances for cloud-based game hosting with Amazon EC2. With GameLift FleetIQ, you can work directly with your hosting resources in Amazon EC2 and Auto Scaling while taking advantage of GameLift optimizations to deliver inexpensive, resilient game hosting for your players and makes the use of low-cost Spot Instances viable for game hosting

This [blog](https://aws.amazon.com/blogs/gametech/introducing-the-gamelift-fleetiq-adapter-for-agones/) will go through the details of deploying EKS Cluster using eksctl and deploy Agones with GameLift FleetIQ

Download the sh and execute
## Destroy

curl -O https://raw.githubusercontent.com/awslabs/fleetiq-adapter-for-agones/master/Agones_EKS_FleetIQ_Integration_Package%5BBETA%5D/quick_install/fleet_eks_agones_quickinstall.sh

## Cleanup

To clean up your environment, destroy the Terraform modules in reverse order.

Destroy the Kubernetes Add-ons, EKS cluster with Node groups and VPC
Delete the resources created by the sample game server first:

```sh
terraform destroy -target="helm_release.agones" -auto-approve
terraform destroy -target="module.eks_blueprints_addons" -auto-approve
terraform destroy -target="module.eks" -auto-approve
terraform destroy -target="module.vpc" -auto-approve
kubectl -n default delete gs --all || true
```

Finally, destroy any additional resources that are not in the above modules

```sh
terraform destroy -auto-approve
```
{%
include-markdown "../../docs/_partials/destroy.md"
%}
8 changes: 0 additions & 8 deletions patterns/agones-game-controller/destroy.sh

This file was deleted.

48 changes: 21 additions & 27 deletions patterns/agones-game-controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module "eks" {
max_size = 5
desired_size = 2
}

agones_system = {
instance_types = ["m5.large"]
labels = {
Expand All @@ -87,6 +88,7 @@ module "eks" {
max_size = 1
desired_size = 1
}

agones_metrics = {
instance_types = ["m5.large"]
labels = {
Expand Down Expand Up @@ -123,7 +125,6 @@ module "eks" {
type = "ingress"
source_cluster_security_group = true
}

}

tags = local.tags
Expand All @@ -135,7 +136,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.0"
version = "~> 1.7"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand All @@ -153,32 +154,25 @@ module "eks_blueprints_addons" {
enable_metrics_server = true
enable_cluster_autoscaler = true

tags = local.tags
}

################################################################################
# Agones Helm Chart
################################################################################
helm_releases = {
agones = {
description = "A Helm chart for Agones game server"
namespace = "agones-system"
create_namespace = true
chart = "agones"
chart_version = "1.32.0"
repository = "https://agones.dev/chart/stable"
values = [
templatefile("${path.module}/helm_values/agones-values.yaml", {
expose_udp = true
gameserver_minport = local.gameserver_minport
gameserver_maxport = local.gameserver_maxport
})
]
}
}

# NOTE: Agones requires a Node group in Public Subnets and enable Public IP
resource "helm_release" "agones" {
name = "agones"
chart = "agones"
version = "1.32.0"
repository = "https://agones.dev/chart/stable"
description = "Agones helm chart"
namespace = "agones-system"
create_namespace = true

values = [templatefile("${path.module}/helm_values/agones-values.yaml", {
expose_udp = true
gameserver_minport = local.gameserver_minport
gameserver_maxport = local.gameserver_maxport
})]

depends_on = [
module.eks_blueprints_addons
]
tags = local.tags
}

################################################################################
Expand Down
Loading

0 comments on commit 2d96b78

Please sign in to comment.