Documentation
¶
Overview ¶
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
* Copyright Metaplay. Licensed under the Apache-2.0 license.
Index ¶
- func FetchGameServerPods(ctx context.Context, kubeCli *KubeClient) ([]corev1.Pod, error)
- func FetchRemoteDockerImageMetadata(creds *DockerCredentials, imageRef string) (*v1.ConfigFile, error)
- func ReadLocalDockerImageMetadata(imageRef string) (*v1.ConfigFile, error)
- type AWSCredentials
- type Deployment
- type DockerCredentials
- type EnvironmentDetails
- type GameServerPodPhase
- type GameServerPodStatus
- type KubeClient
- type KubeConfig
- type KubeConfigCluster
- type KubeConfigClusterData
- type KubeConfigContext
- type KubeConfigContextData
- type KubeConfigUser
- type KubeConfigUserData
- type KubeConfigUserDataExec
- type KubeExecCredential
- type MetaplayImageInfo
- type NewGameServerCR
- type OAuth2Client
- type Observability
- type OldGameServerCR
- type ShardSetWithPods
- type TargetCluster
- type TargetEnvironment
- func (targetEnv *TargetEnvironment) CreateSecret(ctx context.Context, name string, payloadValues map[string][]byte) error
- func (targetEnv *TargetEnvironment) DeleteSecret(ctx context.Context, name string) error
- func (target *TargetEnvironment) GetAWSCredentials() (*AWSCredentials, error)
- func (target *TargetEnvironment) GetDetails() (*EnvironmentDetails, error)
- func (target *TargetEnvironment) GetDockerCredentials(envDetails *EnvironmentDetails) (*DockerCredentials, error)
- func (target *TargetEnvironment) GetGameServer(ctx context.Context) (*TargetGameServer, error)
- func (target *TargetEnvironment) GetKubeConfigWithEmbeddedCredentials() (string, error)
- func (target *TargetEnvironment) GetKubeConfigWithExecCredential(authProvider *auth.AuthProviderConfig) (string, error)
- func (target *TargetEnvironment) GetKubeExecCredential() (*string, error)
- func (target *TargetEnvironment) GetKubernetesNamespace() string
- func (target *TargetEnvironment) GetPrimaryKubeClient() (*KubeClient, error)
- func (targetEnv *TargetEnvironment) GetSecret(ctx context.Context, name string) (*corev1.Secret, error)
- func (targetEnv *TargetEnvironment) ListSecrets(ctx context.Context) ([]corev1.Secret, error)
- func (targetEnv *TargetEnvironment) WaitForServerToBeReady(ctx context.Context, taskRunner *tui.TaskRunner) error
- type TargetGameServer
- type TargetShardSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchGameServerPods ¶
FetchGameServerPods retrieves pods with a specific label selector in a namespace. If (optional) shardSets is specified, only return pods owned by said stateful set. Otherwise, all pods are returned. \todo Figure out how to handle multi-region gameservers
func FetchRemoteDockerImageMetadata ¶
func FetchRemoteDockerImageMetadata(creds *DockerCredentials, imageRef string) (*v1.ConfigFile, error)
FetchRemoteDockerImageMetadata retrieves the labels of an image in a remote Docker registry.
func ReadLocalDockerImageMetadata ¶
func ReadLocalDockerImageMetadata(imageRef string) (*v1.ConfigFile, error)
ReadLocalDockerImageMetadata retrieves metadata from a local Docker image.
Types ¶
type AWSCredentials ¶
type AWSCredentials struct { AccessKeyID string `json:"AccessKeyId"` SecretAccessKey string `json:"SecretAccessKey"` SessionToken string `json:"SessionToken"` Expiration string `json:"Expiration"` }
Container for AWS access credentials into the target environment. The JSON names match those used by AWS.
type Deployment ¶
type Deployment struct { AdminHostname string `json:"admin_hostname"` AdminTlsCert string `json:"admin_tls_cert"` AwsRegion string `json:"aws_region"` CdnDistributionArn string `json:"cdn_distribution_arn"` CdnDistributionId string `json:"cdn_distribution_id"` CdnS3Fqdn string `json:"cdn_s3_fqdn"` EcrRepo string `json:"ecr_repo"` GameserverAdminIamRole string `json:"gameserver_admin_iam_role"` GameserverIamRole string `json:"gameserver_iam_role"` GameserverServiceAccount string `json:"gameserver_service_account"` KubernetesNamespace string `json:"kubernetes_namespace"` MetaplayInfraVersion string `json:"metaplay_infra_version"` MetaplayRequiredSdkVersion string `json:"metaplay_required_sdk_version"` MetaplaySupportedChartVersions []string `json:"metaplay_supported_chart_versions"` S3BucketPrivate string `json:"s3_bucket_private"` S3BucketPublic string `json:"s3_bucket_public"` ServerHostname string `json:"server_hostname"` ServerPorts []int `json:"server_ports"` ServerTlsCert string `json:"server_tls_cert"` TenantEnvironment string `json:"tenant_environment"` // deprecated TenantOrganization string `json:"tenant_organization"` // deprecated TenantProject string `json:"tenant_project"` // deprecated }
type DockerCredentials ¶
Container for access information to an environment's docker registry.
type EnvironmentDetails ¶
type EnvironmentDetails struct { Deployment Deployment `json:"deployment"` Format string `json:"format"` OAuth2Client OAuth2Client `json:"oauth2_client"` Observability Observability `json:"observability"` Type string `json:"type"` }
`deployment` K8s secret's format
type GameServerPodPhase ¶
type GameServerPodPhase string
\todo is there an official k8s type for this?
const ( PhaseReady GameServerPodPhase = "Ready" PhaseRunning GameServerPodPhase = "Running" PhasePending GameServerPodPhase = "Pending" PhaseUnknown GameServerPodPhase = "Unknown" PhaseFailed GameServerPodPhase = "Failed" )
type GameServerPodStatus ¶
type GameServerPodStatus struct { Phase GameServerPodPhase `json:"phase"` Message string `json:"message"` Details interface{} `json:"details,omitempty"` }
type KubeClient ¶
type KubeClient struct { Namespace string KubeConfig string RestConfig *rest.Config RestClient *rest.RESTClient Clientset *kubernetes.Clientset DynamicClient *dynamic.DynamicClient }
Kubernetes client that wraps all the various Kubernetes client configs and client types into one struct for convenient use.
type KubeConfig ¶
type KubeConfig struct { ApiVersion string `yaml:"apiVersion"` Clusters []KubeConfigCluster `yaml:"clusters"` Contexts []KubeConfigContext `yaml:"contexts"` CurrentContext string `yaml:"current-context"` Kind string `yaml:"kind"` Preferences map[string]interface{} `yaml:"preferences"` Users []KubeConfigUser `yaml:"users"` }
type KubeConfigCluster ¶
type KubeConfigCluster struct { Cluster KubeConfigClusterData `yaml:"cluster"` Name string `yaml:"name"` }
type KubeConfigClusterData ¶
type KubeConfigContext ¶
type KubeConfigContext struct { Context KubeConfigContextData `yaml:"context"` Name string `yaml:"name"` }
type KubeConfigContextData ¶
type KubeConfigUser ¶
type KubeConfigUser struct { Name string `yaml:"name"` User KubeConfigUserData `yaml:"user"` }
type KubeConfigUserData ¶
type KubeConfigUserData struct { Token string `yaml:"token"` Exec KubeConfigUserDataExec `yaml:"exec"` }
type KubeConfigUserDataExec ¶
type KubeExecCredential ¶
type KubeExecCredential struct { ApiVersion string `json:"apiVersion"` Kind string `json:"kind"` Spec clientauthentication.ExecCredentialSpec `json:"spec"` Status clientauthentication.ExecCredentialStatus `json:"status"` }
type MetaplayImageInfo ¶
type MetaplayImageInfo struct { Name string // Image name (generally project ID for local projects), empty for remote projects. RepoTag string // Eg, 'lovely-wombats-build:12345678'. Tag string // Image tag (eg, Git hash). ProjectID string // Project human ID (label io.metaplay.project_id). SdkVersion string // Metaplay SDK version (label io.metaplay.sdk_version). CommitID string // Commit ID, e.g., git hash (label io.metaplay.commit_id). BuildNumber string // Build number (label io.metaplay.build_number). ConfigFile v1.ConfigFile // Docker metadata. }
Metadata about a Metaplay docker image.
func ReadLocalDockerImagesByProjectID ¶
func ReadLocalDockerImagesByProjectID(projectID string) ([]MetaplayImageInfo, error)
ReadLocalDockerImagesByProjectID retrieves metadata for all local Docker images that have the 'io.metaplay.project_id' label matching the provided projectID.
type NewGameServerCR ¶
type NewGameServerCR struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec struct { Config struct { EnvVars []corev1.EnvVar `json:"envVars,omitempty"` RuntimeOptionsFiles []string `json:"runtimeOptionsFiles,omitempty"` SecretRefs []struct { Name string `json:"name,omitempty"` KeyRefs []struct { Key string `json:"key,omitempty"` } `json:"keyRef,omitempty"` } `json:"secretRefs,omitempty"` } `json:"config,omitempty"` EnvironmentFamily string `json:"environmentFamily,omitempty"` Image struct { PullPolicy corev1.PullPolicy `json:"pullPolicy,omitempty"` Repository string `json:"repository,omitempty"` Tag string `json:"tag,omitempty"` } `json:"image,omitempty"` Shards []struct { ClusterLabelSelector map[string]string `json:"clusterLabelSelector,omitempty"` MaxNodeCount *int `json:"maxNodeCount,omitempty"` MinNodeCount *int `json:"minNodeCount,omitempty"` Name string `json:"name,omitempty"` PodTemplate struct { ContainerTemplate struct { ExtraPorts []corev1.ContainerPort `json:"extraPorts,omitempty"` Resources corev1.ResourceRequirements `json:"resources,omitempty"` } `json:"containerTemplate,omitempty"` } `json:"podTemplate,omitempty"` Public bool `json:"public,omitempty"` Scaling string `json:"scaling,omitempty"` Connection bool `json:"connection,omitempty"` Admin bool `json:"admin,omitempty"` NodeCount *int `json:"nodeCount,omitempty"` } `json:"shards,omitempty"` } `json:"spec,omitempty"` Status struct { NodeSetConfigs []struct { GlobalSuffix string `json:"globalSuffix,omitempty"` MaxNodeCount *int `json:"maxNodeCount,omitempty"` MinNodeCount *int `json:"minNodeCount,omitempty"` Name string `json:"name,omitempty"` Public bool `json:"public,omitempty"` Scaling string `json:"scaling,omitempty"` Connection bool `json:"connection,omitempty"` AdminAPI bool `json:"adminApi,omitempty"` EntityKinds []string `json:"entityKinds,omitempty"` NodeCount *int `json:"nodeCount,omitempty"` } `json:"nodeSetConfigs,omitempty"` Phase string `json:"phase,omitempty"` Shards map[string]struct { ClusterName string `json:"clusterName,omitempty"` GlobalSuffix string `json:"globalSuffix,omitempty"` } `json:"shards,omitempty"` } `json:"status,omitempty"` }
NewGameServerCR represents the structured CRD for the new operator GameServer.
type OAuth2Client ¶
type OAuth2Client struct { Audience string `json:"audience"` ClientId string `json:"client_id"` ClientSecret string `json:"client_secret"` Domain string `json:"domain"` EmailDomain string `json:"email_domain"` Issuer string `json:"issuer"` LogoutRedirectUri string `json:"logout_redirect_uri"` RolesClaim string `json:"roles_claim"` LocalCallback string `json:"local_callback"` }
type Observability ¶
type Observability struct { LokiEndpoint string `json:"loki_endpoint"` LokiPassword string `json:"loki_password"` LokiUsername string `json:"loki_username"` PrometheusEndpoint string `json:"prometheus_endpoint"` PrometheusPassword string `json:"prometheus_password"` PrometheusUsername string `json:"prometheus_username"` }
type OldGameServerCR ¶
type OldGameServerCR struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata metav1.ObjectMeta `json:"metadata"` Spec struct { DedicatedShardNodes bool `json:"dedicatedShardNodes"` ServiceSpec corev1.ServiceSpec `json:"serviceSpec"` ShardSpec []struct { Name string `json:"name"` NodeCount int `json:"nodeCount"` EntityKinds []string `json:"entityKinds"` Requests corev1.ResourceRequirements `json:"requests"` } `json:"shardSpec"` StatefulSetSpec appsv1.StatefulSetSpec `json:"statefulSetSpec"` } `json:"spec"` Status struct { Phase string `json:"phase"` ShardConfigMap string `json:"shardConfigMap"` ShardServices []string `json:"shardServices"` ShardStatefulSets []string `json:"shardStatefulSets"` } `json:"status"` }
OldGameServerCR represents the structured CRD for the old operator GameServer.
type ShardSetWithPods ¶
type ShardSetWithPods struct { ShardSet *TargetShardSet // ShardSet spec. Pods []corev1.Pod // Pods belonging to this shardSet. }
Result of fetching all shardSets including their pods from all the clusters.
type TargetCluster ¶
type TargetCluster struct {
KubeClient *KubeClient // Kubernetes client(s) to access target cluster.
}
Wrapper for accessing each cluster associated with the game server deployment.
type TargetEnvironment ¶
type TargetEnvironment struct { TokenSet *auth.TokenSet // Tokens to use to access the environment. StackApiBaseURL string // Base URL of the StackAPI, eg, 'https://infra.<stack>/stackapi' HumanId string // Environment human ID, eg, 'tiny-squids'. Same as Kubernetes namespace. StackApiClient *metahttp.Client // HTTP client to access environment StackAPI. // contains filtered or unexported fields }
Wrapper object for accessing an environment within a target stack.
func NewTargetEnvironment ¶
func NewTargetEnvironment(tokenSet *auth.TokenSet, stackDomain, humanId string) *TargetEnvironment
func (*TargetEnvironment) CreateSecret ¶
func (*TargetEnvironment) DeleteSecret ¶
func (targetEnv *TargetEnvironment) DeleteSecret(ctx context.Context, name string) error
DeleteSecret deletes a Kubernetes secret with the given name
func (*TargetEnvironment) GetAWSCredentials ¶
func (target *TargetEnvironment) GetAWSCredentials() (*AWSCredentials, error)
Get AWS credentials against the target environment. \todo migrate this into StackAPI -- AWS creds should not be given to the client
func (*TargetEnvironment) GetDetails ¶
func (target *TargetEnvironment) GetDetails() (*EnvironmentDetails, error)
Request details about an environment from the StackAPI.
func (*TargetEnvironment) GetDockerCredentials ¶
func (target *TargetEnvironment) GetDockerCredentials(envDetails *EnvironmentDetails) (*DockerCredentials, error)
Get Docker credentials for the environment's docker registry.
func (*TargetEnvironment) GetGameServer ¶
func (target *TargetEnvironment) GetGameServer(ctx context.Context) (*TargetGameServer, error)
Get the accessor to the gameserver resource in this environment.
func (*TargetEnvironment) GetKubeConfigWithEmbeddedCredentials ¶
func (target *TargetEnvironment) GetKubeConfigWithEmbeddedCredentials() (string, error)
Get a short-lived kubeconfig with the access credentials embedded in the kubeconfig file.
func (*TargetEnvironment) GetKubeConfigWithExecCredential ¶
func (target *TargetEnvironment) GetKubeConfigWithExecCredential(authProvider *auth.AuthProviderConfig) (string, error)
* * Get a `kubeconfig` payload which invokes `metaplay-auth get-kubernetes-execcredential` to get the actual * access credentials each time the kubeconfig is used. * @returns The kubeconfig YAML.
func (*TargetEnvironment) GetKubeExecCredential ¶
func (target *TargetEnvironment) GetKubeExecCredential() (*string, error)
Get the Kubernetes credentials in the execcredential format
func (*TargetEnvironment) GetKubernetesNamespace ¶
func (target *TargetEnvironment) GetKubernetesNamespace() string
func (*TargetEnvironment) GetPrimaryKubeClient ¶
func (target *TargetEnvironment) GetPrimaryKubeClient() (*KubeClient, error)
Get a Kubernetes client for the primary cluster.
func (*TargetEnvironment) GetSecret ¶
func (targetEnv *TargetEnvironment) GetSecret(ctx context.Context, name string) (*corev1.Secret, error)
GetSecret retrieves a Kubernetes secret by name
func (*TargetEnvironment) ListSecrets ¶
ListSecrets lists all Kubernetes secrets with the user secret label. If no secrets exist, an empty list is returned.
func (*TargetEnvironment) WaitForServerToBeReady ¶
func (targetEnv *TargetEnvironment) WaitForServerToBeReady(ctx context.Context, taskRunner *tui.TaskRunner) error
type TargetGameServer ¶
type TargetGameServer struct { Namespace string // Kubernetes namespace. GameServerNewCR *NewGameServerCR // GameServer CR for new operator. GameServerOldCR *OldGameServerCR // GameServer CR for old operator. KubeCli *KubeClient // Kubernetes clients for the primary cluster. Clusters []TargetCluster // All clusters associated with the environment (primary and edge clusters). ShardSets []TargetShardSet // ShardSets belonging to the game server. }
Wrapper for a (single or multi-cluster) gameserver CR in an environment.
func (*TargetGameServer) GetAllShardSetsWithPods ¶
func (gs *TargetGameServer) GetAllShardSetsWithPods() ([]ShardSetWithPods, error)
Get all shardSets across all gameserver clusters and their asscoiated pods.
func (*TargetGameServer) GetPod ¶
func (gs *TargetGameServer) GetPod(podName string) (*KubeClient, *corev1.Pod, error)
Find a gameserver pod with the given name.
func (*TargetGameServer) GetShardSetWithPods ¶
func (gs *TargetGameServer) GetShardSetWithPods(shardSetName string) (*ShardSetWithPods, error)
Get the shardSet with given name. Can be on any cluster.
type TargetShardSet ¶
type TargetShardSet struct { Name string // Name of the shardSet, also prefix for the pod names. Cluster *TargetCluster // Cluster on which the shard set resides on. }