-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Game operation and maintenance API #166
Comments
Heyy @chrisliu1995 i am kairvee and would like to take up this issue under LFX mentorship programme as it aligns with my interests and skills , please inform me over the further things , |
Hello @chrisliu1995 |
@chrisliu1995 can you please update me over any pretests/ issues to work on before applying? |
Hey everyone! I'm Nihit, a pre-final year student from the Indian Institute of Information Technology, Gwalior, majoring in Information Technology. I'm a tech enthusiast with a strong passion for open-source. I've applied for this project and have been working on this issue for some time now. I would greatly appreciate any guidance or clarity on how best to approach this issue. I'm really looking forward to solving this problem and contributing to the project as much as possible. |
Based on the above requirements, I have the following initial thoughts: Features
ArchitectureQuery Layer
Filter LayerStrategy
Filter syntax
// legal:
{
"$and": [
{
"metadata.annotations.version": "java21"
},
{
"spec.opsState": "Maintaining"
}
]
}
// Illegal:
{
"$and": [
{
"metadata.annotations.version": "java21",
"spec.opsState": "Maintaining"
}
]
}
Comparison Operators
Logical Operators
ExamplesThis is a simplified GS example: apiVersion: game.kruise.io/v1alpha1
kind: GameServer
metadata:
annotations:
server: minecraft-pvp-0
version: java21
generation: 1
labels:
app.kubernetes.io/name: minecraft-pvp
game.kruise.io/owner-gss: minecraft-pvp
name: minecraft-pvp-0
namespace: minecraft
ownerReferences:
- apiVersion: v1
blockOwnerDeletion: true
controller: true
kind: Pod
name: minecraft-pvp-0
uid: c1610944-1fb1-44c7-8ec0-9d24b4aae09c
spec:
deletionPriority: 0
opsState: None
updatePriority: 0
status:
currentState: Ready
deletionPriority: "0"
desiredState: Ready
lastTransitionTime: "2024-09-09T04:33:18Z"
networkStatus:
createTime: "2024-09-02T06:58:59Z"
currentNetworkState: Ready
desiredNetworkState: Ready
externalAddresses:
- endPoint: nlb-xxx.cn-hangzhou.nlb.aliyuncs.com
ip: ""
ports:
- name: "3000"
port: 1273
protocol: UDP
internalAddresses:
- ip: 172.20.4.77
ports:
- name: "3000"
port: 3000
protocol: UDP
networkType: AlibabaCloud-NLB
podStatus:
containerStatuses:
- image: itzg/minecraft-server:java21
name: minecraft
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2024-09-02T06:58:58Z"
updatePriority: "0" Query GS list with {
"$and": [
{
"metadata.annotations.version": "java21"
},
{
"spec.opsState": {
"$ne": "None"
}
}
]
} Query GS list with opsState Maintaining or Draining: {
"$or": [
{
"spec.opsState": "Maintaining"
},
{
"spec.opsState": "Draining"
}
]
} Adaptor LayerGolang PackageFunctionsfunc NewFilter() *Filter
func NewUpdater() *Updater
func GetGsList(filter *FilterDocument)
func UpdateGsList(filter *FilterDocument, updater *UpdaterDocument) ClassFilter: type Filter struct {
}
func (f *Filter) Build() *FilterDocument
func (f *Filter) BuildFromString(filterString string) *FilterDocument Updater: type Updater struct {
}
func (u *Updater) Build() *UpdaterDocument
func (u *Updater) BuildFromString(updaterString string) *UpdaterDocument RESTful API
GET http://localhost/gs?filter={"$or":[{"spec.opsState":"Maintaining"},{"spec.opsState":"Draining"}]} After URL escape: 200 response: [
{
"name": "minecraft-pvp-0",
"namespace": "minecraft",
...
},
{
"name": "minecraft-pvp-1",
"namespace": "minecraft",
...
}
] 4XX/5XX error response: {
"code": 1,
"message": "internal error"
}
POST http://localhost/gs body: {
"query": {
"$or": [
{
"spec.opsState": "Maintaining"
},
{
"spec.opsState": "Draining"
}
]
},
"update": {
"spec.opsState": "None"
}
} 200 response(successfully updated GS list): [
{
"name": "minecraft-pvp-0",
"namespace": "minecraft",
...
},
{
"name": "minecraft-pvp-1",
"namespace": "minecraft",
...
}
] 4XX/5XX response(there is more than one GS that failed to update): {
"updated": [
{
"name": "minecraft-pvp-0",
"namespace": "minecraft",
...
}
],
"failed": [
{
"error": {
"code": 1,
"message": "internal error"
},
"gs": {
"name": "minecraft-pvp-1",
"namespace": "minecraft",
...
}
}
]
}
func GetActiveOpsGsList() {
// Create HttpClient and configure connection pool
sdkClient := sdk_client.Connect("http://localhost")
// Do HTTP request
gsList, err := sdkClient.GetGsList("namespace_name", NewFilter().Or().Kv("spec.opsState", "Maintaining").Kv("spec.opsState", "Draining").Build())
// Or use the encapsulated simpler way
gsList, err = sdkClient.GetGsList("namespace_name", NewFilter().Or().OpsState("Maintaining").OpsState("Draining").Build())
gsList, err = sdkClient.GetGsList("namespace_name", NewFilter().And().Kv("metadata.annotations.version", "java21").Ko("spec.opsState", Not().StrEq("None")).Build())
// Or use the encapsulated simpler way
gsList, err = sdkClient.GetGsList("namespace_name", NewFilter().And().Annotation("version", "java21").OpsStateNot("None").Build())
// patch GS
gsList, err = sdkClient.UpdateGsList("namespace_name", NewFilter().Or().OpsState("Maintaining").OpsState("Draining").Build(), NewUpdater().OpsState("None").Build())
} Command Line Tool# Query the GS whose GSS name is minecraft-pvp and opsState is None
gsops -namespace minecraft -filter -owner_gss minecraft-pvp -ops_state None
# Another form: gsops --namespace=minecraft --filter --owner_gss=minecraft-pvp --ops_state=None
# Update GS with opsState Maintaining or Draining to None
gsops -namespace minecraft -filter -or -ops_state Maintaining -ops_state Draining -updater -ops_state None |
kruise-game contains two CRDs GameServer and GameServerSet. Game servers can be managed by deploying or changing the corresponding CR. However, in actual production use, a release or operation and maintenance action is often a combination of a series of operations on CR. For example, set the GameServer image tag with ids 1, 7, and 10 to v0.3; adjust the update priority of GameServer with ids 5, 9, and 11 before updating the game server, etc.
Therefore, a set of APIs with operation and maintenance semantics is needed, which users can directly use or integrate into their own operation and maintenance platform to facilitate operation and maintenance operations.
The text was updated successfully, but these errors were encountered: