apiVersion: v1
kind: Namespace
metadata:
  name: "emblem"
  labels:
    name: "emblem"
---
apiVersion: v1
kind: Secret
metadata:
  name: regcred
  namespace: emblem
data:
  .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7CgkJCSJhdXRoIjogIlptRnRlbWhsYm1jNmFuUmFOamMwWlhSMmNHNTVTMEk9IgoJCX0sCgkJInJlZ2lzdHJ5LmNuLWJlaWppbmcuYWxpeXVuY3MuY29tIjogewoJCQkiYXV0aCI6ICJaWFZ3YUc5dU9ucEZPRjVlWTJ0cWJtTktRa29xIgoJCX0sCgkJInJlZ2lzdHJ5LmNuLXNoZW56aGVuLmFsaXl1bmNzLmNvbSI6IHsKCQkJImF1dGgiOiAiWlhWd2FHOXVPbnBGT0Y1ZVkydHFibU5LUWtvcSIKCQl9LAoJCSJyZWdpc3RyeS5naXRsYWIuY29tIjogewoJCQkiYXV0aCI6ICJabUZ0ZW1obGJtYzZaMnh3WVhRdFIyWjZXbmxFUjNCMU9XZEtlVGRSTVZSUmVtWT0iCgkJfQoJfQp9Cg==
type: kubernetes.io/dockerconfigjson
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: server
    deploy-timestamp: "${deploy_timestamp}"
  name: server
  namespace: emblem
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: server
  template:
    metadata:
      labels:
        app.kubernetes.io/name: server
        deploy-timestamp: "${deploy_timestamp}"
    spec:
      imagePullSecrets:
        - name: regcred
      volumes:
      - name: data
        hostPath:
          path: /data/emblem
          type: Directory
      containers:
        - image: ${image}
          imagePullPolicy: IfNotPresent
          name: server
          volumeMounts:
          - mountPath: /emblem/data
            name: data
          env:
            - name: EMBLEM_ENV
              value: ${emblem_env}
            - name: EMBLEM_DB_TYPE
              value: postgres
            - name: EMBLEM_DB_HOST
              value: ${db_host}
          resources:
            requests:
              memory: "2048Mi"
              cpu: "1000m"
            limits:
              memory: "2048Mi"
              cpu: "1000m"
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /healthz
              port: http
            initialDelaySeconds: 5
            periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: server
  namespace: emblem
spec:
  selector:
    app.kubernetes.io/name: server
  ports:
    - protocol: TCP
      port: 80
      targetPort: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: server
  namespace: emblem
  annotations:
    traefik.ingress.kubernetes.io/router.tls.certresolver: le
spec:
  tls:
  - hosts:
% for host in hosts:
    - ${host}
% endfor
  rules:
% for host in hosts:
  - host: ${host}
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: server
            port:
              number: 80
% endfor
