---
apiVersion: v1
kind: ConfigMap
metadata:
  name: server-config
data:
  config.yaml: |
    fragLimit: 25
    timeLimit: 15m
    bot:
      minPlayers: 3
    game:
      motd: "Welcome to my Urban Terror server"
      type: FreeForAll
      forceRespawn: false
      inactivity: 10m
    server:
      hostname: "quakekube"
      maxClients: 12
      # password: "changeme"
    commands:
      - addbot sarge 2
    maps:
    - name: ut4_uptown
      type: FreeForAll
      timeLimit: 10m
    - name: ut4_swim
      type: FreeForAll
---
apiVersion: "agones.dev/v1"
kind: GameServer
metadata:
  name: urbanterror
  labels:
    cluster: gke-1.17
    region: us-east-1
spec:
  container: gameserver
  players:
    initialCapacity: 8
  ports:
    - name: default
      portPolicy: Static
      containerPort: 27000
      hostPort: 27000
      protocol: UDP
    - name: client
      portPolicy: Static
      containerPort: 27080
      hostPort: 27080
      protocol: TCP
  template:
    spec:
      containers:
        - name: gameserver
          imagePullPolicy: IfNotPresent
          image: gitea.bp99.eu/bp99/urban-terror-server:latest
          command:
            - q3
            - server
            - --config=/config/config.yaml
            - --assets-dir=/root/.q3a
            - --content-server=http://127.0.0.1:9090
            - --agree-eula
            - --client-addr=0.0.0.0:8081
            - --server-addr=0.0.0.0:27000
            - --with-agones
          ports:
            - containerPort: 8081
          readinessProbe:
            tcpSocket:
              port: 8081
            initialDelaySeconds: 15
            periodSeconds: 5
          resources:
            requests:
              memory: "1Gi"
              cpu: "0.5"
            limits:
              memory: "2Gi"
              cpu: "1"
          volumeMounts:
            - name: server-config
              mountPath: /config
            - name: content
              mountPath: /assets
        - name: content-server
          imagePullPolicy: Always
          image: gitea.bp99.eu/bp99/urban-terror-server:latest
          command:
            - q3
            - content
            - --seed-content-url=http://content.quakejs.com
          ports:
            - containerPort: 9090
          resources:
            requests:
              memory: "1Gi"
              cpu: "0.5"
            limits:
              memory: "2Gi"
              cpu: "1"
          volumeMounts:
            - name: content
              mountPath: /assets
      volumes:
        - name: server-config
          configMap:
            name: server-config
        - name: content
          emptyDir: {}
