apiVersion: v1
kind: Template
metadata:
  creationTimestamp: null
  name: 3scale-gateway
  annotations:
    description: "3scale API Gateway"
    iconClass: "icon-load-balancer"
    tags: "api,gateway,3scale"
objects:
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: ${THREESCALE_GATEWAY_NAME}
  spec:
    replicas: 2
    selector:
      deploymentconfig: ${THREESCALE_GATEWAY_NAME}
    strategy:
      resources: {}
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          deploymentconfig: ${THREESCALE_GATEWAY_NAME}
      spec:
        containers:
        - env:
          - name: THREESCALE_PORTAL_ENDPOINT
            valueFrom:
              secretKeyRef:
                name: ${THREESCALE_PORTAL_ENDPOINT_SECRET}
                key: password
          - name: THREESCALE_CONFIG_FILE
            value: ${THREESCALE_CONFIG_FILE}
          - name: RESOLVER
            value: ${RESOLVER}
          - name: APICAST_SERVICES
            value: ${APICAST_SERVICES}
          - name: APICAST_MISSING_CONFIGURATION
            value: ${MISSING_CONFIGURATION}
          - name: APICAST_LOG_LEVEL
            value: ${APICAST_LOG_LEVEL}
          - name: APICAST_PATH_ROUTING_ENABLED
            value: ${PATH_ROUTING}
          - name: APICAST_RESPONSE_CODES
            value: ${RESPONSE_CODES}
          - name: APICAST_REQUEST_LOGS
            value: ${REQUEST_LOGS}
          - name: APICAST_RELOAD_CONFIG
            value: ${APICAST_RELOAD_CONFIG}
          image: ${THREESCALE_GATEWAY_IMAGE}
          imagePullPolicy: Always
          name: ${THREESCALE_GATEWAY_NAME}
          livenessProbe:
            httpGet:
              path: /status/live
              port: 8090
            initialDelaySeconds: 10
            timeoutSeconds: 1
          readinessProbe:
            httpGet:
              path: /status/ready
              port: 8090
            initialDelaySeconds: 15
            timeoutSeconds: 1
          ports:
          - containerPort: 8080
            protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
        dnsPolicy: ClusterFirst
        restartPolicy: Always
        securityContext: {}
        terminationGracePeriodSeconds: 30
    triggers:
    - type: ConfigChange
  status: {}
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: null
    name: ${THREESCALE_GATEWAY_NAME}
  spec:
    ports:
    - name: 8080-tcp
      port: 8080
      protocol: TCP
      targetPort: 8080
    selector:
      deploymentconfig: ${THREESCALE_GATEWAY_NAME}
    sessionAffinity: None
    type: ClusterIP
  status:
    loadBalancer: {}
parameters:
- description: "Name of the secret containing the THREESCALE_PORTAL_ENDPOINT with the access-token or provider key"
  value: threescale-portal-endpoint-secret
  name: THREESCALE_PORTAL_ENDPOINT_SECRET
  required: true
- description: "Path to saved JSON file with configuration for the gateway. Has to be injected to the docker image as read only volume."
  value:
  name: THREESCALE_CONFIG_FILE
  required: false
- description: "Name for the 3scale API Gateway"
  value: threescalegw
  name: THREESCALE_GATEWAY_NAME
  required: true
- description: "Docker image to use."
  value: 'rhamp10/apicast-gateway:1.0.0-4'
  name: THREESCALE_GATEWAY_IMAGE
  required: true
- description: "DNS Resolver for openresty, if empty it will be autodiscovered"
  value:
  name: RESOLVER
  required: false
- description: "Subset of services to run. Use comma separated list of service ids (eg. 42,1337)"
  value:
  name: APICAST_SERVICES
  required: false
- description: "What to do on missing or invalid configuration. Allowed values are: log, exit."
  value: exit
  required: false
  name: MISSING_CONFIGURATION
- description: "Log level. One of the following: debug, info, notice, warn, error, crit, alert, or emerg."
  name: APICAST_LOG_LEVEL
  required: false
- description: "Enable path routing. Experimental feature."
  name: PATH_ROUTING
  required: false
  value: "false"
- description: "Enable traffic logging to 3scale. Includes whole request and response."
  value: "false"
  name: REQUEST_LOGS
  required: false
- description: "Enable logging response codes to 3scale."
  value: "false"
  name: RESPONSE_CODES
  required: false
- description: "Reload config on every request"
  value: "false"
  name: APICAST_RELOAD_CONFIG
  required: false
