apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app: enmasse
  name: standard-broker-definitions
data:
  queue-persisted.yaml: |-
    apiVersion: v1
    kind: Template
    metadata:
      labels:
        app: enmasse
      name: queue-persisted
    objects:
    - apiVersion: v1
      kind: Service
      metadata:
        annotations:
          addressSpace: ${ADDRESS_SPACE}
          cluster_id: ${CLUSTER_ID}
        labels:
          app: enmasse
          infraType: standard
          infraUuid: ${INFRA_UUID}
        name: ${NAME}
      spec:
        clusterIP: None
        selector:
          name: ${NAME}
          role: broker
          infraUuid: ${INFRA_UUID}
    - apiVersion: apps/v1
      kind: StatefulSet
      metadata:
        annotations:
          address: ${ADDRESS}
          addressSpace: ${ADDRESS_SPACE}
          cluster_id: ${CLUSTER_ID}
          enmasse.io/cert-cn: broker.${INFRA_UUID}
          enmasse.io/cert-secret: broker-internal-cert.${INFRA_UUID}
        labels:
          app: enmasse
          infraType: standard
          infraUuid: ${INFRA_UUID}
        name: ${NAME}
      spec:
        affinity:
          nodeAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
              - weight: 1
                preference:
                  matchExpressions:
                    - key: node-role.enmasse.io/messaging-infra
                      operator: In
                      values:
                        - "true"
        replicas: 1
        serviceName: ${NAME}
        selector:
          matchLabels:
            addresstype: queue
            app: enmasse
            name: ${NAME}
            role: broker
            infraType: standard
            infraUuid: ${INFRA_UUID}
        template:
          metadata:
            annotations:
              address: ${ADDRESS}
              addressSpace: ${ADDRESS_SPACE}
              cluster_id: ${CLUSTER_ID}
              prometheus.io/path: /metrics
              prometheus.io/port: '8080'
              prometheus.io/scrape: 'true'
            labels:
              addresstype: queue
              app: enmasse
              name: ${NAME}
              role: broker
              infraType: standard
              infraUuid: ${INFRA_UUID}
          spec:
            containers:
            - env:
              - name: MESSAGING_SERVICE_HOST
                value: messaging-${INFRA_UUID}
              - name: MESSAGING_SERVICE_PORT_AMQPS_BROKER
                value: 56671
              - name: MESSAGING_SERVICE_PORT_AMQPS_NORMAL
                value: 55671
              - name: INFRA_UUID
                value: ${INFRA_UUID}
              - name: QUEUE_NAME
                value: ${ADDRESS}
              - name: CLUSTER_ID
                value: ${CLUSTER_ID}
              - name: CERT_DIR
                value: /etc/enmasse-certs
              - name: ADDRESS_FULL_POLICY
                value: ${BROKER_ADDRESS_FULL_POLICY}
              - name: AUTHENTICATION_SERVICE_HOST
                value: ${AUTHENTICATION_SERVICE_HOST}
              - name: AUTHENTICATION_SERVICE_PORT
                value: ${AUTHENTICATION_SERVICE_PORT}
              - name: AUTHENTICATION_SERVICE_CLIENT_SECRET
                value: ${AUTHENTICATION_SERVICE_CLIENT_SECRET}
              - name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
                value: ${AUTHENTICATION_SERVICE_SASL_INIT_HOST}
              - name: AUTHENTICATION_SERVICE_OAUTH_URL
                value: ${AUTHENTICATION_SERVICE_OAUTH_URL}                
              - name: AMQ_NAME
                value: broker
              image: amq-broker-7/amq-broker-72-openshift:latest
              imagePullPolicy: Always
              command:
              - /opt/amq/custom/bin/launch-broker.sh
              livenessProbe:
                exec:
                  command:
                  - sh
                  - -c
                  - $AMQ_HOME/custom/bin/probe.sh
                initialDelaySeconds: 120
              name: broker
              ports:
              - containerPort: 5673
                name: amqp
              - containerPort: 8161
                name: jolokia
              - containerPort: 8080
                name: artemismetrics
              readinessProbe:
                exec:
                  command:
                  - sh
                  - -c
                  - $AMQ_HOME/custom/bin/probe.sh
                initialDelaySeconds: 10
              resources:
                limits:
                  memory: ${BROKER_MEMORY_LIMIT}
                requests:
                  memory: ${BROKER_MEMORY_LIMIT}
              volumeMounts:
              - mountPath: /var/run/artemis
                name: data
              - mountPath: /etc/prometheus-config
                name: broker-prometheus-config
                readOnly: true
              - mountPath: /opt/amq/custom
                name: broker-custom
                readOnly: false
            initContainers:
            - env:
              - name: MESSAGING_SERVICE_HOST
                value: messaging-${INFRA_UUID}
              - name: MESSAGING_SERVICE_PORT_AMQPS_BROKER
                value: 56671
              - name: MESSAGING_SERVICE_PORT_AMQPS_NORMAL
                value: 55671
              - name: QUEUE_SCHEDULER_SERVICE_HOST
                value: queue-scheduler-${INFRA_UUID}
              - name: QUEUE_SCHEDULER_SERVICE_PORT
                value: 5672
              - name: INFRA_UUID
                value: ${INFRA_UUID}
              - name: QUEUE_NAME
                value: ${ADDRESS}
              - name: CLUSTER_ID
                value: ${CLUSTER_ID}
              - name: ADDRESS_FULL_POLICY
                value: ${BROKER_ADDRESS_FULL_POLICY}
              - name: CERT_DIR
                value: /etc/enmasse-certs
              - name: GLOBAL_MAX_SIZE
                value: ${GLOBAL_MAX_SIZE}
              - name: AUTHENTICATION_SERVICE_HOST
                value: ${AUTHENTICATION_SERVICE_HOST}
              - name: AUTHENTICATION_SERVICE_PORT
                value: ${AUTHENTICATION_SERVICE_PORT}
              - name: AUTHENTICATION_SERVICE_CLIENT_SECRET
                value: ${AUTHENTICATION_SERVICE_CLIENT_SECRET}
              - name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
                value: ${AUTHENTICATION_SERVICE_SASL_INIT_HOST}
              - name: AUTHENTICATION_SERVICE_OAUTH_URL
                value: ${AUTHENTICATION_SERVICE_OAUTH_URL}
              - name: AMQ_NAME
                value: broker
              image: amq7/amq-online-1-broker-plugin:dev
              imagePullPolicy: Always
              name: broker-plugin
              volumeMounts:
              - mountPath: /etc/enmasse-certs
                name: broker-internal-cert
                readOnly: true
              - mountPath: /etc/authservice-ca
                name: authservice-ca
                readOnly: true
              - mountPath: /etc/prometheus-config
                name: broker-prometheus-config
                readOnly: true
              - mountPath: /opt/amq/custom
                name: broker-custom
                readOnly: false
            volumes:
            - name: broker-custom
              emptyDir: {}
            - name: authservice-ca
              secret:
                secretName: authservice-ca.${INFRA_UUID}
            - name: broker-internal-cert
              secret:
                secretName: broker-internal-cert.${INFRA_UUID}
            - configMap:
                name: broker-prometheus-config
              name: broker-prometheus-config
        volumeClaimTemplates:
        - apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            annotations:
              addressSpace: ${ADDRESS_SPACE}
              cluster_id: ${CLUSTER_ID}
            labels:
              app: enmasse
              infraType: standard
              infraUuid: ${INFRA_UUID}
            name: data
          spec:
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: ${BROKER_STORAGE_CAPACITY}
    parameters:
    - name: INFRA_UUID
      description: UUID to use for infrastructure
      required: true
    - description: Storage capacity required for volume claims
      name: BROKER_STORAGE_CAPACITY
      value: 2Gi
    - description: A valid addressSpace name for the address Space
      name: ADDRESS_SPACE
      required: true
    - description: A valid name for the deployment
      name: NAME
      required: true
    - description: A valid group id for the deployment
      name: CLUSTER_ID
      required: true
    - description: The address to use for the queue
      name: ADDRESS
      value: ''
    - description: The hostname of the authentication service used by this address
        space
      name: AUTHENTICATION_SERVICE_HOST
      required: true
    - description: The port of the authentication service used by this address space
      name: AUTHENTICATION_SERVICE_PORT
      required: true
    - description: The secret to use for validating authentication service cert
      name: AUTHENTICATION_SERVICE_CA_SECRET
      required: true
    - description: The client cert to use as identity against authentication service
      name: AUTHENTICATION_SERVICE_CLIENT_SECRET
    - description: The hostname to use in sasl init
      name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
    - description: Address full policy
      name: BROKER_ADDRESS_FULL_POLICY
      value: FAIL
    - description: Memory limits for container
      name: BROKER_MEMORY_LIMIT
      value: 512Mi
    - description: Global max size for all addresses in broker. Cannot be larger than
        a quarter of BROKER_MEMORY_LIMIT
      name: GLOBAL_MAX_SIZE
      value: "-1"
  topic-persisted.yaml: |-
    apiVersion: v1
    kind: Template
    metadata:
      labels:
        app: enmasse
      name: topic-persisted
    objects:
    - apiVersion: v1
      kind: Service
      metadata:
        annotations:
          addressSpace: ${ADDRESS_SPACE}
          cluster_id: ${CLUSTER_ID}
        labels:
          app: enmasse
          infraType: standard
          infraUuid: ${INFRA_UUID}
        name: ${NAME}
      spec:
        clusterIP: None
        selector:
          name: ${NAME}
          role: broker
          infraType: standard
          infraUuid: ${INFRA_UUID}
    - apiVersion: apps/v1
      kind: StatefulSet
      metadata:
        annotations:
          address: ${ADDRESS}
          addressSpace: ${ADDRESS_SPACE}
          cluster_id: ${CLUSTER_ID}
          enmasse.io/cert-cn: broker.${INFRA_UUID}
          enmasse.io/cert-secret: broker-internal-cert.${INFRA_UUID}
        labels:
          app: enmasse
          infraType: standard
          infraUuid: ${INFRA_UUID}
        name: ${NAME}
      spec:
        affinity:
          nodeAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
              - weight: 1
                preference:
                  matchExpressions:
                    - key: node-role.enmasse.io/messaging-infra
                      operator: In
                      values:
                        - "true"
        replicas: 1
        serviceName: ${NAME}
        selector:
          matchLabels:
            addresstype: topic
            app: enmasse
            name: ${NAME}
            role: broker
            infraType: standard
            infraUuid: ${INFRA_UUID}
        template:
          metadata:
            annotations:
              address: ${ADDRESS}
              addressSpace: ${ADDRESS_SPACE}
              cluster_id: ${CLUSTER_ID}
              prometheus.io/path: /metrics
              prometheus.io/port: '8080'
              prometheus.io/scrape: 'true'
            labels:
              addresstype: topic
              app: enmasse
              name: ${NAME}
              role: broker
              infraType: standard
              infraUuid: ${INFRA_UUID}
          spec:
            containers:
            - env:
              - name: INFRA_UUID
                value: ${INFRA_UUID}
              - name: MESSAGING_SERVICE_HOST
                value: messaging-${INFRA_UUID}
              - name: MESSAGING_SERVICE_PORT_AMQPS_BROKER
                value: 56671
              - name: MESSAGING_SERVICE_PORT_AMQPS_NORMAL
                value: 55671
              - name: TOPIC_NAME
                value: ${ADDRESS}
              - name: CLUSTER_ID
                value: ${CLUSTER_ID}
              - name: CERT_DIR
                value: /etc/enmasse-certs
              - name: ADDRESS_FULL_POLICY
                value: ${BROKER_ADDRESS_FULL_POLICY}
              - name: AUTHENTICATION_SERVICE_HOST
                value: ${AUTHENTICATION_SERVICE_HOST}
              - name: AUTHENTICATION_SERVICE_PORT
                value: ${AUTHENTICATION_SERVICE_PORT}
              - name: AUTHENTICATION_SERVICE_CLIENT_SECRET
                value: ${AUTHENTICATION_SERVICE_CLIENT_SECRET}
              - name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
                value: ${AUTHENTICATION_SERVICE_SASL_INIT_HOST}
              - name: AUTHENTICATION_SERVICE_OAUTH_URL
                value: ${AUTHENTICATION_SERVICE_OAUTH_URL}                
              - name: AMQ_NAME
                value: broker
              image: amq-broker-7/amq-broker-72-openshift:latest
              imagePullPolicy: Always
              command:
              - /opt/amq/custom/bin/launch-broker.sh
              livenessProbe:
                exec:
                  command:
                  - sh
                  - -c
                  - $AMQ_HOME/custom/bin/probe.sh
                initialDelaySeconds: 120
              name: broker
              ports:
              - containerPort: 5673
                name: amqp
              - containerPort: 8161
                name: jolokia
              - containerPort: 8080
                name: artemismetrics
              readinessProbe:
                exec:
                  command:
                  - sh
                  - -c
                  - $AMQ_HOME/custom/bin/probe.sh
                initialDelaySeconds: 10
              resources:
                limits:
                  memory: ${BROKER_MEMORY_LIMIT}
                requests:
                  memory: ${BROKER_MEMORY_LIMIT}
              volumeMounts:
              - mountPath: /opt/amq/custom
                name: broker-custom
                readOnly: false
              - mountPath: /etc/prometheus-config
                name: broker-prometheus-config
                readOnly: true
            - env:
              - name: INFRA_UUID
                value: ${INFRA_UUID}
              - name: TOPIC_NAME
                value: ${ADDRESS}
              - name: CLUSTER_ID
                value: ${NAME}
              - name: CERT_DIR
                value: /etc/enmasse-certs
              image: amq7/amq-online-1-topic-forwarder:dev
              imagePullPolicy: Always
              livenessProbe:
                httpGet:
                  path: /health
                  port: health
                initialDelaySeconds: 60
              name: forwarder
              ports:
              - containerPort: 8088
                name: health
              resources:
                limits:
                  memory: 128Mi
                requests:
                  memory: 128Mi
              volumeMounts:
              - mountPath: /etc/enmasse-certs
                name: broker-internal-cert
                readOnly: true
            initContainers:
            - env:
              - name: INFRA_UUID
                value: ${INFRA_UUID}
              - name: MESSAGING_SERVICE_HOST
                value: messaging-${INFRA_UUID}
              - name: MESSAGING_SERVICE_PORT_AMQPS_BROKER
                value: 56671
              - name: MESSAGING_SERVICE_PORT_AMQPS_NORMAL
                value: 55671
              - name: QUEUE_SCHEDULER_SERVICE_HOST
                value: queue-scheduler-${INFRA_UUID}
              - name: QUEUE_SCHEDULER_SERVICE_PORT
                value: 5672
              - name: TOPIC_NAME
                value: ${ADDRESS}
              - name: CLUSTER_ID
                value: ${CLUSTER_ID}
              - name: ADDRESS_FULL_POLICY
                value: ${BROKER_ADDRESS_FULL_POLICY}
              - name: CERT_DIR
                value: /etc/enmasse-certs
              - name: GLOBAL_MAX_SIZE
                value: ${GLOBAL_MAX_SIZE}
              - name: AUTHENTICATION_SERVICE_HOST
                value: ${AUTHENTICATION_SERVICE_HOST}
              - name: AUTHENTICATION_SERVICE_PORT
                value: ${AUTHENTICATION_SERVICE_PORT}
              - name: AUTHENTICATION_SERVICE_CLIENT_SECRET
                value: ${AUTHENTICATION_SERVICE_CLIENT_SECRET}
              - name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
                value: ${AUTHENTICATION_SERVICE_SASL_INIT_HOST}
              - name: AUTHENTICATION_SERVICE_OAUTH_URL
                value: ${AUTHENTICATION_SERVICE_OAUTH_URL}
              - name: AMQ_NAME
                value: broker
              image: amq7/amq-online-1-broker-plugin:dev
              imagePullPolicy: Always
              name: broker-plugin
              volumeMounts:
              - mountPath: /etc/enmasse-certs
                name: broker-internal-cert
                readOnly: true
              - mountPath: /etc/authservice-ca
                name: authservice-ca
                readOnly: true
              - mountPath: /etc/prometheus-config
                name: broker-prometheus-config
                readOnly: true
              - mountPath: /opt/amq/custom
                name: broker-custom
                readOnly: false
            volumes:
            - name: broker-custom
              emptyDir: {}
            - name: authservice-ca
              secret:
                secretName: authservice-ca.${INFRA_UUID}
            - name: broker-internal-cert
              secret:
                secretName: broker-internal-cert.${INFRA_UUID}
            - configMap:
                name: broker-prometheus-config
              name: broker-prometheus-config
        volumeClaimTemplates:
        - apiVersion: v1
          kind: PersistentVolumeClaim
          metadata:
            annotations:
              addressSpace: ${ADDRESS_SPACE}
              cluster_id: ${CLUSTER_ID}
            labels:
              app: enmasse
              infraType: standard
              infraUuid: ${INFRA_UUID}
            name: data
          spec:
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: ${BROKER_STORAGE_CAPACITY}
    parameters:
    - name: INFRA_UUID
      description: UUID to use for infrastructure
      required: true
    - description: Storage capacity required for volume claims
      name: BROKER_STORAGE_CAPACITY
      value: 2Gi
    - description: A valid addressSpace name for the address Space
      name: ADDRESS_SPACE
      required: true
    - description: A valid name for the deployment
      name: NAME
      required: true
    - description: A valid group id for the deployment
      name: CLUSTER_ID
      required: true
    - description: The address to use for the topic
      name: ADDRESS
      value: ''
    - description: The hostname of the authentication service used by this address
        space
      name: AUTHENTICATION_SERVICE_HOST
      required: true
    - description: The port of the authentication service used by this address space
      name: AUTHENTICATION_SERVICE_PORT
      required: true
    - description: The secret to use for validating authentication service cert
      name: AUTHENTICATION_SERVICE_CA_SECRET
      required: true
    - description: The client cert to use as identity against authentication service
      name: AUTHENTICATION_SERVICE_CLIENT_SECRET
    - description: The hostname to use in sasl init
      name: AUTHENTICATION_SERVICE_SASL_INIT_HOST
    - description: Address full policy
      name: BROKER_ADDRESS_FULL_POLICY
      value: FAIL
    - description: Memory limits for container
      name: BROKER_MEMORY_LIMIT
      value: 512Mi
    - description: Global max size for all addresses in broker. Cannot be larger than
        a quarter of BROKER_MEMORY_LIMIT
      name: GLOBAL_MAX_SIZE
      value: "-1"
