### Run example via npm Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Starts the example directly via npm. ```bash $ npm start ``` -------------------------------- ### Install Extism Go SDK with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/extism/go-sdk/README.md Install the SDK into a Go host application using the go get command. This is the standard first step before importing the library. ```shell go get github.com/extism/go-sdk ``` -------------------------------- ### Install glob with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/gobwas/glob/readme.md Install the glob library using the go get command. ```shell go get github.com/gobwas/glob ``` -------------------------------- ### Install and run local Go Doc site with pkgsite Source: https://github.com/agones-dev/agones/blob/main/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Commands to install and run the pkgsite tool for viewing Go documentation locally. Run 'go install' first, then 'pkgsite' to start the server. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install hashstructure v2 with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/mitchellh/hashstructure/v2/README.md Standard installation command for the hashstructure library. Use this to fetch the v2 release, which is recommended over earlier versions. ```shell $ go get github.com/mitchellh/hashstructure/v2 ``` -------------------------------- ### Install Afero with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/spf13/afero/README.md Installs the latest version of the Afero library using the go get command. ```shell $ go get github.com/spf13/afero ``` -------------------------------- ### Example output when running via Docker Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Shows the expected output when running the example via Docker, including the npm start command and SDK connection messages. ```text docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.12 > @ start /home/server/examples/nodejs-simple > node src/index.js Connecting to the SDK server... ...connected to SDK server ``` -------------------------------- ### Install float16 with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/x448/float16/README.md Install the float16 library using the go get command. ```bash go get github.com/x448/float16 ``` -------------------------------- ### Install Blackfriday v2 with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Resolves and adds the package to the current development module, then builds and installs it. Requires Go installed and module mode enabled. ```shell go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install pflag with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/spf13/pflag/README.md Install the pflag package using the standard go get command. ```bash go get github.com/spf13/pflag ``` -------------------------------- ### Install OpenCensus Go with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/go.opencensus.io/README.md Use this command to install the OpenCensus Go library. The API is still evolving, so vendoring or a dependency management tool is recommended. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install longrunning library Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/longrunning/README.md Install the longrunning helper library for Go using the go get command. ```bash go get cloud.google.com/go/longrunning ``` -------------------------------- ### Install mapstructure with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/mitchellh/mapstructure/README.md Standard installation command for the mapstructure library using go get. ```shell $ go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Show help for the example Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Passes --help to the example to display usage information. All three commands are equivalent. ```bash $ make args="--help" run $ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.12 --help $ npm start -- --help ``` -------------------------------- ### Install INI package with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/gopkg.in/ini.v1/README.md Install the INI package using the go get command. The minimum requirement of Go is 1.6. Add the -u flag to update in the future. ```sh $ go get gopkg.in/ini.v1 ``` -------------------------------- ### Install yaml package with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/go.yaml.in/yaml/v2/README.md Install the yaml package using the go get command. ```bash go get go.yaml.in/yaml/v2 ``` -------------------------------- ### Run example via Docker Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Runs the example gameserver container directly with Docker, using host networking. ```bash $ docker run --network=host us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.12 ``` -------------------------------- ### Run local sdk-server with custom GameServer configuration Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/Client SDKs/local.md Run the local sdk-server with a custom GameServer configuration file. The command downloads an example gameserver.yaml and starts the server with the --local and -f flags. The output shows the server reading the configuration and starting the gRPC and HTTP endpoints. ```bash wget https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/simple-game-server/gameserver.yaml ./sdk-server.linux.amd64 --local -f ./gameserver.yaml ``` ```json {"ctlConf":{"Address":"localhost","IsLocal":true,"LocalFile":"./gameserver.yaml","Delay":0,"Timeout":0,"Test":"","GRPCPort":9357,"HTTPPort":9358},"message":"Starting sdk sidecar","severity":"info","source":"main","time":"2019-10-30T21:47:45.742776+03:00","version":"1.1.0"} {"filePath":"/Users/alexander.apalikov/Downloads/agonessdk-server-1.1.0/gameserver.yaml","message":"Reading GameServer configuration","severity":"info","time":"2019-10-30T21:47:45.743369+03:00"} {"grpcEndpoint":"localhost:9357","message":"Starting SDKServer grpc service...","severity":"info","source":"main","time":"2019-10-30T21:47:45.759692+03:00"} {"httpEndpoint":"localhost:9358","message":"Starting SDKServer grpc-gateway...","severity":"info","source":"main","time":"2019-10-30T21:47:45.760312+03:00"} ``` -------------------------------- ### Example game server list output Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Getting Started/create-wasm-fleetautoscaler.md Example output from the kubectl get gs command showing five ready game servers with their addresses, ports, nodes, and ages. ```text NAME STATE ADDRESS PORT NODE AGE simple-game-server-8pbz5-2w72n Ready 192.168.49.2 7238 agones 4m32s simple-game-server-8pbz5-b4pwb Ready 192.168.49.2 7012 agones 27m simple-game-server-8pbz5-cq8wf Ready 192.168.49.2 7011 agones 17m simple-game-server-8pbz5-lk7l9 Ready 192.168.49.2 7068 agones 27m simple-game-server-8pbz5-tb4qk Ready 192.168.49.2 7055 agones 17m ``` -------------------------------- ### Install fsnotify with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/gopkg.in/fsnotify.v1/CONTRIBUTING.md Use this command to install fsnotify from GitHub, which sets up the original import path for smooth development. ```bash go get -u github.com/fsnotify/fsnotify ``` -------------------------------- ### Install wazero with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/tetratelabs/wazero/README.md Use this command to fetch the latest version of wazero. It requires Go and no other dependencies. ```bash go get github.com/tetratelabs/wazero@latest ``` -------------------------------- ### Run the Go client example as a Kubernetes Job Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/access-api.md Commands to run the Go client example as a Kubernetes Job and check its pod status. The output shows the pod completed successfully. ```bash kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/crd-client/create-gs.yaml --namespace agones-system kubectl get pods --namespace agones-system ``` ```bash NAME READY STATUS RESTARTS AGE create-gs-6wz86-7qsm5 0/1 Completed 0 6s ``` -------------------------------- ### Install cloud.google.com/go/compute/metadata Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/compute/metadata/README.md Installs the metadata utility library for communicating with the Google Cloud metadata service. ```bash go get cloud.google.com/go/compute/metadata ``` -------------------------------- ### Install and use tomll Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/pelletier/go-toml/README.md Install and get help for the tomll command line tool, which reads TOML files and lints them. ```bash go install github.com/pelletier/go-toml/cmd/tomll tomll --help ``` -------------------------------- ### Install Gorilla WebSocket with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/gorilla/websocket/README.md Use this command to install the Gorilla WebSocket package. Run it in your Go module directory. The package provides a complete and tested implementation of the WebSocket protocol with a stable API. ```shell go get github.com/gorilla/websocket ``` -------------------------------- ### Install Agones with kubectl apply Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Install Agones/yaml.md Quickest way to install Agones using the pre-generated install.yaml file. Creates the agones-system namespace and applies the manifest with server-side apply. Uses well-known TLS certificates, so for production use the Helm installation or helm template instead. ```bash kubectl create namespace agones-system kubectl apply --server-side -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/install/yaml/install.yaml ``` -------------------------------- ### Install jsonpointer with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/go-openapi/jsonpointer/README.md Installs the jsonpointer library into your Go project using the go mod command. ```cmd go get github.com/go-openapi/jsonpointer ``` -------------------------------- ### Install jsonreference with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/go-openapi/jsonreference/README.md Use this command to add the jsonreference library to your Go project. It fetches the latest version from the repository. ```cmd go get github.com/go-openapi/jsonreference ``` -------------------------------- ### Install spec package with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/go-openapi/spec/README.md Use this command to install the spec package into your Go project. This is the standard way to add the library as a dependency. ```cmd go get github.com/go-openapi/spec ``` -------------------------------- ### Install with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/contrib.go.opencensus.io/exporter/prometheus/README.md Use this command to install the OpenCensus Go Prometheus exporter package. It fetches the package from the contrib.go.opencensus.io repository. ```shell $ go get -u contrib.go.opencensus.io/exporter/prometheus ``` -------------------------------- ### Install and use tomljson Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/pelletier/go-toml/README.md Install and get help for the tomljson command line tool, which reads a TOML file and outputs its JSON representation. ```bash go install github.com/pelletier/go-toml/cmd/tomljson tomljson --help ``` -------------------------------- ### Install Google Auth Library for Go Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/auth/README.md Installs the latest version of the Google Auth Library for Go. ```bash go get cloud.google.com/go/auth@latest ``` -------------------------------- ### Install a Google Cloud Go package Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/README.md Installs a Google Cloud client library for Go. Replace 'firestore' with the desired package name. ```bash go get cloud.google.com/go/firestore@latest # Replace firestore with the package you want to use. ``` -------------------------------- ### Install uuid package with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/google/uuid/README.md Use this command to install the github.com/google/uuid package. Run it in your terminal to fetch the package and make it available for import in your Go project. ```sh go get github.com/google/uuid ``` -------------------------------- ### Install latest version with go get Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/evanphx/json-patch/README.md Use this command to fetch the latest development version of the jsonpatch library. Run it in a terminal with Go installed and a module-aware environment. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### HCL configuration example Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/hashicorp/hcl/README.md Shows a sample HCL configuration block. Use this as a starting point for defining structured, human-friendly configuration that is also JSON-compatible. ```hcl variable "ami" { description = "the AMI to use" } ``` -------------------------------- ### Get logs from the Go client example Job Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/access-api.md Command to retrieve the logs of the Kubernetes Job pod and the expected output showing the created GameServer name. ```bash kubectl logs create-gs-6wz86-7qsm5 --namespace agones-system ``` ```bash {"message":"\u0026{0xc0001dde00 default}","severity":"info","source":"main","time":"2020-04-21T11:14:00.477576428Z"} {"message":"New GameServer name is: helm-test-server-fxfgg","severity":"info","time":"2020-04-21T11:14:00.516024697Z"} ``` -------------------------------- ### Install Agones with matching port range Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Creating Cluster/minikube.md When installing Agones on the new cluster, update the port range to match the one used in 'minikube start'. The port range must be consistent between both commands. ```bash helm install my-release --namespace agones-system --create-namespace \ --set gameservers.minPort=7000,gameservers.maxPort=7100 agones/agones ``` -------------------------------- ### Example netcat session with game server Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Getting Started/create-gameserver.md Example netcat session showing the GameServer echoing input lines. ```shell nc -u 35.233.183.43 7190 Hello World ! ACK: Hello World ! ``` -------------------------------- ### Install MetalLB with helm upgrade --install Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.54.0.md Upgrade MetalLB to v0.15.2 using helm upgrade --install for local e2e testing on kind or minikube. ```bash helm upgrade --install metallb metallb/metallb --version v0.15.2 ``` -------------------------------- ### Create a GameServer on a Windows node Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/windows-gameservers.md Creates a GameServer from the simple-game-server example. Starting with version 0.3, the simple-game-server example is compiled as a multi-arch docker image that will run on both Linux and Windows. To ensure that the game server runs on a Windows node, a nodeSelector of "kubernetes.io/os": windows must be added to the game server specification. ```bash kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/simple-game-server/gameserver.yaml ``` -------------------------------- ### Create a Fleet with kubectl apply Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Examples/supertuxkart.md Applies the SuperTuxKart fleet configuration from the Agones examples repository. Requires a running Kubernetes cluster with Agones installed. Expected output: 'fleet.agones.dev/supertuxkart created'. ```bash kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/supertuxkart/fleet.yaml ``` -------------------------------- ### Get Agones Pods and Expected Output Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/confirm.md Run this command to list the Agones pods. The expected output shows all pods in the Running state, confirming the installation is successful. ```bash kubectl get pods --namespace agones-system ``` ```text NAME READY STATUS RESTARTS AGE agones-allocator-5c988b7b8d-cgtbs 1/1 Running 0 8m47s agones-allocator-5c988b7b8d-hhhr5 1/1 Running 0 8m47s agones-allocator-5c988b7b8d-pv577 1/1 Running 0 8m47s agones-controller-7db45966db-56l66 1/1 Running 0 8m44s agones-ping-84c64f6c9d-bdlzh 1/1 Running 0 8m37s agones-ping-84c64f6c9d-sjgzz 1/1 Running 0 8m47s ``` -------------------------------- ### Install golang.org/x/sys dependency Source: https://github.com/agones-dev/agones/blob/main/vendor/gopkg.in/fsnotify.v1/README.md Run this command to install the latest version of golang.org/x/sys, which fsnotify requires instead of the standard syscall package. ```console go get -u golang.org/x/sys/... ``` -------------------------------- ### Install kubectl with gcloud components install kubectl Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Creating Cluster/gke.md Installs the kubectl command-line tool using the gcloud components command. ```bash gcloud components install kubectl ``` -------------------------------- ### Run additional fsnotify examples Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/fsnotify/fsnotify/README.md Command to run the additional examples located in the cmd/fsnotify directory. ```shell % go run ./cmd/fsnotify ``` -------------------------------- ### Local Setup Commands Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/CONTRIBUTING.md Run these commands in order to configure the local environment for integration tests. Sets the default project, authenticates, creates Datastore indexes, creates a storage bucket with logging permissions, creates a PubSub topic, and prepares a Spanner instance. ```sh # Sets the default project in your env. $ gcloud config set project $GCLOUD_TESTS_GOLANG_PROJECT_ID # Authenticates the gcloud tool with your account. $ gcloud auth login # Create the indexes for all the databases you want to use in the datastore integration tests. # Use empty string as databaseID or skip database flag for default database. $ gcloud alpha datastore indexes create --database=your-databaseID-1 --project=$GCLOUD_TESTS_GOLANG_PROJECT_ID testdata/index.yaml # Creates a Google Cloud storage bucket with the same name as your test project, # and with the Cloud Logging service account as owner, for the sink # integration tests in logging. $ gsutil mb gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID $ gsutil acl ch -g cloud-logs@google.com:O gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID # Creates a PubSub topic for integration tests of storage notifications. $ gcloud beta pubsub topics create go-storage-notification-test # Next, go to the Pub/Sub dashboard in GCP console. Authorize the user # "service-@gs-project-accounts.iam.gserviceaccount.com" # as a publisher to that topic. # Creates a Spanner instance for the spanner integration tests. $ gcloud spanner instances create go-spanner-test --config=regional-us-central1 --nodes=1 --description='Instance for integration tests' ``` -------------------------------- ### Install Agones 1.29.0 with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.29.0.md Install Agones 1.29.0 using Helm. First add the stable Helm repository, then install the chart with the specified version. ```bash helm install agones agones/agones --version 1.29.0 ``` ```bash helm repo add agones https://agones.dev/chart/stable ``` -------------------------------- ### Install Agones 1.7.0 with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.7.0.md Install the Agones 1.7.0 Helm chart. First add the stable Helm repository using `helm repo add agones https://agones.dev/chart/stable`, then run the install command. ```bash helm install agones/agones --version 1.7.0 ``` -------------------------------- ### Create a storage client with a service account key file Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/README.md Creates a client using a service account key file. Requires the path to the key file. ```go client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json")) ``` -------------------------------- ### Install OpenCensus Stackdriver Exporter Source: https://github.com/agones-dev/agones/blob/main/vendor/contrib.go.opencensus.io/exporter/stackdriver/README.md Install the OpenCensus Stackdriver exporter package using the Go tool. ```bash $ go get -u contrib.go.opencensus.io/exporter/stackdriver ``` -------------------------------- ### Create root logger with logimpl.New Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/go-logr/logr/README.md Shows the early application setup where the root logger is created using the chosen logging implementation. The logger is then available for passing to other libraries or storing in structs. ```go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... ``` -------------------------------- ### Start Minikube cluster Source: https://github.com/agones-dev/agones/blob/main/build/docs/development-workflow.md Starts the Minikube cluster if it is not already running. This is the first step in setting up the remote debugging environment. ```bash make minikube-test-cluster ``` -------------------------------- ### Expose /live and /ready endpoints Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/heptiolabs/healthcheck/README.md Starts an HTTP server on port 8086 that exposes the /live and /ready endpoints. ```go go http.ListenAndServe("0.0.0.0:8086", health) ``` -------------------------------- ### Build and push simple-game-server image to Minikube Source: https://github.com/agones-dev/agones/blob/main/build/docs/building-testing.md Run from the examples/simple-game-server directory. Builds the image for the host architecture and loads it into the agones Minikube profile, re-tagging it to match the production image reference so existing YAML files pick up changes without edits. ```bash make build-linux-image-$(dpkg --print-architecture) && make minikube-push ``` -------------------------------- ### Example output for interactive SDK port forwarding Source: https://github.com/agones-dev/agones/blob/main/build/docs/development-workflow.md Example output from the interactive mode of minikube-debug-sdk-portforward. It shows the list of pods with the agones-gameserver-sidecar container and the port forwarding messages. ```text Searching for pods with agones-gameserver-sidecar container... Found pods with agones-gameserver-sidecar container: 1 simple-game-server-7d94f 2 xonotic-gameserver-9x8k2 3 unity-gameserver-m3n7q Select pod number (1-3): 2 Port forwarding to pod: xonotic-gameserver-9x8k2 Forwarding from 127.0.0.1:2351 -> 2346 Forwarding from [::1]:2351 -> 2346 ``` -------------------------------- ### Create a Fleet Source: https://github.com/agones-dev/agones/blob/main/examples/autoscaler-wasm/README.md Create a Fleet of game servers using the simple-game-server example. ```bash kubectl apply -f ../simple-game-server/fleet.yaml ``` -------------------------------- ### Go: RuntimeConfig initialization alternatives Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/tetratelabs/wazero/RATIONALE.md Shows three ways to initialize a RuntimeConfig in wazero. The first two are incorrect because fields are nil or the value is not a pointer; the third uses the NewRuntimeConfig constructor and is the correct approach. ```go rt := &RuntimeConfig{} // not initialized properly (fields are nil which shouldn't be) rt := RuntimeConfig{} // not initialized properly (should be a pointer) rt := wazero.NewRuntimeConfig() // initialized properly ``` -------------------------------- ### Build and run the example gameserver container Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Builds the Docker image and runs the container. Run in a separate terminal while the SDK-server is running. ```bash $ make build $ make run ``` -------------------------------- ### Get GameServer Pod logs with kubectl logs Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/troubleshooting.md Retrieve logs from a specific container in a GameServer Pod using `kubectl logs -c `. The example output shows the SDK instance creation, health ping start, UDP server startup on port 7654, and the server being marked ready. ```bash kubectl logs simple-game-server-zqppv -c simple-game-server ``` ```text 2019/08/16 21:26:23 Creating SDK instance 2019/08/16 21:26:24 Starting Health Ping 2019/08/16 21:26:24 Starting UDP server, listening on port 7654 2019/08/16 21:26:24 Marking this server as ready ``` -------------------------------- ### Install go-openapi/swag root package (backward compatibility) Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/go-openapi/swag/README.md Use this command for backward compatibility to install the root go-openapi/swag package. The root package is deprecated; prefer child modules for new features. ```cmd go get github.com/go-openapi/swag ``` -------------------------------- ### Run SDK Server from source: git clone and go run Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/Client SDKs/local.md These commands first clone the Agones repository and switch to the latest release branch or tag, then run the SDK Server in local mode from the clone directory. Requires Go installed and the Agones repository cloned. ```bash git clone https://github.com/agones-dev/agones.git cd agones git checkout release-{{< release-version >}} ``` ```go go run cmd/sdk-server/main.go --local ``` -------------------------------- ### Build Docker Image and Create GameServer Source: https://github.com/agones-dev/agones/blob/main/examples/unity-simple/README.md Builds the server Docker image and deploys the GameServer to Kubernetes. Run these commands from the example directory after building the server. ```bash $ make build-image $ kubectl create -f gameserver.yaml ``` -------------------------------- ### Create a GameServer with the Agones Go Client (in-cluster) Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/access-api.md In-cluster Go client example that creates an Agones Clientset and a GameServer. Uses rest.InClusterConfig() for authentication and creates a GameServer with a static UDP port. The full example is available in the examples/crd-client/main.go folder. ```go package main import ( "fmt" "context" agonesv1 "agones.dev/agones/pkg/apis/agones/v1" "agones.dev/agones/pkg/client/clientset/versioned" "agones.dev/agones/pkg/util/runtime" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" ) func main() { config, err := rest.InClusterConfig() logger := runtime.NewLoggerWithSource("main") if err != nil { logger.WithError(err).Fatal("Could not create in cluster config") } // Access to standard Kubernetes resources through the Kubernetes Clientset // We don't actually need this for this example, but it's just here for // illustrative purposes kubeClient, err := kubernetes.NewForConfig(config) if err != nil { logger.WithError(err).Fatal("Could not create the kubernetes clientset") } // Access to the Agones resources through the Agones Clientset // Note that we reuse the same config as we used for the Kubernetes Clientset agonesClient, err := versioned.NewForConfig(config) if err != nil { logger.WithError(err).Fatal("Could not create the agones api clientset") } // Create a GameServer gs := &agonesv1.GameServer{ObjectMeta: metav1.ObjectMeta{GenerateName: "simple-game-server", Namespace: "default"}, Spec: agonesv1.GameServerSpec{ Container: "simple-game-server", Ports: []agonesv1.GameServerPort{{ ContainerPort: 7654, HostPort: 7654, Name: "gameport", PortPolicy: agonesv1.Static, Protocol: corev1.ProtocolUDP, }}, Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ Containers: []corev1.Container{{Name: "simple-game-server", Image: "{{% example-image %}}"}}, }, }, }, } newGS, err := agonesClient.AgonesV1().GameServers("default").Create(context.TODO(), gs, metav1.CreateOptions{}) if err != nil { panic(err) } fmt.Printf("New game servers' name is: %s", newGS.ObjectMeta.Name) } ``` -------------------------------- ### Install Agones 1.36.0 with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.36.0.md Install the Agones 1.36.0 Helm chart. Ensure the stable repository is added first with `helm repo add agones https://agones.dev/chart/stable`. ```bash helm install agones agones/agones --version 1.36.0 ``` -------------------------------- ### Run SDK-server for local testing Source: https://github.com/agones-dev/agones/blob/main/examples/nodejs-simple/README.md Starts an SDK-server for 120 seconds with specific tests. Run from the build directory. ```bash $ cd ../../build; make run-sdk-conformance-local TIMEOUT=120 TESTS=ready,watch,health,gameserver ``` -------------------------------- ### Run the simple C++ gameserver with kubectl create Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Tutorials/simple-gameserver-cpp.md Creates the pre-built simple C++ gameserver from the provided YAML and captures the generated GameServer name. The game server uses the Agones SDK, calls SDK::Ready(), prints messages every 10 seconds, and calls SDK::Shutdown() after a minute. ```bash kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/cpp-simple/gameserver.yaml GAMESERVER_NAME=$(kubectl get gs -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') ``` -------------------------------- ### Successful run output Source: https://github.com/agones-dev/agones/blob/main/test/load/allocation/README.md Example output from the runAllocation.sh script showing the start and end timestamps for a successful run. ```text started: 2020-10-22 23:33:25.828724579 -0700 PDT m=+0.005921014 finished: 2020-10-22 23:34:18.381396416 -0700 PDT m=+52.558592912 ``` -------------------------------- ### Expected output of agones-allocator service lookup Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Advanced/allocator-service.md Example output from the kubectl get service command, showing the LoadBalancer external IP and port mapping. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE agones-allocator LoadBalancer 10.55.251.73 34.82.195.204 443:30250/TCP 5m ``` -------------------------------- ### Run gRPC allocation client Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Advanced/allocator-service.md Runs the Go gRPC client example to allocate a Game Server in the specified namespace. Requires the environment variables set in the previous step. ```bash #!/bin/bash go run examples/allocator-client/main.go --ip ${EXTERNAL_IP} \ --port 443 \ --namespace ${NAMESPACE} \ --key ${KEY_FILE} \ --cert ${CERT_FILE} \ --cacert ${TLS_CA_FILE} ``` -------------------------------- ### Initialize AgonesSDK Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/Client SDKs/csharp.md Creates a new instance of the AgonesSDK wrapper. Requires adding 'using Agones;' at the beginning of relevant files. ```csharp var agones = new AgonesSDK(); ``` -------------------------------- ### Import Blackfriday v2 in Go Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/russross/blackfriday/v2/README.md Imports the Blackfriday v2 package in a Go source file. After adding this import, running `go get` without parameters installs the package. ```go import "github.com/russross/blackfriday/v2" ``` -------------------------------- ### Create a GameServer with kubectl Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Getting Started/create-gameserver.md Use this command to create a GameServer from the example YAML file hosted on GitHub. The output confirms the creation of the GameServer record. ```bash kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/simple-game-server/gameserver.yaml ``` ```text gameserver.agones.dev/simple-game-server-4ss4j created ``` -------------------------------- ### Get Agones SDK instance from GameObject Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/Client SDKs/unity.md Retrieves the Agones SDK component from a GameObject so you can start using the SDK. Attach the script to a GameObject and call this to obtain the SDK instance. ```csharp var agones = agonesGameObject.GetComponent(); ``` -------------------------------- ### Replace client.Copy for query jobs with query.Run Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/CHANGES.md To start a query job, create a Query and call its Run method. Replace client.Copy(ctx, table, query) with query.Run(ctx). Set fields on the query instead of passing options. ```go client.Copy(ctx, table, query) ``` ```go query.Run(ctx) ``` -------------------------------- ### Default HA pod deployment output Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Advanced/high-availability-agones.md Example output of kubectl get pods showing the default high availability deployment: 2 agones-controller, 2 agones-extensions, 3 agones-allocator, and 2 agones-ping pods. ```text NAME READY STATUS RESTARTS AGE agones-allocator-78c6b8c79-h9nqc 1/1 Running 0 23h agones-allocator-78c6b8c79-l2bzp 1/1 Running 0 23h agones-allocator-78c6b8c79-rw75j 1/1 Running 0 23h agones-controller-fbf944f4-vs9xx 1/1 Running 0 23h agones-controller-fbf944f4-sjk3t 1/1 Running 0 23h agones-extensions-5648fc7dcf-hm6lk 1/1 Running 0 23h agones-extensions-5648fc7dcf-qbc6h 1/1 Running 0 23h agones-ping-5b9647874-2rrl6 1/1 Running 0 27h agones-ping-5b9647874-rksgg 1/1 Running 0 27h ``` -------------------------------- ### Invalid argument "/agones-controller:1.29.0-961d8ae-amd64" for "-t, --tag" flag: invalid reference format Source: https://github.com/agones-dev/agones/blob/main/build/docs/troubleshooting.md This error indicates the $(REGISTRY) variable is not set in ~/agones/build/Makefile. For GKE, follow the Cluster Setup Guide to create a registry and export the path. ```text Invalid argument "/agones-controller:1.29.0-961d8ae-amd64" for "-t, --tag" flag: invalid reference format ``` -------------------------------- ### Unity Editor and OS Prerequisites Source: https://github.com/agones-dev/agones/blob/main/examples/unity-simple/README.md Lists the supported Unity Editor version and operating systems required to run this example. Use this to verify your development environment before building. ```text Unity Editor: Unity 2018.4.2f1 or later OS: Windows 10 Pro or MacOS ``` -------------------------------- ### Add fork as origin and run tests Source: https://github.com/agones-dev/agones/blob/main/vendor/go.opencensus.io/CONTRIBUTING.md Adds your fork as a remote, then installs tools and runs the test suite. The make install-tools command is only needed the first time. ```shell cd $(go env GOPATH)/src/go.opencensus.io git remote add fork git@github.com:YOUR_GITHUB_USERNAME/opencensus-go.git ``` ```shell $ make install-tools # Only first time. $ make ``` -------------------------------- ### Create AKS cluster and get credentials Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Creating Cluster/aks.md Creates an AKS cluster with four nodes, installs kubectl, and fetches credentials. Requires prior `az login` when using the local Azure CLI. The `--kubernetes-version` uses the placeholder `{{% aks-example-cluster-version %}}`; replace it with a valid version. ```bash # Declare necessary variables, modify them according to your needs AKS_RESOURCE_GROUP=akstestrg # Name of the resource group your AKS cluster will be created in AKS_NAME=akstest # Name of your AKS cluster AKS_LOCATION=westeurope # Azure region in which you'll deploy your AKS cluster # Create the Resource Group where your AKS resource will be installed az group create --name $AKS_RESOURCE_GROUP --location $AKS_LOCATION # Create the AKS cluster - this might take some time. Type 'az aks create -h' to see all available options # The following command will create a four Node AKS cluster. Node size is Standard A1 v1 and Kubernetes version is {{% aks-example-cluster-version %}}. Plus, SSH keys will be generated for you, use --ssh-key-value to provide your values az aks create --resource-group $AKS_RESOURCE_GROUP --name $AKS_NAME --node-count 4 --generate-ssh-keys --node-vm-size Standard_A4_v2 --kubernetes-version {{% aks-example-cluster-version %}} --enable-node-public-ip # Install kubectl sudo az aks install-cli # Get credentials for your new AKS cluster az aks get-credentials --resource-group $AKS_RESOURCE_GROUP --name $AKS_NAME ``` -------------------------------- ### Set Makefile Variables in local-includes/images.mk Source: https://github.com/agones-dev/agones/blob/main/build/docs/building-testing.md Place this file in the local-includes directory to permanently set Makefile variables for your local setup. This example disables Windows and Arm64 image builds, leaving only Linux images. The file is ignored by git, so it won't affect the shared repository. ```makefile # Just Linux WITH_WINDOWS=0 WITH_ARM64=0 ``` -------------------------------- ### Start Minikube with Agones profile Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Creating Cluster/minikube.md Starts a Minikube cluster with the Kubernetes version supported by Agones, using the `--kubernetes-version` flag and an `agones` profile via `-p` to keep it separate from other clusters. ```bash minikube start --kubernetes-version v{{% minikube-example-cluster-version %}} -p agones ``` -------------------------------- ### Install Prometheus with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/metrics.md Installs Prometheus using the Prometheus Community Helm chart with a 30s scrape interval, a 64Gi persistent volume, and the Agones build/prometheus.yaml configuration. The chart schedules pods on nodes tainted with agones.dev/agones-metrics=true:NoExecute and labeled with agones.dev/agones-metrics=true if available. ```bash helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm upgrade --install --wait prom prometheus-community/prometheus --namespace metrics --create-namespace \ --version 28.9.0 \ --set server.global.scrape_interval=30s \ --set server.persistentVolume.enabled=true \ --set server.persistentVolume.size=64Gi \ -f ./build/prometheus.yaml ``` -------------------------------- ### npm install - install dependencies Source: https://github.com/agones-dev/agones/blob/main/sdks/nodejs/README.md Installs the project dependencies. ```bash npm install ``` -------------------------------- ### Run SDK Server locally with sdk-server.linux.amd64 Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Advanced/out-of-cluster-dev-server.md Starts the SDK Server so the game server binary can connect to it. The `--gameserver-name`, `--pod-namespace`, and `--kubeconfig` arguments must match the dev `GameServer` resource and cluster configuration. ```bash ./sdk-server.linux.amd64 \ --gameserver-name my-local-server \ --pod-namespace default \ --kubeconfig "$HOME/.kube/config" \ ``` -------------------------------- ### Install Agones 1.23.0 Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.23.0.md Command to install Agones 1.23.0 using the official installation YAML. This is the standard installation method for the release. ```bash kubectl create -f https://raw.githubusercontent.com/agonesdev/agones/release-1.23.0/install/yaml/install.yaml ``` -------------------------------- ### Replace AdminClient.CreateBucket with Client.Bucket().Create Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/CHANGES.md Migrate from the removed AdminClient.CreateBucket method to the new Client.Bucket().Create method. The new method requires a project ID argument. ```go adminClient.CreateBucket(ctx, bucketName, attrs) ``` ```go client.Bucket(bucketName).Create(ctx, projectID, attrs) ``` -------------------------------- ### Install development version Source: https://github.com/agones-dev/agones/blob/main/build/docs/cluster-setup.md Installs the development version with all imagePolicies set to always download. The resulting installation yaml can be found in build/.install.yaml. ```shell make install ``` -------------------------------- ### Initialize procfs and read CPU statistics Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/prometheus/procfs/README.md Shows how to create a new FS instance for /proc and call Stat() to retrieve CPU statistics. The error from NewFS is not checked in this example. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Install Agones 1.2.0 with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.2.0.md Add the Agones stable Helm repository before installing the 1.2.0 chart. The second command installs the chart with version 1.2.0. ```bash helm repo add agones https://agones.dev/chart/stable ``` ```bash helm install agones/agones --version 1.2.0 ``` -------------------------------- ### Replace client.CreateTable with DatasetInProject().Table().Create() Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/CHANGES.md Client.CreateTable has been removed. Use client.DatasetInProject(...).Table(...).Create(ctx) instead. ```go client.CreateTable(ctx, "project", "dataset", "table") ``` ```go client.DatasetInProject("project", "dataset").Table("table").Create(ctx) ``` -------------------------------- ### Install Grafana with Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Guides/metrics.md Installs Grafana using the Grafana Community Helm chart with the specified admin password and the build/grafana.yaml configuration. This installs Grafana with prepopulated dashboards and the Prometheus datasource. ```bash helm repo add grafana-community https://grafana-community.github.io/helm-charts helm repo update helm upgrade --install --wait grafana grafana-community/grafana --namespace metrics \ --set adminPassword= -f ./build/grafana.yaml ``` -------------------------------- ### Replace os.Open with AppFs.Open Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/spf13/afero/README.md Shows the before-and-after replacement when migrating from the OS package to an Afero filesystem variable. The first block is the original call and the second is the Afero equivalent. ```go os.Open("/tmp/foo") ``` ```go AppFs.Open("/tmp/foo") ``` -------------------------------- ### Run helm test agones to verify installation Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Installation/Install Agones/helm.md Use this command to verify the Agones Helm installation when the helm.installTests parameter is enabled. It runs the tests defined in the Helm chart to confirm the installation is working correctly. ```bash helm test agones ``` -------------------------------- ### Test case example: create and write file Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md Example test case that creates a new empty file with some data. The script watches /, writes data to /file, and expects create and write events in the output. ```text # Create a new empty file with some data. watch / echo data >/file Output: create /file write /file ``` -------------------------------- ### GameServer list output Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Examples/xonotic.md Example output showing two ready GameServers with their addresses and ports. ```text NAME STATE ADDRESS PORT NODE AGE xonotic-7lk8x-hgfrg Ready 34.71.168.92 7206 gk3-genai-quickstart-pool-3-ba2a705f-wpmc 103s xonotic-7lk8x-rwhst Ready 34.71.168.92 7330 gk3-genai-quickstart-pool-3-ba2a705f-wpmc 103s ``` -------------------------------- ### Create a JWW Notebook instance Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/spf13/jwalterweatherman/README.md Create a non-global Notebook instance with custom thresholds and output writers. The example shows a warning printed via the notepad; note the extra quote in the source. ```go notepad = jww.NewNotepad(jww.LevelInfo, jww.LevelTrace, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime) notepad.WARN.Println("Some warning"") ``` -------------------------------- ### Example commit message Source: https://github.com/agones-dev/agones/blob/main/vendor/cloud.google.com/go/CONTRIBUTING.md Example commit message following the Conventional Commits style with a scope of 'functions'. ```text feat(functions): add gophers codelab ``` -------------------------------- ### Run a fleet of C++ gameservers with kubectl create Source: https://github.com/agones-dev/agones/blob/main/site/content/en/docs/Tutorials/simple-gameserver-cpp.md Creates a fleet of C++ gameservers and captures the fleet name. Each gameserver exits after about a minute, and the fleet replaces it to maintain Ready ones. ```bash kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/{{< release-branch >}}/examples/cpp-simple/fleet.yaml FLEET_NAME=$(kubectl get fleets -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') ``` -------------------------------- ### Get values with viper.GetString and viper.GetBool Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/spf13/viper/README.md Shows how to retrieve values with Viper's Get functions. GetString returns a zero value if the key is not found; use IsSet to check existence. The comment notes that setting and getting are case-insensitive. ```go viper.GetString("logfile") // case-insensitive Setting & Getting if viper.GetBool("verbose") { fmt.Println("verbose enabled") } ``` -------------------------------- ### Install Agones with scenario values using helm Source: https://github.com/agones-dev/agones/blob/main/test/load/allocation/README.md Installs Agones with the scenario-specific configuration values from scenario-values.yaml. Use this command during installation to apply the node affinity and resource changes described above. Requires the scenario-values.yaml file to be present in the current directory. ```bash helm install my-release --namespace agones-system -f scenario-values.yaml agones/agones --create-namespace ``` -------------------------------- ### Run the C# allocator client with dotnet run Source: https://github.com/agones-dev/agones/blob/main/examples/allocator-client-csharp/README.md Shell script that configures the allocator client connection parameters and launches the C# client. Replace the namespace and certificate file paths as needed. Requires the client and server certificates to be set up first. ```bash #!/bin/bash NAMESPACE=default # replace with any namespace EXTERNAL_IP=`kubectl get services agones-allocator -n agones-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}'` KEY_FILE=client.key CERT_FILE=client.crt TLS_CA_FILE=ca.crt MULTICLUSTER_ENABLED=false dotnet run $KEY_FILE $CERT_FILE $TLS_CA_FILE $EXTERNAL_IP $NAMESPACE $MULTICLUSTER_ENABLED ``` -------------------------------- ### Install Agones 1.5.0-rc via Helm Source: https://github.com/agones-dev/agones/blob/main/site/content/en/blog/releases/1.5.0-rc.md Command to install the Agones 1.5.0-rc Helm chart from the stable repository. ```bash helm install agones/agones --version 1.5.0-rc ``` -------------------------------- ### Test script format example Source: https://github.com/agones-dev/agones/blob/main/vendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md Shows the basic format for creating test cases in the testdata directory using a shell-like syntax. The script is followed by an Output: section with the desired output. ```text script Output: desired output ```