openkruise / kruise-game

Game Servers Management on Kubernetes
https://openkruise.io/kruisegame/introduction
Apache License 2.0
233 stars 38 forks source link

Feat | Add AutoUpdateStrategy #113

Closed chrisliu1995 closed 2 days ago

chrisliu1995 commented 9 months ago

Backgroud

Currently GameServerSet supports batch updates in a user-defined manner by setting UpdatePriority and Partition. However, under this strategy, users need to frequently operate gss and gs objects, and many times users want to complete rolling updates in a more automated way. There are currently two scenario requirements:

  1. The existing gs under gss is not updated, and the new gs is created with a new image. In this way, users can achieve hot updates of versions through the automatic scaling capabilities provided by OKG without additional manual intervention.
  2. User-specified gs update in certain states. gss will determine whether the gs is updated based on the current gs status. If it meets the user-specified status, it will be updated; otherwise, it will not be updated.

API

type UpdateStrategy struct {
    // Type indicates the type of the StatefulSetUpdateStrategy.
    // Default is RollingUpdate.
    // +optional
    Type apps.StatefulSetUpdateStrategyType `json:"type,omitempty"`
    // RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
    // +optional
    RollingUpdate *RollingUpdateStatefulSetStrategy `json:"rollingUpdate,omitempty"`
    // AutoUpdateStrategy means that the update process will be performed automatically without user intervention.
    // +optional
    AutoUpdateStrategy *AutoUpdateStrategy `json:"autoUpdateStrategy,omitempty"`
}

type AutoUpdateStrategy struct {
    //+kubebuilder:validation:Required
    Type AutoUpdateStrategyType `json:"type"`
    // Only GameServers in SpecificStates will be updated.
    // +optional
    SpecificStates []OpsState `json:"specificStates,omitempty"`
}

type AutoUpdateStrategyType string

const (
    // OnlyNewAutoUpdateStrategyType indicates exist GameServers will never be updated, new GameServers will be created in new template.
    OnlyNewAutoUpdateStrategyType AutoUpdateStrategyType = "OnlyNew"
    // SpecificStateAutoUpdateStrategyType indicates only GameServers with Specific OpsStates will be updated.
    SpecificStateAutoUpdateStrategyType AutoUpdateStrategyType = "SpecificState"
)
chrisliu1995 commented 9 months ago

@sFireFrog

Is that meet the requirement from https://github.com/openkruise/kruise-game/issues/111 ?

chrisliu1995 commented 2 days ago

We implement it by a simpler way.

https://openkruise.io/kruisegame/best-practices/session-based-game/#game-room-hot-update