Create a container group definition for an Amazon GameLift container fleet
A container group definition describes how to deploy your containerized game server applications to a container fleet. It's a blueprint that tells Amazon GameLift what container images to deploy to the fleet and how to run them. When you create a container fleet, you specify the container group definitions to deploy to the fleet. For more information about container groups, see Container fleet components.
Before you start
Tips on what to do before you start creating a container group definition:
-
Finalize your container images and push them to an Amazon Elastic Container Registry (Amazon ECR) repository in the same AWS Region where you plan to create the container group. Amazon GameLift captures a snapshot of each image at the time you create container group definition, and uses the snapshot when deploying to a container fleet. See Build a container image for Amazon GameLift.
-
Create your container definitions as JSON files. A container group definition includes one or more container definitions. You can use the JSON files if you create a container group definition using the AWS CLIfor Amazon GameLift.
-
Verify that your AWS user has IAM permissions to access the Amazon ECR repository. See IAM permission examples for Amazon GameLift.
Create a game server container group definition
A game server container group runs your game server software. A game server container group has one game server container, which runs the game server executable. It can also have one or more support containers to run additional software to support your game server. (These are sometimes referred to as “sidecar” containers.)
This topic describes how to create a simple game server container group definition using the Amazon GameLift console or AWS CLI tools. For more detailed information on optional features, see Customize an Amazon GameLift container fleet.
Note
You can change most container group definition and container definition settings after creating them. If you make changes to a container definition, Amazon GameLift captures a new snapshot of the updated container images.
To create a simple game server container group definition:
The following instructions describe how to create a container group definition with the minimal required parameters and using the Amazon GameLift default values.
Create a container definition JSON
file
When you create a container group definition, you also define the containers for the
group. A container definition specifies the Amazon ECR repository where the container image is
stored, and optional configurations for network ports, limits for CPU and memory usage, and
other settings. We recommend creating a single JSON
file with the configurations
for all the containers in a container group. Maintaining a file is useful for storing,
sharing, version tracking these critical configurations. If you use the AWS CLI to create
your container group definitions, you can reference the file in the command.
To create a container definition
Create and open a new
.JSON
file. For example:[~/work/glc]$
vim SimpleServer.jsonCreate a separate container definition for each of the containers for the group. Copy the following example content and modify it as needed for your containers. For details on the syntax of a container definition, see ContainerDefinitionInput in the Amazon GameLift API Reference.
Save the file locally so that you can refer to it in an AWS CLI command.
This example describes the essential container for your game server container group. The essential replica container includes your game server application, the Amazon GameLift Agent, and can include other supporting software for your game hosting. The definition must include a name, image URI, and a port configuration. This example also sets some container-specific resource limits.
[ { "ContainerName": "MyAdventureGameServer", "ImageUri": "111122223333.dkr.ecr.us-east-1.amazonaws.com/gl-containers:myadventuregame-server", "PortConfiguration": { "ContainerPortRanges": [ { "FromPort": 2000, "Protocol": "TCP", "ToPort": 2010 } ] }, "ServerSdkVersion": 5.2.0 } ]