apiVersion: v1
kind: Namespace
metadata:
  name: cs2ds

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cs2ds
  namespace: cs2ds
data:
  CS2_ADDITIONAL_ARGS: ""
  CS2_BOT_DIFFICULTY: "3"
  CS2_GAMEMODE: "1"
  CS2_GAMETYPE: "0"
  CS2_IP: 0.0.0.0
  CS2_MAPGROUP: mg_active
  CS2_MAXPLAYERS: "12"
  CS2_PORT: "32715"
  CS2_PW: topsecret
  CS2_RCON_PORT: "32720"
  CS2_RCONPW: topmegasecret
  CS2_SERVERNAME: 473x0
  CS2_STARTMAP: de_anubis
  SRCDS_TOKEN: xxxxxxx

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: cs2ds
  name: cs2ds
  namespace: cs2ds
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 60Gi

---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: cs2ds
  name: cs2ds
  namespace: cs2ds
spec:
  selector:
    matchLabels:
      app: cs2ds
  template:
    metadata:
      labels:
        app: cs2ds
      namespace: cs2ds
    spec:
      containers:
        - name: cs2ds
          image: joedwards32/cs2:latest
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: cs2ds
                optional: false
          ports:
            - containerPort: 32715
              name: cs2ds-tcp
              protocol: TCP
            - containerPort: 32715
              name: cs2ds-udp
              protocol: UDP
            - containerPort: 32720
              name: cs2ds-rcon-tcp
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
          volumeMounts:
            - mountPath: /home/steam/cs2-dedicated/
              name: cs2ds-data
      securityContext:
        fsGroup: 1000
        runAsGroup: 1000
        runAsNonRoot: true
        runAsUser: 1000
        seccompProfile:
          type: RuntimeDefault
      volumes:
        - name: cs2ds-data
          persistentVolumeClaim:
            claimName: cs2ds

---
apiVersion: v1
kind: Service
metadata:
  name: cs2ds
  namespace: cs2ds
spec:
  type: NodePort
  selector:
    app: cs2ds
  ports:
    - name: cs2ds-tcp
      nodePort: 32715
      port: 32715
      protocol: TCP
      targetPort: cs2ds-tcp
    - name: cs2ds-udp
      nodePort: 32715
      port: 32715
      protocol: UDP
      targetPort: cs2ds-udp
    - name: cs2ds-rcon-tcp
      nodePort: 32720
      port: 32720
      protocol: TCP
      targetPort: cs2ds-rcon-tcp
