apiVersion: apps/v1
kind: Deployment
metadata:
  name: kube-znn
  labels:
    app: kube-znn
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kube-znn
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: kube-znn
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9180"
    spec:
      # affinity:
      #   podAntiAffinity:
      #     requiredDuringSchedulingIgnoredDuringExecution:
      #     - labelSelector:
      #         matchExpressions:
      #         - key: service
      #           operator: In
      #           values:
      #           - znn-db
      #       topologyKey: kubernetes.io/hostname
      volumes:
      - name: fidelity-config-volume
        configMap:
          name: fidelity-config
          items:
          - key: fidelity
            path: fidelity
      containers:
      - name: znn
        image: cmendes/znn:high
        imagePullPolicy: Always
        env:
        #- name: FIDELITY_FILE
        #  value: "/www/fidelity/fidelity"
        - name: DB_HOST
          value: "kube-znn-db"
        - name: DB_PORT
          value: "3306"
        - name: DB_NAME
          value: "znn_data"
        - name: DB_USER
          value: "znn"
        - name: SLEEP_TIME
          value: "0"
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        readinessProbe:
          httpGet:
            path: /readiness.php
            port: 80
          initialDelaySeconds: 1
          periodSeconds: 2
          failureThreshold: 5
        livenessProbe:
          httpGet:
            path: /liveness.php
            port: 80
          initialDelaySeconds: 1
          periodSeconds: 1
          failureThreshold: 5
        ports:
        - containerPort: 80
          name: kube-znn
        - containerPort: 9180
          name: caddy-exporter
        # volumeMounts:
        # - name: fidelity-config-volume
        #   mountPath: /www/fidelity
      # volumes:
      # - name: fidelity-config-volume
      #   configMap:
      #     name: fidelity-config
      #     items:
      #     - key: fidelity
      #       path: fidelity
      nodeSelector:
        kops.k8s.io/instancegroup: nodes