apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nifi
spec:
  selector:
    matchLabels:
      app: nifi
  serviceName: nifi
  replicas: 3
  podManagementPolicy: Parallel
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: nifi
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: "app"
                    operator: In
                    values:
                    - nifi
              topologyKey: "kubernetes.io/hostname"
      containers:
        - name: nifi
          command: ["/bin/sh","-c"]
          args: ['sed -e "s/^search/& $(dnsdomainname)/" /etc/resolv.conf > /tmp/resolv.conf;cat /tmp/resolv.conf  > /etc/resolv.conf; cd /opt/nifi && ./start_nifi.sh']
          image: xemuliam/nifi:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
            - containerPort: 8081
            - containerPort: 8443
            - containerPort: 2882
          env:
            - name: ZK_NODES_LIST
              # Requires zookeeper running
              value: "zk-0.zk-hs.zk.svc.cluster.local,zk-1.zk-hs.zk.svc.cluster.local,zk-2.zk-hs.zk.svc.cluster.local"
            - name: ZK_MONITOR_PORT
              value: "2888"
            - name: IS_CLUSTER_NODE
              value: "yes"
            - name: BANNER_TEXT
              value: "Nifi Cluster"