apiVersion: apps/v1
kind: Deployment
metadata:
  name: trigger-service-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: trigger-service
  template:
    metadata:
      labels:
        component: trigger-service
    spec:
      initContainers:
        - name: wait-db
          image: alpine:3.7
          command: ['sh', '-c', "until nslookup trigger-service-mysql-cluster-ip.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for db; sleep 2; done"]
      containers:
        - name: trigger-service
          image: metalom/trigger-service:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 50051
          env:
            # grpc server
            - name: SERVER_HOST
              value: ':50051'

            # broker
            - name: MESSENGER_TRANSPORT_DSN
              value: 'amqp://rabbitmq:secret@rabbitmq-message-cluster-ip:5672/'
            - name: EXCHANGE_NAME
              value: 'task_execute_event'

            # monitoring
            - name: INFLUX_DB_DNS
              value: 'http://influxdb-cluster-ip:8086'
            - name: INFLUX_DB_PASSWORD
              value: 'secret'
            - name: INFLUX_DB_USERNAME
              value: 'monitor'
            - name: INFLUX_DB_NAME
              value: 'trigger_hook'

            # database
            - name: DATABASE_HOST
              value: 'trigger-service-mysql-cluster-ip:3306'
            - name: DATABASE_USER
              value: 'user'
            - name: DATABASE_PASSWORD
              value: 'secret'
            - name: DATABASE_NAME
              value: 'trigger_service'

