apiVersion: apps/v1
kind: Deployment
metadata:
  name: aws-janitor
  namespace: $(kubernetes-namespace)
  labels:
    project: selfservice
    department: devex
    app: aws-janitor
    component: aws-janitor
spec:
  replicas: 1
  selector:
    matchLabels:
      app: aws-janitor
  template:
    metadata:
      labels:
        app: aws-janitor
        project: selfservice
        department: devex
      annotations:
        iam.amazonaws.com/role: arn:aws:iam::$(account_id):role/eks-hellman-self-service
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"
    spec:
      priorityClassName: selfservice
      containers:
      - name: aws-janitor
        image: 579478677147.dkr.ecr.eu-central-1.amazonaws.com/ded/aws-janitor:$(Build.BuildId)
        ports:
        - containerPort: 80
          name: web
        - containerPort: 8080
          name: metrics
        resources:
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "200m"
        livenessProbe:
          initialDelaySeconds: 5
          periodSeconds: 5
          timeoutSeconds: 5
          httpGet:
            port: web
            path: /healthz
        readinessProbe:
          initialDelaySeconds: 5
          periodSeconds: 5
          timeoutSeconds: 5
          httpGet:
            port: web
            path: /healthz
        env:
        - name: KUBERNETES_CLUSTER_NAME
          value: $(KUBERNETES_CLUSTER_NAME)
        - name: AWS_REGION
          value: $(AWS_REGION)
        - name: KAFKA_BOOTSTRAP_SERVERS
          value: $(KAFKA_BOOTSTRAP_SERVERS)
        - name: KAFKA_BROKER_VERSION_FALLBACK
          value: "0.10.0.0"
        - name: KAFKA_API_VERSION_FALLBACK_MS
          value: "0"
        - name: KAFKA_SASL_USERNAME
          valueFrom:
            secretKeyRef:
              name: aws-janitor-kafka-credentials
              key: username
        - name: KAFKA_SASL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: aws-janitor-kafka-credentials
              key: password
        - name: KAFKA_GROUP_ID
          value: "$(KAFKA_GROUP_ID)"
        - name: KAFKA_ENABLE_AUTO_COMMIT
          value: "false"
        - name: KAFKA_SASL_MECHANISMS
          value: "PLAIN"
        - name: KAFKA_SECURITY_PROTOCOL
          value: "SASL_SSL"
