# Create a secret containing your AWS credentials token first:
# kubectl create secret generic aws-credentials --from-literal=accessKeyID=ACCESS_KEY_ID_HERE --from-literal=secretKey=SECRET_KEY

apiVersion: apps/v1
kind: Deployment
metadata:
  name: aws-exporter
  labels:
    app.kubernetes.io/name: aws-exporter
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: aws-exporter
  template:
    metadata:
      labels:
        app.kubernetes.io/name: aws-exporter
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '9759'
    spec:
      containers:
        - name: aws-exporter
          image: xrstf/aws_exporter:latest
          args:
            - -listen=0.0.0.0:9759
          env:
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: aws-credentials
                  key: accessKeyID
            - name: AWS_SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: aws-credentials
                  key: secretKey
          ports:
            - name: metrics
              containerPort: 9759
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /metrics
              port: metrics
          readinessProbe:
            httpGet:
              path: /metrics
              port: metrics
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 1
              memory: 128Mi
          securityContext:
            runAsNonRoot: true
            runAsUser: 65534
