apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: rqlite
#  labels:
#    app: rqlite   # pas indispensable mais tellement plus pratique pour kubectl get all --selector
spec:
  selector:
    matchLabels:
      app: rqlite   # doit correspondre avec le(s) label(s) de template (plus bas) et aussi le(s) "selector" des services
  serviceName: rqlite-interne
  replicas: 3
  podManagementPolicy: Parallel
  template:
    metadata:
      labels:
        app: rqlite   # doit correspondre avec le(s) matchLabel(s) du StatefulSet (plus haut)
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: rqlited
          image: rqlite/rqlite
          args: ["-disco-mode=dns","-disco-config={\"name\":\"rqlite-interne\"}","-bootstrap-expect","3", "-join-interval=1s", "-join-attempts=120"]
          ports:
            - containerPort: 4001
              name: rqlite
          readinessProbe:
            httpGet:
              scheme: HTTP
              path: /readyz
              port: 4001
            periodSeconds: 5
            timeoutSeconds: 2
            initialDelaySeconds: 2
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /readyz?noleader
              port: rqlite
            initialDelaySeconds: 2
            timeoutSeconds: 2
            failureThreshold: 3
          volumeMounts:
            - name: donnees
              mountPath: /rqlite/file
  volumeClaimTemplates:
    - metadata:
        name: donnees
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: microk8s-hostpath
        resources:
          requests:
            storage: 100Mi
