apiVersion: apps/v1
kind: Deployment
metadata:
  name: crafty
  namespace: crafty
  labels:
    app: crafty
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: crafty
  template:
    metadata:
      labels:
        app: crafty
    spec:
      securityContext:
        fsGroup: 0
      initContainers:
      - name: init-permissions
        image: busybox:latest
        command: ['sh', '-c', 'chown -R 1000:0 /crafty && chmod -R g+rwX /crafty']
        volumeMounts:
        - name: servers
          mountPath: /crafty/servers
        - name: config
          mountPath: /crafty/app/config
        securityContext:
          runAsUser: 0
      containers:
      - name: crafty
        image: registry.gitlab.com/crafty-controller/crafty-4:latest
        env:
        - name: TZ
          value: Asia/Seoul
        ports:
        - name: https
          containerPort: 8443
          protocol: TCP
        - name: dynmap
          containerPort: 8123
          protocol: TCP
        - name: bedrock
          containerPort: 19132
          protocol: UDP
        resources:
          requests:
            memory: "512Mi"
            cpu: "250m"
          limits:
            memory: "2Gi"
        volumeMounts:
        - name: servers
          mountPath: /crafty/servers
        - name: config
          mountPath: /crafty/app/config
        securityContext:
          allowPrivilegeEscalation: false
      volumes:
      - name: servers
        persistentVolumeClaim:
          claimName: crafty-servers
      - name: config
        persistentVolumeClaim:
          claimName: crafty-config
