From f4aacef7de40cbfeb6ffaa5167af923467950383 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Wed, 4 Oct 2023 14:22:50 -0700 Subject: [PATCH] Examples for relay configuration Updated examples from #772 moved into their own separate PR, so that when #772 is submitted, link checks om the quickstart documentation will resolve correctly. --- examples/agones-xonotic-relay/README.md | 3 + .../agones-xonotic-relay/client-token.yaml | 26 +++ examples/agones-xonotic-relay/fleet.yaml | 38 ++++ .../gameserverallocation.yaml | 23 +++ examples/agones-xonotic-relay/proxy-pool.yaml | 72 +++++++ .../relay-control-plane.yaml | 185 ++++++++++++++++++ 6 files changed, 347 insertions(+) create mode 100644 examples/agones-xonotic-relay/README.md create mode 100644 examples/agones-xonotic-relay/client-token.yaml create mode 100644 examples/agones-xonotic-relay/fleet.yaml create mode 100644 examples/agones-xonotic-relay/gameserverallocation.yaml create mode 100644 examples/agones-xonotic-relay/proxy-pool.yaml create mode 100644 examples/agones-xonotic-relay/relay-control-plane.yaml diff --git a/examples/agones-xonotic-relay/README.md b/examples/agones-xonotic-relay/README.md new file mode 100644 index 0000000000..e2f50ba206 --- /dev/null +++ b/examples/agones-xonotic-relay/README.md @@ -0,0 +1,3 @@ +# Agones & Xonotic via Relay Example + +This is the code example for the "Quickstart: Quilkin with Agones and Xonotic (Relay)" Guide, linked via the homepage. diff --git a/examples/agones-xonotic-relay/client-token.yaml b/examples/agones-xonotic-relay/client-token.yaml new file mode 100644 index 0000000000..1b99fc536a --- /dev/null +++ b/examples/agones-xonotic-relay/client-token.yaml @@ -0,0 +1,26 @@ +# +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +version: v1alpha1 +filters: + - name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes + config: + on_read: APPEND + on_write: DO_NOTHING + bytes: NDU2 # 456 +clusters: + - endpoints: + - address: ${LOADBALANCER_IP}:7777 diff --git a/examples/agones-xonotic-relay/fleet.yaml b/examples/agones-xonotic-relay/fleet.yaml new file mode 100644 index 0000000000..d486415226 --- /dev/null +++ b/examples/agones-xonotic-relay/fleet.yaml @@ -0,0 +1,38 @@ +# Copyright 2022 Google LLC All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Usually you would define a Fleet rather than a GameServerSet +# directly. This is here mostly for testing purposes + +apiVersion: "agones.dev/v1" +kind: Fleet +metadata: + name: xonotic +spec: + replicas: 3 + strategy: + type: Recreate + template: + spec: + ports: + - name: default + containerPort: 26000 + health: + initialDelaySeconds: 30 + periodSeconds: 60 + template: + spec: + containers: + - name: xonotic + image: us-docker.pkg.dev/agones-images/examples/xonotic-example:1.2 diff --git a/examples/agones-xonotic-relay/gameserverallocation.yaml b/examples/agones-xonotic-relay/gameserverallocation.yaml new file mode 100644 index 0000000000..6a7f1e24ab --- /dev/null +++ b/examples/agones-xonotic-relay/gameserverallocation.yaml @@ -0,0 +1,23 @@ +# Copyright 2022 Google LLC All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: "allocation.agones.dev/v1" +kind: GameServerAllocation +spec: + selectors: + - matchLabels: + agones.dev/fleet: xonotic + metadata: + annotations: + quilkin.dev/tokens: NDU2 # 456 diff --git a/examples/agones-xonotic-relay/proxy-pool.yaml b/examples/agones-xonotic-relay/proxy-pool.yaml new file mode 100644 index 0000000000..b404d31273 --- /dev/null +++ b/examples/agones-xonotic-relay/proxy-pool.yaml @@ -0,0 +1,72 @@ +# +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Pool of Quilkin proxies, tied to the +# Quilkin relay control plane in relay-control-plane.yaml +# + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + role: proxy + name: quilkin-proxies +spec: + replicas: 3 + selector: + matchLabels: + role: proxy + template: + metadata: + labels: + role: proxy + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8000" + spec: + containers: + - name: quilkin + image: us-docker.pkg.dev/quilkin-mark-dev/release/quilkin:0.7.0 + args: ["proxy", "--management-server", "http://quilkin-relay-agones:7800"] + env: + - name: RUST_LOG + value: info #,quilkin=trace + livenessProbe: + failureThreshold: 3 + httpGet: + path: /live + port: 8000 + scheme: HTTP + ports: + - containerPort: 7777 + protocol: UDP + +--- +apiVersion: v1 +kind: Service +metadata: + name: quilkin-proxies +spec: + ports: + - port: 7777 + protocol: UDP + targetPort: 7777 + selector: + role: proxy + type: LoadBalancer diff --git a/examples/agones-xonotic-relay/relay-control-plane.yaml b/examples/agones-xonotic-relay/relay-control-plane.yaml new file mode 100644 index 0000000000..b7ca789bdd --- /dev/null +++ b/examples/agones-xonotic-relay/relay-control-plane.yaml @@ -0,0 +1,185 @@ +# +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Everything to setup the relay and agent Agones control plane +# + +--- +# ANCHOR: config-map +apiVersion: v1 +kind: ConfigMap +metadata: + name: quilkin-relay-filter-config + labels: + quilkin.dev/configmap: "true" +data: + quilkin.yaml: | + version: v1alpha1 + filters: + - name: quilkin.filters.capture.v1alpha1.Capture + config: + suffix: + size: 3 + remove: true + - name: quilkin.filters.token_router.v1alpha1.TokenRouter +# ANCHOR_END: config-map + +--- + +# RBAC Setup for Agones Relay Control Plane + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: quilkin-agones +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: quilkin-agones +rules: + - apiGroups: + - agones.dev + resources: + - gameservers + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: quilkin-agones +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: quilkin-agones +subjects: + - apiGroup: rbac.authorization.k8s.io + kind: User + name: system:serviceaccount:default:quilkin-agones +--- + +# Quilkin Relay server + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + role: xds + name: quilkin-relay-agones +spec: + replicas: 1 + selector: + matchLabels: + role: xds + template: + metadata: + labels: + role: xds + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8000" + spec: + containers: + - name: quilkin + args: + - relay + - agones + env: + - name: RUST_LOG + value: info + image: us-docker.pkg.dev/quilkin-mark-dev/release/quilkin:0.7.0 + livenessProbe: + failureThreshold: 3 + httpGet: + path: /live + port: 8000 + scheme: HTTP + ports: + - containerPort: 7800 + protocol: TCP + serviceAccountName: quilkin-agones +--- + +# Quilkin Agones Agent + +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + role: xds + name: quilkin-agones-agent +spec: + replicas: 1 + selector: + matchLabels: + role: xds + template: + metadata: + labels: + role: xds + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8000" + spec: + containers: + - name: quilkin + args: + - agent + - --relay + - http://quilkin-relay-agones:7900 + - agones + env: + - name: RUST_LOG + value: info + image: us-docker.pkg.dev/quilkin-mark-dev/release/quilkin:0.7.0 + livenessProbe: + failureThreshold: 3 + httpGet: + path: /live + port: 8000 + scheme: HTTP + serviceAccountName: quilkin-agones +--- +apiVersion: v1 +kind: Service +metadata: + name: quilkin-relay-agones +spec: + ports: + - name: ads + port: 7800 + protocol: TCP + targetPort: 7800 + - name: cpds + port: 7900 + protocol: TCP + targetPort: 7900 + selector: + role: xds