kruise-game icon indicating copy to clipboard operation
kruise-game copied to clipboard

Feat | Add AutoUpdateStrategy

Open chrisliu1995 opened this issue 1 year ago • 1 comments

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 avatar Nov 29 '23 12:11 chrisliu1995

@sFireFrog

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

chrisliu1995 avatar Nov 29 '23 12:11 chrisliu1995

We implement it by a simpler way.

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

chrisliu1995 avatar Sep 12 '24 03:09 chrisliu1995