apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: mosquitto
  name: mosquitto
spec:
  podManagementPolicy: OrderedReady
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: mosquitto
  serviceName: mosquitto-headless
  template:
    metadata:
      labels:
        app.kubernetes.io/name: mosquitto
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - mosquitto
              topologyKey: kubernetes.io/hostname
            weight: 100
      containers:
      - image: eclipse-mosquitto
        imagePullPolicy: Always
        name: mosquitto
        ports:
        - containerPort: 1883
          name: mqtt
          protocol: TCP
        volumeMounts:
        - mountPath: /mosquitto/config
          name: config-volume
        - mountPath: /mosquitto/data
          name: data
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext:
        fsGroup: 1883
        runAsUser: 1883
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 420
          name: mosquitto
        name: config-volume
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      volumeMode: Filesystem
      storageClassName: azurefile
