---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ipapi
  name: ipapi
  namespace: ipapi
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: ipapi
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: ipapi
    spec:
      containers:
      - image: docker.io/mpolden/echoip:latest
        imagePullPolicy: Always
        name: ipapi
        args:
        - -H
        - X-Forwarded-For
        - -f
        - /data/geoip/GeoLite2-Country.mmdb
        - -c
        - /data/geoip/GeoLite2-City.mmdb
        - -a
        - /data/geoip/GeoLite2-ASN.mmdb
        - -r
        - -p
        - -C
        - "1000"
        - -t
        - /data/template/index.html
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        volumeMounts:
        - name: geoip
          mountPath: /data/geoip
        - name: template
          mountPath: /data/template
        livenessProbe:
          httpGet:
            path: /health
            port: http
        readinessProbe:
          httpGet:
            path: /health
            port: http
        resources:
          requests:
            memory: 64Mi
            cpu: 150m
          limits:
            memory: 256Mi
            cpu: 300m
        securityContext:
          runAsUser: 1000
          runAsGroup: 1000
      volumes:
      - name: geoip
        persistentVolumeClaim:
          claimName: ipapi-geodb
      - name: template
        configMap:
          name: html-template
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 30
