apiVersion: apps/v1
kind: Deployment
metadata:
  name: notification-mailer-deployment
  labels:
    app: notification
    component: notification-mailer
spec:
  replicas: 1
  selector:
    matchLabels:
      component: notification-mailer
  template:
    metadata:
      labels:
        component: notification-mailer
    spec:
      serviceAccountName: notification-mailer-sa
      initContainers:
        - name: wait-for-rabbit
          image: alpine
          command:
            [
              "sh",
              "-c",
              "for i in $(seq 1 300); do nc -zvw1 notification-mq 5672 && exit 0 || sleep 3; done; exit 1",
            ]
      containers:
        - name: notification-mailer
          image: bespinian/notification-mailer:1.0.3
          env:
            - name: SIMULATE
              value: "true"
            - name: MQ_URL
              value: amqp://notification-mq
          envFrom:
            - configMapRef:
                name: notification-mailer-configmap
