Documentation
¶
Index ¶
- Constants
- Variables
- func GetPublicIPForNode(ctx context.Context, r client.Reader, nodeName string) (string, error)
- func NewGameServerForGameServerBuild(gsb *mpsv1alpha1.GameServerBuild, portRegistry *PortRegistry) (*mpsv1alpha1.GameServer, error)
- func NewPodForGameServer(gs *mpsv1alpha1.GameServer) *corev1.Pod
- type GameServerBuildReconciler
- type GameServerReconciler
- type PortRegistry
Constants ¶
const ( ActiveServerStatus = "active" StandingByServerStatus = "standingby" InitializingServerStatus = "initializing" PendingServerStatus = "pending" )
const ( InitContainerName = "initcontainer" GameServerKind = "GameServer" GameServerBuildKind = "GameServerBuild" DataVolumeName = "data" DataVolumeMountPath = "/data" // MinPort is minimum Port Number MinPort int32 = 10000 // MaxPort is maximum Port Number MaxPort int32 = 50000 RandStringSize = 5 LabelBuildID = "BuildID" LabelBuildName = "BuildName" LabelOwningGameServer = "OwningGameServer" LabelOwningOperator = "OwningOperator" LabelNodeName = "NodeName" GsdkConfigFile = "/data/Config/gsdkConfig.json" LogDirectory = "/data/GameLogs/" CertificatesDirectory = "/data/GameCertificates" DaemonSetPort int32 = 56001 )
Variables ¶
var ( GameServersCreatedCounter = registry.NewCounterVec( prometheus.CounterOpts{ Namespace: "thundernetes", Name: "gameservers_created_total", Help: "Number of GameServers created", }, []string{"BuildName"}, ) GameServersSessionEndedCounter = registry.NewCounterVec( prometheus.CounterOpts{ Namespace: "thundernetes", Name: "gameservers_sessionended_total", Help: "Number of GameServer sessions ended", }, []string{"BuildName"}, ) GameServersCrashedCounter = registry.NewCounterVec( prometheus.CounterOpts{ Namespace: "thundernetes", Name: "gameservers_crashed_total", Help: "Number of GameServers sessions crashed", }, []string{"BuildName"}, ) GameServersDeletedCounter = registry.NewCounterVec( prometheus.CounterOpts{ Namespace: "thundernetes", Name: "gameservers_deleted_total", Help: "Number of GameServers deleted", }, []string{"BuildName"}, ) CurrentGameServerGauge = registry.NewGaugeVec( prometheus.GaugeOpts{ Namespace: "thundernetes", Name: "gameservers_current_state", Help: "Gameserver gauges by state", }, []string{"BuildName", "state"}, ) AllocationsCounter = registry.NewCounterVec( prometheus.CounterOpts{ Namespace: "thundernetes", Name: "allocations_total", Help: "Number of GameServers allocations", }, []string{"BuildName"}, ) )
var InitContainerImage string
Functions ¶
func GetPublicIPForNode ¶
GetPublicIPForNode returns the Public IP of the node if the Node does not have a Public IP, method returns the internal one
func NewGameServerForGameServerBuild ¶
func NewGameServerForGameServerBuild(gsb *mpsv1alpha1.GameServerBuild, portRegistry *PortRegistry) (*mpsv1alpha1.GameServer, error)
NewGameServerForGameServerBuild creates a GameServer for a GameServerBuild
func NewPodForGameServer ¶
func NewPodForGameServer(gs *mpsv1alpha1.GameServer) *corev1.Pod
NewPodForGameServer returns a Kubernetes Pod struct for a specified GameServer Pod has the same name as the GameServer It also sets a label called "GameServer" with the value of the corresponding GameServer resource
Types ¶
type GameServerBuildReconciler ¶
type GameServerBuildReconciler struct { client.Client Scheme *runtime.Scheme PortRegistry *PortRegistry Recorder record.EventRecorder }
GameServerBuildReconciler reconciles a GameServerBuild object
func (*GameServerBuildReconciler) Reconcile ¶
func (r *GameServerBuildReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. For more details, check Reconcile and its Result here: - https://pkgo.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (*GameServerBuildReconciler) SetupWithManager ¶
func (r *GameServerBuildReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type GameServerReconciler ¶
type GameServerReconciler struct { client.Client Scheme *runtime.Scheme Recorder record.EventRecorder PortRegistry *PortRegistry GetPublicIpForNodeProvider func(ctx context.Context, r client.Reader, nodeName string) (string, error) // we abstract this for testing purposes }
GameServerReconciler reconciles a GameServer object
func (*GameServerReconciler) Reconcile ¶
func (r *GameServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. For more details, check Reconcile and its Result here: - https://pkgo.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (*GameServerReconciler) SetupWithManager ¶
func (r *GameServerReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type PortRegistry ¶
type PortRegistry struct { HostPorts map[int32]bool Indexes []int32 NextFreePortIndex int32 Min int32 // Minimum Port Max int32 // Maximum Port // contains filtered or unexported fields }
PortRegistry implements a custom map for the port registry
func NewPortRegistry ¶
func NewPortRegistry(gameServers mpsv1alpha1.GameServerList, min, max int32, setupLog logr.Logger) (*PortRegistry, error)
NewPortRegistry initializes the IndexedDictionary that holds the port registry.
func (*PortRegistry) DeregisterServerPorts ¶
func (pr *PortRegistry) DeregisterServerPorts(ports []int32)
DeregisterServerPorts deregisters all host ports so they can be re-used by additional game servers
func (*PortRegistry) GetNewPort ¶
func (pr *PortRegistry) GetNewPort() (int32, error)
GetNewPort returns and registers a new port for the designated game server. Locks a mutex
func (*PortRegistry) Stop ¶
func (pr *PortRegistry) Stop()
Stop stops port registry mechanism by closing requests and responses channels