### Install Kruise-Game using Helm Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/installation.md Installs the Kruise-Game component using Helm. Specifies the version of Kruise-Game to install. ```shell $ helm install kruise-game openkruise/kruise-game --version 0.2.0 ``` -------------------------------- ### OpenKruiseGame Next Steps Source: https://github.com/openkruise/kruise-game/blob/master/README.md Provides guidance on how to get started with OpenKruiseGame, contribute to the project, report issues, and contact the development team. ```markdown * Install and use OpenKruiseGame. For more information, see [Getting Started](./docs/en/getting_started) & [User Manuals](./docs/en/user_manuals). * Submit code for OpenKruiseGame. For more information, see [Developer Guide](./docs/en/developer_manuals/contribution.md). * Submit [issues](https://github.com/openkruise/kruise-game/issues) to offer suggestions for OpenKruiseGame or discuss the best practices of cloud-native transformation of games. * Join the DingTalk group (ID: 44862615) to have a discussion with core contributors to OpenKruiseGame. * Contact us by email at zhongwei.lzw@alibaba-inc.com. ``` -------------------------------- ### Install Kruise using Helm Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/installation.md Installs the Kruise component using Helm. Requires Helm V3.5 or later and adds the OpenKruise charts repository. Allows setting feature gates. ```shell # Firstly add openkruise charts repository if you haven't do this. $ helm repo add openkruise https://openkruise.github.io/charts/ # [Optional] $ helm repo update # Install the latest version. $ helm install kruise openkruise/kruise --version 1.3.0 --set featureGates="PodProbeMarkerGate=true" ``` -------------------------------- ### Compile and Deploy Kruise-Game with Yaml Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/installation.md Builds and deploys the kruise-game-manager component manually. Involves editing the Makefile, compiling images, pushing them to a repository, and deploying to Kubernetes. ```bash make docker-build make docker-push make deploy ``` -------------------------------- ### Proposal Template - Getting Started Instructions Source: https://github.com/openkruise/kruise-game/blob/master/docs/proposals/YYYYMMDD-template.md Instructions for using the proposal template, including making a copy, filling out sections, and creating a Pull Request (PR). It also mentions the canonical source for the latest instructions. ```markdown To get started with this template: 1. **Make a copy of this template.** Copy this template into `docs/enhacements` and name it `YYYYMMDD-my-title.md`, where `YYYYMMDD` is the date the proposal was first drafted. 1. **Fill out the required sections.** 1. **Create a PR.** Aim for single topic PRs to keep discussions focused. If you disagree with what is already in a document, open a new PR with suggested changes. The canonical place for the latest set of instructions (and the likely source of this file) is [here](YYYYMMDD-template.md). The `Metadata` section above is intended to support the creation of tooling around the proposal process. This will be a YAML section that is fenced as a code block. See the proposal process for details on each of these items. ``` -------------------------------- ### GameServerSet with AlibabaCloud-EIP Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/网络模型.md Example configuration for a GameServerSet using AlibabaCloud Elastic IP (EIP). This setup assigns a unique EIP to each GameServer and allows configuration of bandwidth, charge type, and release strategy. ```yaml apiVersion: game.kruise.io/v1alpha1 kind: GameServerSet metadata: name: eip-nginx namespace: default spec: replicas: 1 updateStrategy: rollingUpdate: podUpdatePolicy: InPlaceIfPossible network: networkType: AlibabaCloud-EIP networkConf: - name: ReleaseStrategy value: Never - name: Bandwidth value: "3" - name: ChargeType value: PayByTraffic gameServerTemplate: spec: containers: - image: nginx name: nginx ``` -------------------------------- ### TencentCloud-CLB Network Configuration Example Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/网络模型.md Example of how to configure network settings for TencentCloud-CLB within a GameServerSet resource. It specifies the CLB IDs and port protocols. ```yaml apiVersion: game.kruise.io/v1alpha1 kind: GameServerSet metadata: name: clb-nginx namespace: default spec: replicas: 1 updateStrategy: rollingUpdate: podUpdatePolicy: InPlaceIfPossible network: networkType: TencentCloud-CLB networkConf: - name: ClbIds value: "lb-3ip9k5kr,lb-4ia8k0yh" - name: PortProtocols value: "80/TCP,7777/UDP" gameServerTemplate: spec: containers: - image: nginx name: nginx ``` -------------------------------- ### Install inotify-tools Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/hot_update.md Command to install inotify-tools in a Debian-based container, required for file system event monitoring. ```bash apt-get install inotify-tools ``` -------------------------------- ### PodEIP Resource for AlibabaCloud-EIP Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/网络模型.md Example of a PodEIP resource created by the ack-extend-network-controller for a GameServer using AlibabaCloud-EIP, detailing its specification and status. ```yaml apiVersion: alibabacloud.com/v1beta1 kind: PodEIP metadata: annotations: k8s.aliyun.com/eip-controller: ack-extend-network-controller creationTimestamp: "2023-07-17T09:58:12Z" finalizers: - podeip-controller.alibabacloud.com/finalizer generation: 1 name: eip-nginx-1 namespace: default resourceVersion: "41443319" uid: 105a9575-998e-4e17-ab91-8f2597eeb55f spec: allocationID: eip-xxx allocationType: releaseStrategy: Never type: Auto status: eipAddress: 47.98.xxx.xxx internetChargeType: PayByTraffic isp: BGP networkInterfaceID: eni-xxx podLastSeen: "2023-07-17T10:36:02Z" privateIPAddress: 192.168.1.51 resourceGroupID: rg-xxx status: InUse ``` -------------------------------- ### Sidecar PostStart Hook Example Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/hot_update.md This YAML snippet shows a Kubernetes postStart lifecycle hook for a sidecar container. It executes a bash script named 'request.sh' after the container starts, which is responsible for triggering the reload request to the main game server. ```yaml name: sidecar lifecycle: postStart: exec: command: - bash - -c - ./request.sh ``` -------------------------------- ### Example Kubernetes Service Manifests with ELB Configuration Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/user_manuals/network.md These are example Kubernetes Service manifests demonstrating the application of ELB auto-creation annotations. Each service is configured to use specific ELB settings and is assigned different external IPs, illustrating the auto-creation process. ```yaml apiVersion: v1 kind: Service metadata: annotations: game.kruise.io/network-config-hash: "3090934611" kubernetes.io/elb.autocreate: '{ "type": "public", "bandwidth_name": "bandwidth-89f0", "bandwidth_chargemode": "traffic", "bandwidth_size": 5, "bandwidth_sharetype": "PER", "eip_type": "5_bgp", "available_zone": [ "ap-southeast-1a", "ap-southeast-1b" ], "l4_flavor_name": "L4_flavor.elb.s1.small" }' kubernetes.io/elb.class: performance kubernetes.io/elb.eip-id: 566d5f4c-3484-4d7e-aa6b-xxxx kubernetes.io/elb.enterpriseID: aff97261-4dbd-4593-8236-xxxx kubernetes.io/elb.id: 75e06e8b-a246-48cb-b05c-xxxx kubernetes.io/elb.lb-algorithm: ROUND_ROBIN kubernetes.io/elb.mark: "0" creationTimestamp: "2025-07-23T09:25:01Z" finalizers: - service.kubernetes.io/load-balancer-cleanup name: hw-cce-elb-auto-performance-0 namespace: kruise-game-system ownerReferences: - apiVersion: v1 blockOwnerDeletion: true controller: true kind: Pod name: hw-cce-elb-auto-performance-0 uid: 1da0edf4-f45d-4635-8db0-ed5ccea2441d resourceVersion: "13401553" uid: 13efd440-65a7-4b45-bafc-2268102a4fd7 spec: allocateLoadBalancerNodePorts: true clusterIP: 10.247.50.xxx clusterIPs: - 10.247.50.xxx externalTrafficPolicy: Cluster internalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack loadBalancerIP: 49.0.251.xxx ports: - name: 80-tcp nodePort: 30918 port: 1 protocol: TCP targetPort: 80 selector: statefulset.kubernetes.io/pod-name: hw-cce-elb-auto-performance-0 sessionAffinity: None type: LoadBalancer status: loadBalancer: ingress: - ip: 49.0.251.xxx - ip: 192.168.1.xxx --- apiVersion: v1 kind: Service metadata: annotations: game.kruise.io/network-config-hash: "3090934611" kubernetes.io/elb.autocreate: '{ "type": "public", "bandwidth_name": "bandwidth-89f0", "bandwidth_chargemode": "traffic", "bandwidth_size": 5, "bandwidth_sharetype": "PER", "eip_type": "5_bgp", "available_zone": [ "ap-southeast-1a", "ap-southeast-1b" ], "l4_flavor_name": "L4_flavor.elb.s1.small" }' kubernetes.io/elb.class: performance kubernetes.io/elb.eip-id: 4a5396b1-e750-4ba5-a5d3-xxxx kubernetes.io/elb.enterpriseID: aff97261-4dbd-4593-8236-xxxx kubernetes.io/elb.id: b093db79-3c3e-4e77-a2ee-xxxx kubernetes.io/elb.lb-algorithm: ROUND_ROBIN kubernetes.io/elb.mark: "0" creationTimestamp: "2025-07-23T09:25:01Z" finalizers: - service.kubernetes.io/load-balancer-cleanup name: hw-cce-elb-auto-performance-1 namespace: kruise-game-system ownerReferences: - apiVersion: v1 blockOwnerDeletion: true controller: true kind: Pod name: hw-cce-elb-auto-performance-1 uid: abfc9ad1-1ae3-45fa-b956-4617c465a44f resourceVersion: "13401664" uid: 01dd8e13-b1c8-4d9f-8b1c-13c2f001c614 spec: allocateLoadBalancerNodePorts: true clusterIP: 10.247.196.xxx clusterIPs: - 10.247.196.xxx externalTrafficPolicy: Cluster internalTrafficPolicy: Cluster ipFamilies: - IPv4 ipFamilyPolicy: SingleStack loadBalancerIP: 150.40.245.xxx ports: - name: 80-tcp nodePort: 30942 port: 1 protocol: TCP targetPort: 80 selector: statefulset.kubernetes.io/pod-name: hw-cce-elb-auto-performance-1 sessionAffinity: None type: LoadBalancer status: loadBalancer: ingress: - ip: 150.40.245.xxx - ip: 192.168.1.xxx ``` -------------------------------- ### JdCloud-EIP Network Configuration Example Source: https://github.com/openkruise/kruise-game/blob/master/cloudprovider/jdcloud/README.zh_CN.md Example YAML configuration for a GameServerSet utilizing the JdCloud-EIP network plugin, specifying bandwidth, charge type, and EIP assignment options. ```yaml apiVersion: game.kruise.io/v1alpha1 kind: GameServerSet metadata: name: eip namespace: default spec: containers: - args: - /data/server/start.sh command: - /bin/bash image: gss-cn-north-1.jcr.service.jdcloud.com/gsshosting/pal:v1 name: game-server network: networkType: JdCloud-EIP networkConf: - name: "BandWidth" value: "10" - name: "ChargeType" value: postpaid_by_usage - name: "Fixed" value: "false" replicas: 3 ``` -------------------------------- ### GameServer networkStatus Example Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/网络模型.md Illustrates the networkStatus field for a GameServer, showing details like creation time, network state, IP addresses, and network type. ```yaml networkStatus: createTime: "2025-01-17T10:10:18Z" currentNetworkState: Ready desiredNetworkState: Ready externalAddresses: - ip: 106.xx.xx.xx internalAddresses: - ip: 192.168.1.51 lastTransitionTime: "2025-01-17T10:10:18Z" networkType: Volcengine-EIP ``` -------------------------------- ### GameServerSet with Volcengine CLB Example Source: https://github.com/openkruise/kruise-game/blob/master/cloudprovider/volcengine/README.md An example Kubernetes manifest for a GameServerSet utilizing the Volcengine CLB network type, demonstrating various configuration options like ClbIds, PortProtocols, and Annotations. ```yaml cat <

``` -------------------------------- ### Checking GameServer Network Status Source: https://github.com/openkruise/kruise-game/blob/master/cloudprovider/volcengine/README.md Example output showing the network status of a GameServer, indicating that the Volcengine CLB has been successfully configured and the network is in a 'Ready' state. ```bash networkStatus: createTime: "2024-01-19T08:19:49Z" currentNetworkState: Ready desiredNetworkState: Ready externalAddresses: - ip: xxx.xxx.xx.xxx ports: - name: "80" port: 6611 protocol: TCP internalAddresses: - ip: 172.16.200.60 ports: - name: "80" port: 80 protocol: TCP lastTransitionTime: "2024-01-19T08:19:49Z" networkType: Volcengine-CLB ``` -------------------------------- ### Kubernetes GameServerSet Deployment Example Source: https://github.com/openkruise/kruise-game/blob/master/docs/en/getting_started/hot_update.md This YAML defines a Kubernetes GameServerSet for the 2048 game. It includes configurations for the main game server container and a sidecar container with a postStart hook to trigger hot reloads. It also specifies volume mounts for shared directories. ```yaml kind: GameServerSet metadata: name: gss-2048 namespace: default spec: replicas: 1 updateStrategy: rollingUpdate: podUpdatePolicy: InPlaceIfPossible network: networkType: AlibabaCloud-SLB networkConf: - name: SlbIds value: lb-bp1oqahx3jnr7j3f6vyp8 - name: PortProtocols value: 80/TCP gameServerTemplate: spec: containers: - image: registry.cn-beijing.aliyuncs.com/acs/2048:v1.0-http name: app-2048 volumeMounts: - name: shared-dir mountPath: /var/www/html/js - image: registry.cn-beijing.aliyuncs.com/acs/2048-sidecar:v1.0-http #Replace with v2.0-http during hot update name: sidecar lifecycle: postStart: exec: command: - bash - -c - ./request.sh args: - bash - -c - rsync -aP /app/js/* /app/scripts/ && while true; do echo 11;sleep 2; done volumeMounts: - name: shared-dir mountPath: /app/scripts volumes: - name: shared-dir emptyDir: {} ``` -------------------------------- ### Kruise Game Autoscaling - Scale Down Example Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/自动伸缩.md Demonstrates configuring a ScaledObject for automatic scale-down in Kruise Game. It leverages KEDA's external scaler and sets a specific stabilization window for scale-down policies. The example shows how to mark a game server for deletion and the resulting state. ```yaml apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: minecraft #填写对应GameServerSet的名称 spec: scaleTargetRef: name: minecraft #填写对应GameServerSet的名称 apiVersion: game.kruise.io/v1alpha1 kind: GameServerSet pollingInterval: 30 minReplicaCount: 0 advanced: horizontalPodAutoscalerConfig: behavior: #继承HPA策略,可参考文档 https://kubernetes.io/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/#configurable-scaling-behavior scaleDown: stabilizationWindowSeconds: 45 #设置缩容稳定窗口时间为45秒 policies: - type: Percent value: 100 periodSeconds: 15 triggers: - type: external metricType: AverageValue metadata: scalerAddress: kruise-game-external-scaler.kruise-game-system:6000 ``` ```bash kubectl edit gs minecraft-0 ... spec: deletionPriority: 0 opsState: WaitToBeDeleted #初始为None, 将其改为WaitToBeDeleted updatePriority: 0 ... ``` ```bash kubectl get gs NAME STATE OPSSTATE DP UP minecraft-0 Deleting WaitToBeDeleted 0 0 minecraft-1 Ready None 0 0 minecraft-2 Ready None 0 0 # After a while ... kubectl get gs NAME STATE OPSSTATE DP UP minecraft-1 Ready None 0 0 minecraft-2 Ready None 0 0 ``` -------------------------------- ### Kruise Game Autoscaling - Scale Up Example (CPU Utilization) Source: https://github.com/openkruise/kruise-game/blob/master/docs/中文/用户手册/自动伸缩.md Illustrates configuring a ScaledObject for automatic scale-up based on CPU utilization in Kruise Game. This example shows how to define triggers for both external metrics and CPU utilization, allowing the system to scale the GameServerSet according to demand. It also includes sample commands to observe the scaling process. ```yaml apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: name: minecraft #填写对应GameServerSet的名称 spec: scaleTargetRef: name: minecraft #填写对应GameServerSet的名称 apiVersion: game.kruise.io/v1alpha1 kind: GameServerSet pollingInterval: 30 minReplicaCount: 0 advanced: horizontalPodAutoscalerConfig: behavior: #继承HPA策略,可参考文档 https://kubernetes.io/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/#configurable-scaling-behavior scaleDown: stabilizationWindowSeconds: 45 #设置缩容稳定窗口时间为45秒 policies: - type: Percent value: 100 periodSeconds: 15 triggers: - type: external metricType: AverageValue metadata: scalerAddress: kruise-game-external-scaler.kruise-game-system:6000 - type: cpu metricType: Utilization # 允许的类型是 "利用率 "或 "平均值" metadata: value: "50" ``` ```bash kubectl get gss NAME DESIRED CURRENT UPDATED READY MAINTAINING WAITTOBEDELETED AGE minecraft 5 5 5 0 0 0 7s # After a while kubectl get gss NAME DESIRED CURRENT UPDATED READY MAINTAINING WAITTOBEDELETED AGE minecraft 20 20 20 20 0 0 137s ```