apiVersion: v1
kind: Service
metadata:
  name: statping
spec:
  ports:
  - port: 80
    targetPort: web
  selector:
    app: statping
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: statping
spec:
  selector:
    matchLabels:
      app: statping
  replicas: 1
  template:
    metadata:
      labels:
        app: statping
    spec:
      volumes:
        - name: app-folder
          hostPath:
            path: /mnt/statping
            type: Directory
      containers:
      - name: statping
        image: hunterlong/statping
        securityContext:
          runAsUser: 1000
        imagePullPolicy: IfNotPresent
        env:
          - name: DB_CONN
            value: postgres
          - name: DB_HOST
            value: new-postgres-postgresql.db.svc.cluster.local
          - name: DB_PORT
            value: "5432"
          - name: DB_USER
            value: postgres
          - name: DB_PASS
            valueFrom:
                secretKeyRef:
                  name: new-postgres-postgresql
                  key: password
          - name: DB_DATABASE
            value: statping
          - name: NAME
            value: "JUNV Apps Status"
        ports:
          - containerPort: 8080
            name: web
        volumeMounts:
          - name: app-folder
            mountPath: /app
---

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: statping-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - status.junv.me
    secretName: statping-tls
  rules:
  - host: status.junv.me
    http:
      paths:
      - backend:
          serviceName: statping
          servicePort: 80
        path: /
