Skip to content

Commit e011c70

Browse files
authored
Addon Kruise game (#672)
* Added postgres-operator Signed-off-by: MdSahil-oss <[email protected]> * Removed unwanted changes Signed-off-by: MdSahil-oss <[email protected]> * Fixed unwanted mistake Signed-off-by: MdSahil-oss <[email protected]> * Added installtion support Signed-off-by: MdSahil-oss <[email protected]> * Added GameServerSet Component as definition Signed-off-by: MdSahil-oss <[email protected]> * Added game-server Signed-off-by: MdSahil-oss <[email protected]> * Updated Signed-off-by: MdSahil-oss <[email protected]> * Updated Signed-off-by: MdSahil-oss <[email protected]> * Updated installation Signed-off-by: MdSahil-oss <[email protected]> * Updated Readme Signed-off-by: MdSahil-oss <[email protected]> * Removed gameServer definitoin Signed-off-by: MdSahil-oss <[email protected]> * Updated Signed-off-by: MdSahil-oss <[email protected]> * Updated Readme Signed-off-by: MdSahil-oss <[email protected]> * Updated Signed-off-by: MdSahil-oss <[email protected]> * Added exaples Signed-off-by: MdSahil-oss <[email protected]> * Updated kruise game Signed-off-by: MdSahil-oss <[email protected]> * moved to addon directory from experimental Signed-off-by: MdSahil-oss <[email protected]> * Reverted movement of the kruise-game addon Signed-off-by: MdSahil-oss <[email protected]> --------- Signed-off-by: MdSahil-oss <[email protected]>
1 parent d0b9ed7 commit e011c70

File tree

7 files changed

+248
-0
lines changed

7 files changed

+248
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: core.oam.dev/v1beta1
2+
kind: Application
3+
metadata:
4+
name: game-server-set-sample
5+
spec:
6+
components:
7+
- type: game-server-set
8+
name: minecraft
9+
properties:
10+
replicas: 3
11+
updateStrategy:
12+
rollingUpdate:
13+
podUpdatePolicy: InPlaceIfPossible
14+
gameServerTemplate:
15+
spec:
16+
containers:
17+
- image: registry.cn-hangzhou.aliyuncs.com/acs/minecraft-demo:1.12.2
18+
name: minecraft
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# kruise-game
2+
3+
OpenKruiseGame (OKG) is a multicloud-oriented, open source Kubernetes workload specialized for game servers. It is a sub-project of the open source workload project OpenKruise of the Cloud Native Computing Foundation (CNCF) in the gaming field. OpenKruiseGame makes the cloud-native transformation of game servers easier, faster, and stabler.
4+
5+
For more visit: https://openkruise.io/kruisegame/introduction
6+
7+
## Install
8+
9+
Add experimental registry
10+
```
11+
vela addon registry add experimental --type=helm --endpoint=https://addons.kubevela.net/experimental/
12+
```
13+
14+
Before enabling this addon enable kruise addon as `kruise-game` addon depends on `kruise` addon
15+
16+
```shell
17+
$ vela addon enable kruise
18+
```
19+
20+
Enable this addon
21+
```shell
22+
$ vela addon enable kruise-game
23+
```
24+
25+
```shell
26+
$ vela ls -A | grep kruise
27+
vela-system addon-kruise-game kruise helm running healthy Fetch repository successfully, Create helm release
28+
vela-system └─ kruise-game helm running healthy Fetch repository successfully, Create helm release
29+
```
30+
31+
Disable this addon
32+
```
33+
vela addon disable kruise-game
34+
```
35+
36+
## Use kruise-game
37+
38+
### Deploy Gameservers
39+
40+
After you enable this addon, create a namespace `prod`:
41+
42+
```shell
43+
$ kubectl create namespace prod
44+
```
45+
46+
You can use GameServerSet to deploy game servers. A simple deployment case is as follows:
47+
48+
```yaml
49+
apiVersion: core.oam.dev/v1beta1
50+
kind: Application
51+
metadata:
52+
name: game-server-set-sample
53+
spec:
54+
components:
55+
- type: game-server-set
56+
name: minecraft
57+
properties:
58+
replicas: 3
59+
updateStrategy:
60+
rollingUpdate:
61+
podUpdatePolicy: InPlaceIfPossible
62+
gameServerTemplate:
63+
spec:
64+
containers:
65+
- image: registry.cn-hangzhou.aliyuncs.com/acs/minecraft-demo:1.12.2
66+
name: minecraft
67+
```
68+
69+
After the GameServerSet is created, three game servers and three corresponding pods appear in the cluster, because the specified number of replicas is 3.
70+
71+
```shell
72+
$ kubectl get gss -n prod
73+
NAME AGE
74+
minecraft 25m
75+
76+
$ kubectl get gs -n prod
77+
NAME STATE OPSSTATE DP UP
78+
minecraft-0 Ready None 0 0
79+
minecraft-1 Ready None 0 0
80+
minecraft-2 Ready None 0 0
81+
82+
$ kubectl get pod -n prod
83+
NAME READY STATUS RESTARTS AGE
84+
minecraft-0 1/1 Running 0 25m
85+
minecraft-1 1/1 Running 0 25m
86+
minecraft-2 1/1 Running 0 25m
87+
```
88+
89+
For more visit: https://openkruise.io/kruisegame/introduction.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"game-server-set": {
2+
alias: ""
3+
annotations: {}
4+
attributes: workload: type: "autodetects.core.oam.dev"
5+
description: "game server set component"
6+
labels: {}
7+
type: "component"
8+
}
9+
10+
template: {
11+
output: {
12+
kind: "GameServerSet"
13+
apiVersion: "game.kruise.io/v1alpha1"
14+
metadata: {
15+
name: context.name
16+
}
17+
spec: {
18+
gameServerTemplate: parameter.gameServerTemplate
19+
network: parameter.network
20+
replicas: parameter.replicas
21+
reserveGameServerIds: parameter.reserveGameServerIds
22+
scaleStrategy: parameter.scaleStrategy
23+
serviceQualities: parameter.serviceQualities
24+
updateStrategy: parameter.updateStrategy
25+
}
26+
}
27+
parameter: {
28+
//+usage=INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run "make" to regenerate code after modifying this file
29+
gameServerTemplate: *null | {...}
30+
//+usage=Configure Network.
31+
network: *null | {...}
32+
//+usage=replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity.
33+
replicas: *1 | int
34+
//+usage=Enter Reserve game server Ids.
35+
reserveGameServerIds: *null | [...]
36+
//+usage=It takes an interger for attribute `maxUnavailable`.
37+
scaleStrategy: {
38+
//+usage=The maximum number of pods that can be unavailable during scaling. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. It can just be allowed to work with Parallel podManagementPolicy.
39+
maxUnavailable: *null | int
40+
}
41+
//+usage=Configure serviceQualities.
42+
serviceQualities: *null | [...]
43+
//+usage=Configure updateStrategy.
44+
updateStrategy: {
45+
//+usage=Type indicates the type of the StatefulSetUpdateStrategy. Default is RollingUpdate.
46+
type: *null | string
47+
//+usage=RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
48+
rollingUpdate: *null | {...}
49+
}
50+
}
51+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: kruise-game
2+
version: 1.0.0
3+
description: This addon adds kruise-game to the kubevela to be used across the application installed in kubevela.
4+
icon: "https://github.com/openkruise/kruise-game/blob/master/docs/images/logo.jpg"
5+
url: "https://openkruise.io/kruisegame/introduction"
6+
7+
tags:
8+
- kruise-game
9+
10+
invisible: false
11+
12+
dependencies:
13+
- name: fluxcd
14+
- name: kruise
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// parameter.cue is used to store addon parameters.
2+
//
3+
// You can use these parameters in template.cue or in resources/ by 'parameter.myparam'
4+
//
5+
// For example, you can use parameters to allow the user to customize
6+
// container images, ports, and etc.
7+
parameter: {
8+
// +usage=Custom parameter description
9+
chartVersion: "0.2.1"
10+
clusters?: [...string]
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
labels:
5+
rules.oam.dev/resource-format: yaml
6+
rules.oam.dev/resources: "true"
7+
name: game-server-set-relation
8+
data:
9+
rules: |-
10+
- parentResourceType:
11+
group: game.kruise.io
12+
kind: GameServerSet
13+
childrenResourceType:
14+
- apiVersion: apps.kruise.io/v1beta1
15+
kind: StatefulSet
16+
- apiVersion: game.kruise.io/v1alpha1
17+
kind: GameServer
18+
- parentResourceType:
19+
group: apps.kruise.io
20+
kind: StatefulSet
21+
childrenResourceType:
22+
- apiVersion: v1
23+
kind: Pod
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package main
2+
3+
output: {
4+
apiVersion: "core.oam.dev/v1beta1"
5+
kind: "Application"
6+
spec: {
7+
components: [
8+
{
9+
name: "kruise-game"
10+
type: "helm"
11+
properties: {
12+
repoType: "helm"
13+
url: "https://openkruise.github.io/charts/"
14+
chart: "kruise-game"
15+
version: parameter.chartVersion
16+
}
17+
},
18+
]
19+
20+
policies: [
21+
{
22+
type: "shared-resource"
23+
name: "kruise-game-ns"
24+
properties: rules: [{
25+
selector: resourceTypes: ["Namespace"]
26+
}]
27+
},
28+
{
29+
type: "topology"
30+
name: "deploy-kruise-game"
31+
properties: {
32+
if parameter.clusters != _|_ {
33+
clusters: parameter.clusters
34+
}
35+
if parameter.clusters == _|_ {
36+
clusterLabelSelector: {}
37+
}
38+
}
39+
},
40+
]
41+
}
42+
}

0 commit comments

Comments
 (0)