Deploying the Game Application
To deploy the game application on CCE, you need to perform the following operations:
- Create a cluster: A container cluster is a logical group that runs applications and contains a group of cloud server resources. Each cluster node corresponds to a cloud server. When using CCE for the first time, create an initial cluster and add a node into the cluster.
- Deploy a MySQL database: Deploy the database.
- Deploy the wow-auth authentication system: Deploy the wow-auth authentication system on CCE.
- Deploy the wow-world game server: Deploy the wow-world game server on CCE.
Creating a Cluster
A container cluster is a logical group that runs applications and contains a group of cloud server resources. Each cluster node corresponds to a cloud server. When using CCE for the first time, create an initial cluster and add a node into the cluster.
- Before creating a cluster, create a VPC and a key pair.
If a VPC and a key pair are available, skip to the next step.
Table 1 Preparing the environment No.
Item
Procedure
1
Creating a VPC
Create a VPC before you create a cluster. A VPC provides an isolated, configurable, and manageable virtual network environment for CCE clusters.
If you have a VPC already, skip to the next task.
- Log in to the management console.
- In the service list, choose Network > Virtual Private Cloud.
- On the Dashboard page, click Create VPC.
- Follow the instructions to create a VPC. Retain default settings for parameters unless otherwise specified.
2
Creating a key pair
Create a key pair before you create a containerized application. Key pairs are used for identity authentication during remote login to a node. If you have a key pair already, skip this task.
- Log in to the management console.
- In the service list, choose Security and Compliance > Data Encryption Workshop.
- In the navigation pane, choose Key Pair Service. On the Private Key Pairstab page, click Create Key Pair.
- Enter a key pair name and click OK.
- In the displayed dialog box, click OK.
View and save the key pair. For security purposes, a key pair can be downloaded only once. Keep it secure to ensure successful login.
- Log in to the CCE console, choose Dashboard in the navigation pane, and click Buy Cluster.
- Set Cluster Name to cluster-wow, retain the default settings for other parameters, and click Next.
- Set the parameters for adding a node into the cluster. Set the node specifications, network, and login parameters as follows, and retain the default settings for the other parameters:
- Specifications: 4 vCPUs and 8 GB memory.
The 4-core CPU and 8 GB memory are the minimum specifications for the game application, supporting deployment of only one game server. To deploy more game servers, scale out the node or configure higher specifications.
- EIP: Select Automatically assign to make the node accessible from public networks. Retain the default values for other parameters.
- Login Mode: Select Key pair, and select the key pair you created in Table 1 for logging in to the node.
- Specifications: 4 vCPUs and 8 GB memory.
- Click Buy Now. Review the order details, and click Submit.
It takes about 6 to 10 minutes to create a cluster. View the cluster creation process as prompted.
- Choose Resource Management > Nodes in the navigation pane. You can view the node whose status is Available and has bound with an elastic IP address.
Creating a MySQL Database
In this section, the database is deployed as a two-pod StatefulSet. In practice, complex clusters or active/standby deployments are often used, or database cloud services are directly used.
- Log in to the CCE console. In the navigation pane, choose Workloads > StatefulSets. On the page displayed, click Create StatefulSet.
- Enter the basic information about the workload.
- Workload Name: Set it to mysql.
- Cluster Name: Select the cluster where the workload will run.
- Namespace: Set it to default.
- Instances: Change the value to 1 in this example.
Figure 1 Basic information about the MySQL workload
- Click Next: Add Container, click Add Container, select the MySQL image on the Open Source Images tab page, and click OK. Figure 2 Selecting the MySQL image
Select 5.7 for Image Version.
Figure 3 Selecting an image version
Set environment variables. In this example, you need to set four environment variables. You can visit MySQL to view the environment variables that can be set for MySQL.
- MYSQL_ROOT_PASSWORD: password of the root user of MySQL.
- MYSQL_DATABASE: name of the database created during image startup.
- MYSQL_USER: name of the database user.
- MYSQL_PASSWORD: password of the database user.
Figure 4 Setting environment variables
- Choose Data Storage > Cloud Volume and add a cloud volume as the MySQL storage. Mount the storage to the /var/lib/mysql path of the container, which is the default path used by MySQL.Figure 5 Mounting storage for MySQL
The following information is displayed.
Figure 6 Data storage
- Click Next: Set Application Access to configure the workload access. A headless service needs to be configured for the StatefulSet to discover pods. In this example, this function is not used. You can set a random port number.Figure 7 Headless Service
- Click Add Service.
Select ClusterIP for Access Type, set Service Name to mysql, set both the Container Port and Access Port to 3306, and click OK.
The default access port in the MySQL image is 3306. In this example, both the container port and access port are set to 3306 for convenience. The access port can be changed to another port.
In this way, the MySQL workload can be accessed through Service name:Access port (mysql:3306 in this example) in the cluster.
Figure 8 Adding a Service for MySQL
- Click Next: Configure Advanced Settings, and then click Create.
If the workload status is Running, the workload is successfully created.
Figure 9 Workload created successfully
- Click the MySQL name to view its details. Click the Services tab, and obtain and record the Access Address. Figure 10 Obtaining the access address
Deploying the wow-auth Authentication System
Deploy the wow-auth authentication system on CCE. During the deployment, set the wow-auth authentication system to connect to the MySQL database and wow-world game server through environment variables.
- Log in to the CCE console.
- In the navigation pane, choose Workloads > Deployments, and click Create Deployment.
For the game application described in this tutorial, both its authentication system and game server are Deployments. You are advised to reconstruct them into Deployments if they are StatefulSets in actual application scenarios. The differences between Deployments and StatefulSets are as follows:
- Deployment: a workload that does not store any data or statuses, for example, Nginx.
- StatefulSet: a workload that stores data or statuses during running. For example, MySQL is a StatefulSet because it needs to store new data.
- Set the basic information about the workload.
- Workload Name: Specify the workload name, for example, wow-auth.
- Cluster Name: Select the cluster created in Creating a Cluster.
- Namespace: Retain the default value.
- Instances: You are advised to set the quantity to 1. Otherwise, resources may be insufficient.
- Description: You can leave it blank.
- Click Next, and click Add Container. On the Select Container Image page displayed, search for wow, and select the wowauth-5.0 image version.
- Retain the default values for the other parameters, and set the parameters for Container Resources as required. After the setting, select the 0.5X specifications.
Configure compute resources based on the application requirements. In this tutorial, the wow-auth component of the game application requires at least 0.5 CPU core and 0.5 GiB memory.
Figure 11 Configuring container resources
- Expand Environment Variables and configure the environment variables for connecting the wow-auth authentication system to the MySQL database and wow-world game server.
The environment variables listed in the following list are pre-set in the image. If you are unclear about the settings, see How Can I Obtain the Values of Environment Variables When Deploying a Game Application?.
Table 2 Setting environment variables Variable Name
Description
Variable Value/Variable Reference
mysqlip
Set this variable to the database access address obtained in 8.
10.247.59.224//10.247.130.188
mysqlrootpasswd
Password of the database administrator, which must be the same as the administrator password set in 3.
-
biboaddress
External access address of the game server. You can use the elastic IP address or elastic load balancer mode. Elastic IP address mode is used in this tutorial. Select the elastic IP address queried in 6.
10.3.2.119
biboport
External access port of the game server. You must set a value ranging from 30000 to 32767 in advance.
NOTE:This value must be globally unique in the current cluster. In this tutorial, for easy operations, a fixed value is specified for connection to the game server. During actual application deployment, you are advised to specify the dependencies when creating the images.
32500
- Click Next: Set Application Access, and click Add Service to configure a policy by which the workload will be accessed externally. Figure 12 Adding a Service
- Access Type: In this example, select NodePort.
- Service Name: The service name can be the same as the application name, for example, wow-auth.
- Service Affinity: In this example, the cluster level is selected.
- Cluster level: The IP addresses and access ports of all nodes in a cluster can be used to access the workload associated with the Service. Service access will cause performance loss due to route redirection, and the source IP address of the client cannot be obtained.
- Node level: Only the IP address and access port of the node where the workload is located can be used to access the workload associated with the Service. Service access will not cause performance loss due to route redirection, and the source IP address of the client can be obtained.
- Port Settings
- Protocol: In this example, TCP is selected.
- Container Port: Listening port of the authentication system, which is port 3724 in this example. Do not change the port number because the port number 3724 has been set in the image.
- Access Port: Node port (with a private IP address) to which the container port will be mapped. In this example, the port is automatically generated.
- Click OK.
- Click Next: Configure Advanced Settings. Skip the advanced settings, and click Create.
On the workload list page, you can view the created workload. It takes about one minute to create the workload.
Deploying the wow-world Game Server
Deploy the wow-world game server on CCE. During the deployment, set the wow-world game server to connect to the MySQL database through environment variables.
- Log in to the CCE console.
- In the navigation pane, choose Workloads > Deployments, and click Create Deployment.
- Set the basic information about the workload.
- Workload Name: Specify the workload name, for example, wow-world.
- Cluster Name: Select the cluster created in Creating a Cluster.
- Namespace: Retain the default value.
- Instances: You are advised to set the quantity to 1. Otherwise, resources may be insufficient.
- Description: You can leave it blank.
- Click Next: Add Container, and click Add Container. On the Select Container Image page displayed, search for wow, and select the wowworld-5.0-withmap image version.
- Configure Container Resources. Configure compute resources based on the application requirements. In this tutorial, the wow-world component of the game application requires at least 2 CPU cores and 2 GiB memory. Figure 13 Configuring container resources
- Set the environment variables used for interconnection with the MySQL database. Table 3 describes the variables.
If you are unclear about the settings, see How Can I Obtain the Values of Environment Variables When Deploying a Game Application?.
Table 3 Setting environment variables Variable Name
Description
Variable Value/Variable Reference
mysqlip
Set this variable to the database access address.
10.247.59.224
mysqlrootpasswd
Password of the database administrator, which must be the same as the administrator password set in 3.
-
- Click Next: Set Application Access, and click Add Service to configure a policy by which the workload will be accessed externally.
- Access Type: In this example, select NodePort.
- Service Name: The service name can be the same name as the workload name, for example, wow-world.
- Service Affinity: In this example, select Cluster level.
- Cluster level: The IP addresses and access ports of all nodes in a cluster can be used to access the workload associated with the Service. Service access will cause performance loss due to route redirection, and the source IP address of the client cannot be obtained.
- Node level: Only the IP address and access port of the node where the workload is located can be used to access the workload associated with the Service. Service access will not cause performance loss due to route redirection, and the source IP address of the client can be obtained.
- Protocol: In this example, TCP is selected.
- Container Port: Listening port of the game server, which is port 8085 in this tutorial. Do not change the port number because the port number has been set in the image.
- Access Port. This port must be the same as the biboport in the environment variable settings added when the authentication system is deployed. If no such environment variable is found, see How Can I Obtain the Access Port When Deploying a Game Application?.
- Click OK.
- Click Next. Skip the advanced settings, and click Create.
On the workload list page, you can view the created workload. It takes about one minute to create the workload.
Last Article: Preparing the Environment
Next Article: Running the Game
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.