apiVersion: apps/v1
kind: Deployment
metadata:
  name: harald
  namespace: selfservice-herald-vbqkr
  labels:
    project: selfservice
    department: devex
    app: harald
    component: harald
spec:
  replicas: 1
  selector:
    matchLabels:
      app: harald
  template:
    metadata:
      labels:
        app: harald
        project: selfservice
        department: devex
        logging_dfds_cloud_format_json: "true"
      annotations:
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"
    spec:
      priorityClassName: selfservice
      initContainers:
      - name: dbmigrations
        image: 640590921355.dkr.ecr.eu-west-1.amazonaws.com/harald/dbmigrations:$(Build.BuildId)
        envFrom:
        - secretRef:
            name: harald-postgres
        env:
        - name:  PGPORT
          value: "1433"
      containers:
      - name: harald
        image: 640590921355.dkr.ecr.eu-west-1.amazonaws.com/harald/harald:$(Build.BuildId)
        ports:
        - containerPort: 50900
          name: web
        - containerPort: 8080
          name: metrics
        resources:
          requests:
            memory: "200Mi"
            cpu: "100m"
          limits:
            memory: "400Mi"
            cpu: "200m"
        envFrom:
        - secretRef:
            name: harald-postgres
        - secretRef:
            name: harald-kafka
        - secretRef:
            name: harald-slack
        env:
          - name: SLACK_API_BASE_URL
            value: "https://slack.com"
          - name: HARALD_DATABASE_CONNECTIONSTRING
            valueFrom:
              secretKeyRef:
                name: harald-postgres
                key: PGCONNSTRING
          - name: HARALD_KAFKA_BOOTSTRAP_SERVERS
            valueFrom:
              secretKeyRef:
                name: harald-kafka
                key: KAFKA_BOOTSTRAP_SERVERS
          - name: HARALD_KAFKA_SASL_USERNAME
            valueFrom:
              secretKeyRef:
                name: harald-kafka
                key: KAFKA_SASL_USERNAME
          - name: HARALD_KAFKA_SASL_PASSWORD
            valueFrom:
              secretKeyRef:
                name: harald-kafka
                key: KAFKA_SASL_PASSWORD
          - name: HARALD_KAFKA_BROKER_VERSION_FALLBACK
            value: "0.10.0.0"
          - name: HARALD_KAFKA_API_VERSION_FALLBACK_MS
            value: "0"
          - name: HARALD_KAFKA_GROUP_ID
            value: "build.selfservice.harald-consumer"
          - name: HARALD_KAFKA_ENABLE_AUTO_COMMIT
            value: "false"
          - name: HARALD_KAFKA_SASL_MECHANISMS
            value: "PLAIN"
          - name: HARALD_KAFKA_SECURITY_PROTOCOL
            value: "SASL_SSL"
          - name: DD_AGENT_HOST
            valueFrom:
              fieldRef:
                fieldPath: status.hostIP
          - name: DD_TRACE_GLOBAL_TAGS
            value: "selfservice:harald"
          - name: DD_LOGS_INJECTION
            value: "true"
        livenessProbe:
          initialDelaySeconds: 5
          periodSeconds: 60
          timeoutSeconds: 5
          httpGet:
            port: web
            path: /healthz
        readinessProbe:
          initialDelaySeconds: 5
          periodSeconds: 5
          timeoutSeconds: 5
          httpGet:
            port: web
            path: /healthz
