apiVersion: v1
kind: Template
metadata:
  name: apiomat-dashboard
  annotations:
    tag: BaaS,Backend, dashboard, apiomat
objects:
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: ${DASHBOARD_SERVICE_NAME}
    labels:
      app: ${DASHBOARD_SERVICE_NAME}
      template: apiomat-dashboard
  spec:
    strategy:
      type: Rolling
      rollingParams:
        updatePeriodSeconds: 1
        intervalSeconds: 1
        timeoutSeconds: 600
        maxUnavailable: 25%
        maxSurge: 25%
      resources: {  }
    triggers:
      -
        type: ConfigChange
    replicas: 1
    selector:
      deploymentconfig: ${DASHBOARD_SERVICE_NAME}
    template:
      metadata:
        labels:
          app: ${DASHBOARD_SERVICE_NAME}
          deploymentconfig: ${DASHBOARD_SERVICE_NAME}
      spec:
        containers:
          - env:
            - name: DEBUG
              value: 'false'
            - name: common_hosts_admin
              value: http://localhost:8081
            - name: common_hosts_live
              value: http://${YAMBAS_ROUTE}-${OPENSHIFT_PROJECT}.${OPENSHIFT_INSTANCE_SUBDOMAIN}
            - name: common_hosts_staging
              value: http://${YAMBAS_ROUTE}-${OPENSHIFT_PROJECT}.${OPENSHIFT_INSTANCE_SUBDOMAIN}
            - name: common_hosts_test
              value: http://${YAMBAS_ROUTE}-${OPENSHIFT_PROJECT}.${OPENSHIFT_INSTANCE_SUBDOMAIN}
            - name: common_isEnterpriseInstallation
              value: 'true'
            - name: common_superadminEmail
              value: ${COMMON_SUPERADMINEMAIL}
            - name: common_superadminPassword
              value: ${COMMON_SUPERADMINPASSWORD}
            - name: yambas_license_key
              value: ${YAMBAS_LICENSE_KEY}                  
            name: alpine-dashboard
            image: ${DASHBOARD_IMAGE}
            ports:
              - containerPort: 8000
                protocol: TCP
            resources:
              limits:
                memory: ${DASHBOARD_MEMORY_LIMIT}
            imagePullPolicy: Always
            livenessProbe:
              httpGet:
                path: /site/login
                port: 8000
              initialDelaySeconds: 30
              timeoutSeconds: 10
            readinessProbe:
              httpGet:
                path: /site/login
                port: 8000
              initialDelaySeconds: 30
              timeoutSeconds: 10
        restartPolicy: Always
        terminationGracePeriodSeconds: 30
        dnsPolicy: ClusterFirst
        securityContext: {  }
  status: {  }
- apiVersion: v1
  kind: Service
  metadata:
    name: ${DASHBOARD_SERVICE_NAME}
    labels:
      template: apiomat-dashboard
  spec:
    selector:
      deploymentconfig: ${DASHBOARD_SERVICE_NAME}
    ports:
    - nodePort: 0
      name: dashboard
      port: 8000
      protocol: TCP
      targetPort: 8000
- apiVersion: v1
  kind: Route
  metadata:
    name: ${DASHBOARD_ROUTE}
  spec:
    to:
      kind: Service
      name: ${DASHBOARD_SERVICE_NAME}
    port:
      targetPort: 8000
  status: {  }
parameters:
- name: OPENSHIFT_PROJECT
  description: "Name of Openshift Project"
  value: apiomat
- name: OPENSHIFT_INSTANCE_SUBDOMAIN
  description: "Subdomain of Openshift instance (for example: sub.example.com)"
  value: sub.example.com
- name: YAMBAS_SERVICE_NAME
  description: "Service name of yambas. Yambas is the 'heart' and backend of ApiOmat."
  value: yambas
- name: COMMON_SUPERADMINEMAIL
  description: "Mail of superadmin (For example: apinaut@apiomat.com)"
  value: apinaut@apiomat.com
- name: COMMON_SUPERADMINPASSWORD
  description: "Password of superadmin (For example: secret)"
  value: secret
- name: DASHBOARD_SERVICE_NAME
  description: "Service name of dashboard. Dashboard is the frontend of ApiOmat."
  value: dashboard
- name: DASHBOARD_ROUTE
  description: "Route to dashboard service (generated)"
  generate: expression
  from: "dashboard[a-z]{15}"
- name: DASHBOARD_MEMORY_LIMIT
  description: "Memory limit of dashboard (min. 1Gi)"
  value: 1Gi
- name: DASHBOARD_IMAGE
  description: "Url to the docker dashboard image"
  value: docker.io/apiomat/alpine-dashboard:3.0.1