apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: minecraft-server
spec:
  serviceName: minecraft-headless
  replicas: 1
  selector:
    matchLabels:
      app: minecraft-server
      tier: backend
      track: stable
  template:
    metadata:
      labels:
        app: minecraft-server
        tier: backend
        track: stable
    spec:
      restartPolicy: Always
      containers:
      - name: minecraft-server
        image: balmiusf/mcserver:latest
        env:
        - name: JAVA_MEM_SIZE 
          value: "3g"
        - name: EULA
          value: "true"
        ports:
        - name: mcserver
          containerPort: 25565 
        resources:
          requests:
            memory: 3Gi
            cpu: "1"
        volumeMounts:          
        - name: world-data
          mountPath: /opt/minecraft/world
        - name: minecraft-config
          mountPath: /opt/minecraft/server.properties
          subPath: server.properties   
      volumes:
        - name: minecraft-config
          configMap:
            name: minecraft-configuration
  volumeClaimTemplates:
  - metadata:
      name: world-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi