Documentation ¶
Index ¶
- Constants
- func AreMapsSame(map1, map2 map[string]string) bool
- func AuthenticateWebServerCode(code string) (bool, error)
- func GetAccessCode(client kubernetes.Interface) (string, error)
- func GetClientSet() (*kubernetes.Clientset, *dgsclientsetversioned.Clientset, error)
- func GetRandomIndexes(length int, count int) []int
- func GetRandomInt(min int, max int) int
- func GetReadyDGSs() ([]dgsv1alpha1.DedicatedGameServer, error)
- func Logger() *logrus.Logger
- func NewDedicatedGameServer(dgsCol *dgsv1alpha1.DedicatedGameServerCollection, template corev1.PodSpec) *dgsv1alpha1.DedicatedGameServer
- func NewDedicatedGameServerCollection(name string, namespace string, replicas int32, template corev1.PodSpec) *dgsv1alpha1.DedicatedGameServerCollection
- func NewDedicatedGameServerWithNoParent(namespace string, name string, template corev1.PodSpec, portsToExpose []int32) *dgsv1alpha1.DedicatedGameServer
- func NewPod(dgs *dgsv1alpha1.DedicatedGameServer, apiDetails APIDetails) *corev1.Pod
- func SliceContains(slice []int32, value int32) bool
- func UpdateActivePlayers(serverName string, namespace string, activePlayers int) error
- func UpdateDGSStatus(serverName string, namespace string, fields DGSStatusFields) error
- func UpdateGameServerHealth(serverName string, namespace string, serverHealth dgsv1alpha1.DGSHealth) error
- func UpdateGameServerMarkedForDeletion(serverName string, namespace string, markedForDeletion bool) error
- func UpdateGameServerState(serverName string, namespace string, serverState dgsv1alpha1.DGSState) error
- type APIDetails
- type DGSStatusFields
Constants ¶
const ( DedicatedGameServerKind = "DedicatedGameServer" GameNamespace = "default" // MinPort is minimum Port Number MinPort int32 = 20000 // MaxPort is maximum Port Number MaxPort int32 = 30000 RandStringSize = 5 )
const ( LabelIsDedicatedGameServer = "IsDedicatedGameServer" LabelDedicatedGameServerName = "DedicatedGameServerName" LabelDedicatedGameServerCollectionName = "DedicatedGameServerCollectionName" LabelOriginalDedicatedGameServerCollectionName = "OriginalDedicatedGameServerCollectionName" )
const ( // SuccessSynced is used as part of the Event 'reason' when a CRD is synced SuccessSynced = "Synced" // ErrResourceExists is used as part of the Event 'reason' when a CRD fails // to sync due to a Deployment of the same name already existing. ErrResourceExists = "ErrResourceExists" // MessageResourceExists is the message used for Events when a resource // fails to sync due to a Deployment already existing MessageResourceExists = "Resource %q already exists and is not managed by CRD" // MessageResourceSynced is the message used for an Event fired when a resource // is synced successfully MessageResourceSynced = "%s with name %s synced successfully" DedicatedGameServerReplicasChanged = "Dedicated Game Server Replicas Changed" MessageReplicasDecreased = "%s with name %s decreased by %d replicas successfully" MessageReplicasIncreased = "%s with name %s increased by %d replicas successfully" MessageMarkedForDeletionDedicatedGameServerDeleted = "Dedicated Game Server %s that was MarkedForDeletion with 0 Active Players was deleted" MessageAutoscalingNotConfigured = "Autoscaling is not configured for DedicatedGameServerCollection %s" )
const APIAccessCodeSecretName = "apiaccesscode"
const (
APIServerURL = "http://aks-gaming-apiserver.dgs-system.svc.cluster.local"
)
make sure to change the host values if the K8s service name for the API Server is changed
Variables ¶
This section is empty.
Functions ¶
func AreMapsSame ¶
AreMapsSame compares two map[string]string objects
func AuthenticateWebServerCode ¶
AuthenticateWebServerCode authenticates the user request by comparing the given code with the actual
func GetAccessCode ¶
func GetAccessCode(client kubernetes.Interface) (string, error)
func GetClientSet ¶
func GetClientSet() (*kubernetes.Clientset, *dgsclientsetversioned.Clientset, error)
GetClientSet returns a Kubernetes interface object that will allow us to give commands to the K8s API
func GetRandomIndexes ¶
GetRandomIndexes will return *count* random integers from a hypothetical slice of *length* For example, think that we want to take two random indexes from a length-five slice
func GetReadyDGSs ¶
func GetReadyDGSs() ([]dgsv1alpha1.DedicatedGameServer, error)
GetReadyDGSs returns a list of DGS that are "PodRunning", "Healthy" and not "MarkedForDeletion"
func NewDedicatedGameServer ¶
func NewDedicatedGameServer(dgsCol *dgsv1alpha1.DedicatedGameServerCollection, template corev1.PodSpec) *dgsv1alpha1.DedicatedGameServer
NewDedicatedGameServer returns a new DedicatedGameServer object that belongs to the specified DedicatedGameServerCollection and has the designated PodSpec
func NewDedicatedGameServerCollection ¶
func NewDedicatedGameServerCollection(name string, namespace string, replicas int32, template corev1.PodSpec) *dgsv1alpha1.DedicatedGameServerCollection
NewDedicatedGameServerCollection creates a new DedicatedGameServerCollection with the specified parameters Initial state is DGSHealth: creating, DGSState: Idle and PodPhase: pending
func NewDedicatedGameServerWithNoParent ¶
func NewDedicatedGameServerWithNoParent(namespace string, name string, template corev1.PodSpec, portsToExpose []int32) *dgsv1alpha1.DedicatedGameServer
NewDedicatedGameServerWithNoParent creates a new DedicatedGameServer that is not part of a DedicatedGameServerCollection
func NewPod ¶
func NewPod(dgs *dgsv1alpha1.DedicatedGameServer, apiDetails APIDetails) *corev1.Pod
NewPod returns a Kubernetes Pod struct It also sets a label called "DedicatedGameServer" with the value of the corresponding DedicatedGameServer resource
func SliceContains ¶
SliceContains returns true if the specific int32 value is contained in the slice
func UpdateActivePlayers ¶
UpdateActivePlayers updates the active players count for the server with name serverName
func UpdateDGSStatus ¶
func UpdateDGSStatus(serverName string, namespace string, fields DGSStatusFields) error
func UpdateGameServerHealth ¶
func UpdateGameServerHealth(serverName string, namespace string, serverHealth dgsv1alpha1.DGSHealth) error
UpdateGameServerHealth updates the DedicatedGameServer with the serverName health
func UpdateGameServerState ¶
func UpdateGameServerState(serverName string, namespace string, serverState dgsv1alpha1.DGSState) error
UpdateGameServerState updates the DedicatedGameServer with the serverName state
Types ¶
type APIDetails ¶
APIDetails contains the information that allows our DedicatedGameServer to communicate with the API Server
type DGSStatusFields ¶
type DGSStatusFields struct { MarkedForDeletion *bool DGSHealth *dgsv1alpha1.DGSHealth DGSState *dgsv1alpha1.DGSState ActivePlayers *int }