---
kind: Template
apiVersion: v1
metadata:
  name: ${NAME}-deployment-template
labels:
  template: ${NAME}-deployment-template
objects:
- kind: DeploymentConfig
  apiVersion: v1
  metadata:
    name: "${NAME}"
    labels:
      app: "${NAME}"
  spec:
    strategy:
      type: Rolling
      rollingParams:
        updatePeriodSeconds: 1
        intervalSeconds: 1
        timeoutSeconds: 600
        maxUnavailable: 25%
        maxSurge: 25%
      resources: {}
    triggers:
    - type: ConfigChange
    - type: ImageChange
      imageChangeParams:
        automatic: true
        containerNames:
        - "${NAME}"
        from:
          kind: ImageStreamTag
          namespace: "${IMAGE_NAMESPACE}"
          name: "${NAME}:${TAG_NAME}"
    replicas: 1
    test: false
    selector:
      app: "${NAME}"
      deploymentconfig: "${NAME}"
    template:
      metadata:
        creationTimestamp:
        labels:
          app: "${NAME}"
          deploymentconfig: "${NAME}"
      spec:
        containers:
        - name: "${NAME}"
          image: " "
          ports:
          - containerPort: 8080
            protocol: TCP
          livenessProbe:
            httpGet:
              path: /nginx_status
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 60
            timeoutSeconds: 30
            periodSeconds: 60
            successThreshold: 1
            failureThreshold: 5
          imagePullPolicy: Always
        restartPolicy: Always
        terminationGracePeriodSeconds: 30
        dnsPolicy: ClusterFirst
        securityContext: {}
- kind: Service
  apiVersion: v1
  metadata:
    name: "${NAME}"
    labels:
      app: "${NAME}"
  spec:
    ports:
    - name: 8080-tcp
      protocol: TCP
      port: 8080
      targetPort: 8080
    selector:
      app: "${NAME}"
      deploymentconfig: "${NAME}"
    type: ClusterIP
    sessionAffinity: None
- kind: Route
  apiVersion: v1
  metadata:
    name: "${NAME}-siteminder-route"
    labels:
      app: "${NAME}-siteminder-route"
    annotations:
      haproxy.router.openshift.io/ip_whitelist: "${SITEMINDER_WHITE_LIST}"
  spec:
    host: "${SITEMINDER_APPLICATION_DOMAIN}"
    port:
      targetPort: 8080-tcp
    to:
      kind: Service
      name: "${NAME}"
      weight: 100
- kind: HorizontalPodAutoscaler
  apiVersion: autoscaling/v1
  metadata:
    name: "${NAME}"
    labels:
      app: "${NAME}"
  spec:
    scaleTargetRef:
      kind: DeploymentConfig
      name: "${NAME}"
    minReplicas: 1
    maxReplicas: 4
parameters:
- name: NAME
  displayName: Name
  description: The name assigned to all of the frontend objects defined in this template.
  required: true
  value: nginx-proxy
- name: IMAGE_NAMESPACE
  displayName: Image Namespace
  description: Namespace containing application images.
  required: true
  value: "jag-csb-edivorce-tools"
- name: TAG_NAME
  displayName: Environment TAG name
  description: The TAG name for this environment, e.g., dev, test, prod.
  required: true
  value: "dev"
- name: SITEMINDER_APPLICATION_DOMAIN
  displayName: SiteMinder Application Domain
  description: The endpoint used for SiteMinder routed access to the application.
  required: true
  value: "edivorce-dev.pathfinder.bcgov"
- name: SITEMINDER_WHITE_LIST
  displayName: SiteMinder Whitelist
  description: The whitelist containing all of the trusted siteminder IPs.
  required: false