apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: unrealircd
  name: unrealircd
spec:
  podManagementPolicy: OrderedReady
  replicas: 1  # Never scale more than 1 replica. This will most probably corrupt the data.
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: unrealircd
  serviceName: unrealircd
  template:
    metadata:
      labels:
        app: unrealircd
    spec:
      containers:
      - image: faforever/faf-unrealircd:5.2.4
        imagePullPolicy: IfNotPresent
        name: unrealircd
        envFrom:
          - configMapRef:
              name: unrealircd
          - secretRef:
              name: unrealircd
        ports:
        - containerPort: 6667
          protocol: TCP
        - containerPort: 6697
          protocol: TCP
        - containerPort: 8167
          protocol: TCP
        # Anope control port
        - containerPort: 7000
          protocol: TCP
        volumeMounts:
        - name: data
          mountPath: /data/unrealircd/data/
        - name: config
          mountPath: /data/unrealircd/conf/unrealircd.conf
          subPath: unrealircd.conf
        - name: config
          mountPath: /data/unrealircd/conf/ircd.motd
          subPath: ircd.motd
        - name: config
          mountPath: /data/unrealircd/conf/tls/server.cert.pem
          subPath: tls/server.cert.pem
          readOnly: true
        - name: config
          mountPath: /data/unrealircd/conf/tls/server.key.pem
          subPath: tls/server.key.pem
          readOnly: true
      restartPolicy: Always
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: unrealircd-pvc
      - name: config
        projected:
          sources:
            - configMap:
                name: unrealircd
                items:
                  - key: unrealircd.conf
                    path: unrealircd.conf
                  - key: ircd.motd
                    path: ircd.motd
            - secret:
                name: unrealircd
                items:
                  - key: server.cert.pem
                    path: tls/server.cert.pem
                  - key: server.key.pem
                    path: tls/server.key.pem
