From ef95e10b97d8ed7a008cf49f9e8fcd81e9ebfa42 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 19 Apr 2023 19:37:53 -0400 Subject: [PATCH] Add factorio game server --- .../game-servers/factorio/helm-release.yaml | 67 +++++++++++++++++++ .../game-servers/factorio/kustomization.yaml | 4 ++ cluster/apps/game-servers/kustomization.yaml | 6 ++ cluster/apps/game-servers/namespace.yaml | 6 ++ cluster/apps/game-servers/network_policy.yaml | 25 +++++++ cluster/apps/kustomization.yaml | 1 + .../core/networking/traefik/helm-release.yaml | 1 + 7 files changed, 110 insertions(+) create mode 100644 cluster/apps/game-servers/factorio/helm-release.yaml create mode 100644 cluster/apps/game-servers/factorio/kustomization.yaml create mode 100644 cluster/apps/game-servers/kustomization.yaml create mode 100644 cluster/apps/game-servers/namespace.yaml create mode 100644 cluster/apps/game-servers/network_policy.yaml diff --git a/cluster/apps/game-servers/factorio/helm-release.yaml b/cluster/apps/game-servers/factorio/helm-release.yaml new file mode 100644 index 0000000..2c8cb39 --- /dev/null +++ b/cluster/apps/game-servers/factorio/helm-release.yaml @@ -0,0 +1,67 @@ +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: factorio + namespace: game-server +spec: + interval: 5m + chart: + spec: + chart: app-template + version: 1.3.x + sourceRef: + kind: HelmRepository + name: bjws-charts + namespace: flux-system + + values: + image: + repository: factoriotools/factorio + tag: latest + + service: + main: + ports: + http: + enabled: false + + game: + enabled: true + primary: true + port: 34197 + targetPort: 34197 + protocol: UDP + + probes: + liveness: + enabled: false + + ingress: + main: + enabled: true + annotations: + traefik.ingress.kubernetes.io/router.entrypoints: factorio + hosts: + - host: &host "fact.${SECRET_NEW_DOMAIN}" + paths: + - path: / + pathType: Prefix + service: + port: + name: game + + persistence: + data: + enabled: true + type: hostPath + hostPath: /mnt/MainPool/Kubernetes/cdn + readOnly: true + mountPath: /data + config: + enabled: true + type: configMap + name: nginx-cdn-configmap + + resources: + requests: + cpu: 1m \ No newline at end of file diff --git a/cluster/apps/game-servers/factorio/kustomization.yaml b/cluster/apps/game-servers/factorio/kustomization.yaml new file mode 100644 index 0000000..ea3145d --- /dev/null +++ b/cluster/apps/game-servers/factorio/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ./helm-release.yaml \ No newline at end of file diff --git a/cluster/apps/game-servers/kustomization.yaml b/cluster/apps/game-servers/kustomization.yaml new file mode 100644 index 0000000..6bcf363 --- /dev/null +++ b/cluster/apps/game-servers/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ./namespace.yaml +- ./network_policy.yaml +- ./factorio \ No newline at end of file diff --git a/cluster/apps/game-servers/namespace.yaml b/cluster/apps/game-servers/namespace.yaml new file mode 100644 index 0000000..2ca29d0 --- /dev/null +++ b/cluster/apps/game-servers/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: game-servers + labels: + name: game-servers \ No newline at end of file diff --git a/cluster/apps/game-servers/network_policy.yaml b/cluster/apps/game-servers/network_policy.yaml new file mode 100644 index 0000000..0fa98ed --- /dev/null +++ b/cluster/apps/game-servers/network_policy.yaml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: deny-most-allow-some + namespace: game-servers +spec: + # Apply to all pods in this namespace + podSelector: {} + ingress: + - from: + # Allow all pods in this namespace + - namespaceSelector: + matchLabels: + name: "game-servers" +# - podSelector: {} + + # Allow traefik pods + - namespaceSelector: + matchLabels: + name: "traefik" + + # Allow all pods with this label + - podSelector: + matchLabels: + needsGameServers: "yes" \ No newline at end of file diff --git a/cluster/apps/kustomization.yaml b/cluster/apps/kustomization.yaml index c937a0c..8ddaf85 100644 --- a/cluster/apps/kustomization.yaml +++ b/cluster/apps/kustomization.yaml @@ -10,4 +10,5 @@ resources: - ./irc - ./monitoring - ./default +- ./game-servers #- ./harbor \ No newline at end of file diff --git a/cluster/core/networking/traefik/helm-release.yaml b/cluster/core/networking/traefik/helm-release.yaml index ceb1a7a..c3c9291 100644 --- a/cluster/core/networking/traefik/helm-release.yaml +++ b/cluster/core/networking/traefik/helm-release.yaml @@ -17,6 +17,7 @@ spec: values: additionalArguments: - --api.insecure + - --entryPoints.factorio.address=:34197/udp logs: general: