--- #---------------- Orderer2 1Deployment ---------------
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: orderer2
  name: orderer2
  namespace: hyperledger
spec:
  selector:
    matchLabels:
      app: orderer2
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: orderer2
    spec:
      nodeSelector:
        tier: api
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: "app"
                      operator: In
                      values:
                        - orderer0
                        - orderer1
                topologyKey: "kubernetes.io/hostname"
      containers:
        - args:
            - orderer
          env:
            - name: FABRIC_LOGGING_SPEC
              value: DEBUG
            - name: ORDERER_OPERATIONS_LISTENADDRESS
              value: 0.0.0.0:8443
            - name: ORDERER_METRICS_PROVIDER
              value: prometheus
            - name: ORDERER_GENERAL_GENESISFILE
              value: /share/channel-artifacts/genesis.block
            - name: ORDERER_GENERAL_GENESISMETHOD
              value: file
            - name: ORDERER_GENERAL_LISTENADDRESS
              value: 0.0.0.0
            - name: ORDERER_GENERAL_LOCALMSPDIR
              value: /share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/msp
            - name: ORDERER_GENERAL_LOCALMSPID
              value: OrdererMSP
            - name: ORDERER_GENERAL_TLS_CERTIFICATE
              value: /share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/server.crt
            - name: ORDERER_GENERAL_TLS_ENABLED
              value: "true"
            - name: ORDERER_GENERAL_TLS_PRIVATEKEY
              value: /share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/server.key
            - name: ORDERER_GENERAL_TLS_ROOTCAS
              value: "[/share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/ca.crt]"
            - name: ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE
              value: /share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/server.crt
            - name: ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY
              value: /share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/server.key
            - name: ORDERER_GENERAL_CLUSTER_ROOTCAS
              value: "[/share/crypto-config/ordererOrganizations/consortium/orderers/orderer2/tls/ca.crt]"
          image: hyperledger/fabric-orderer:amd64-2.2.0
          name: orderer
          ports:
            - containerPort: 7050
            - containerPort: 8443
          volumeMounts:
            - mountPath: /var/hyperledger/production
              name: orderer-persistentdata
            - mountPath: /share
              name: share-persistentdata
          workingDir: /opt/gopath/src/github.com/hyperledger/fabric
      restartPolicy: Always
      volumes:
        - name: orderer-persistentdata
          persistentVolumeClaim:
            claimName: orderer2-pvc
        - name: share-persistentdata
          persistentVolumeClaim:
            claimName: share-pvc
