apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: broker
  namespace: openfaas
spec:
  selector:
    matchLabels:
      app: broker # has to match .spec.template.metadata.labels
  serviceName: "broker"
  replicas: 1 # Alter to match number of nodes, use "1" for the defaults
  template:
    metadata:
      labels:
        app: broker
        role: broker
        namespace: openfaas
    spec:
      terminationGracePeriodSeconds: 30
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - broker
            topologyKey: kubernetes.io/hostname
      containers:
      - env:
        - name: EMITTER_LICENSE  # <- Provide license
          value: "RfBEIGQlQNSLQfIlm-b4s-TNJirEjMhJu7rGA5FJW8BTMFTTGADk2MX9Tq0AaT_20-of7cDM-clmRbb7Z-n5itgHubSCgwcB:2"
        - name: EMITTER_CLUSTER_SEED
          value: "broker" # or "broker-0.broker.default.svc.cluster.local"
        - name: EMITTER_CLUSTER_ADVERTISE
          value: "private:4000"
        - name: EMITTER_STORAGE_PROVIDER
          value: "ssd"
        name: broker
        image: emitter/server:latest
        ports:
          - containerPort: 8080
          - containerPort: 443
          - containerPort: 4000
        volumeMounts:
          - name: broker-volume
            mountPath: /data
      restartPolicy: Always
  updateStrategy:
    type: RollingUpdate
  volumeClaimTemplates:
  - metadata:
      name: broker-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: local-path
      resources:
        requests:
          storage: 10Gi
