---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: fail2ban-geoip
    app.kubernetes.io/instance: fail2ban-prometheus
    app.kubernetes.io/name: fail2ban-geoip
  name: fail2ban-geoip
  namespace: fail2ban-prometheus
spec:
  replicas: 2
  selector:
    matchLabels:
      app: fail2ban-geoip
  template:
    metadata:
      labels:
        app: fail2ban-geoip
        app.kubernetes.io/instance: fail2ban-prometheus
        app.kubernetes.io/name: fail2ban-geoip
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - fail2ban-geoip
              topologyKey: kubernetes.io/hostname
            weight: 1
      containers:
      - env:
        - name: GEOIP_LISTEN_ADDRESS
          value: :8080
        - name: GEOIP_EXPORTER_ADDRESS
          value: :9191
        - name: GEOIP_ENABLE_EXPORTER
          value: "true"
        - name: GEOIP_DATA_URL
          value: https://data.neuber.io/data.csv
        image: git.ar21.de/yolokube/country-geo-locations:latest
        imagePullPolicy: IfNotPresent
        name: fail2ban-geoip
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        - containerPort: 9191
          name: http-metrics
          protocol: TCP
        readinessProbe:
          httpGet:
            httpHeaders:
            - name: Accept
              value: application/json
            path: /api/v1/location/1.1.1.1
            port: http
          initialDelaySeconds: 3
          periodSeconds: 2
        resources:
          limits:
            cpu: "2"
            memory: 4Gi
          requests:
            cpu: "1.5"
            memory: 3.5Gi
      serviceAccountName: fail2ban-geoip-service-account