apiVersion: apps/v1
kind: Deployment
metadata:
  name: minecraft
spec:
  replicas: 0
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: minecraft
  template:
    metadata:
      labels:
        app: minecraft
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 2000
      containers:
        - name: minecraft
          image: itzg/minecraft-server:latest
          imagePullPolicy: Always
          resources:
            requests:
              memory: 512Mi
              cpu: 500m
          readinessProbe:
            tcpSocket:
              port: 25565
            initialDelaySeconds: 30
            periodSeconds: 5
            failureThreshold: 10
            successThreshold: 1
            timeoutSeconds: 1
          livenessProbe:
            tcpSocket:
              port: 25565
            initialDelaySeconds: 30
            periodSeconds: 5
            failureThreshold: 10
            successThreshold: 1
            timeoutSeconds: 1
          envFrom:
            - configMapRef:
                name: minecraft-configmap
          ports:
            - name: minecraft
              containerPort: 25565
              protocol: TCP
            - name: metrics
              containerPort: 9225
              protocol: TCP
          volumeMounts:
            - name: datadir
              mountPath: /data
      volumes:
        - name: datadir
          persistentVolumeClaim:
            claimName: minecraft-datadir
