apiVersion: v1
kind: Template
metadata:
  name: apiomat-yambas
  annotations:
    tag: BaaS,Backend, yambas, apiomat
objects:
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: ${YAMBAS_SERVICE_NAME}
    labels:
      app: ${YAMBAS_SERVICE_NAME}
      template: apiomat-yambas
  spec:
    strategy:
      type: Rolling
      rollingParams:
        updatePeriodSeconds: 1
        intervalSeconds: 1
        timeoutSeconds: 600
        maxUnavailable: 25%
        maxSurge: 25%
      resources: {  }
    triggers:
      -
        type: ConfigChange
    replicas: 1
    selector:
      deploymentconfig: ${YAMBAS_SERVICE_NAME}
    template:
      metadata:
        labels:
          app: ${YAMBAS_SERVICE_NAME}
          deploymentconfig: ${YAMBAS_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: DISABLE_HAZELCAST_MULTICAST
              value: "true"
            - name: common_superadminEmail
              value: ${COMMON_SUPERADMINEMAIL}
            - name: common_superadminPassword
              value: ${COMMON_SUPERADMINPASSWORD}
            - name: yambas_license_key
              value: ${YAMBAS_LICENSE_KEY}
            - name: yambas_defaultModules
              value: ${YAMBAS_DEFAULT_MODULES}
            - name: yambas_mongodb_hosts_default
              value: ${MONGODB_SERVICE_NAME}:27017
            - name: yambas_mongodb_hosts_live
              value: ${MONGODB_SERVICE_NAME}:27017
            - name: yambas_mongodb_hosts_staging
              value: ${MONGODB_SERVICE_NAME}:27017
            - name: yambas_mongodb_hosts_test
              value: ${MONGODB_SERVICE_NAME}:27017
            - name: yambas_mongodb_connections
              value: '100'
            - name: yambas_limits_maxResults
              value: ${YAMBAS_LIMITS_MAX_RESULTS}
            - name: yambas_limits_maxCompileTimeInMinutes
              value: ${YAMBAS_LIMITS_MAX_COMPILE_TIME_IN_MINUTES}
            - name: yambas_configEncryptionKey
              value: ${YAMBAS_CONFIG_ENCRYPTION_KEY}
            - name: yambas_git_conflictmode
              value: ${YAMBAS_GIT_CONFLICTMODE}
            - name: yambas_strictChecks
              value: ${YAMBAS_STRICT_CHECKS}
            name: alpine-yambas
            image: ${YAMBAS_IMAGE}
            ports:
              - containerPort: 8081
                protocol: TCP
              - containerPort: 10009
                protocol: TCP
              - containerPort: 10021
                protocol: TCP
              - containerPort: 10300
                protocol: TCP
            resources:
              limits:
                memory: ${YAMBAS_MEMORY_LIMIT}
            livenessProbe:
              httpGet:
                path: /yambas/rest
                port: 8081
              initialDelaySeconds: 180
              timeoutSeconds: 10
            readinessProbe:
              httpGet:
                path: /yambas/rest
                port: 8081
              initialDelaySeconds: 180
              timeoutSeconds: 10
            imagePullPolicy: Always
        restartPolicy: Always
        terminationGracePeriodSeconds: 30
        dnsPolicy: ClusterFirst
        securityContext: {  }
  status: {  }
- apiVersion: v1
  kind: Service
  metadata:
    name: ${YAMBAS_SERVICE_NAME}
    labels:
      template: apiomat-yambas
  spec:
    selector:
      deploymentconfig: ${YAMBAS_SERVICE_NAME}
    ports:
    - nodePort: 0
      name: ftp1
      port: 10021
      protocol: TCP
      targetPort: 10021
    - nodePort: 0
      name: ftp2
      port: 10300
      protocol: TCP
      targetPort: 10300
    - nodePort: 0
      name: ajp
      port: 10009
      protocol: TCP
      targetPort: 10009
    - nodePort: 0
      name: yambas
      port: 8081
      protocol: TCP
      targetPort: 8081
- apiVersion: v1
  kind: Route
  metadata:
    name: ${YAMBAS_ROUTE}
  spec:
    to:
      kind: Service
      name: ${YAMBAS_SERVICE_NAME}
    port:
      targetPort: 8081
  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: MONGODB_SERVICE_NAME
  description: "MongoDB service name (for example: mongodb)"
  value: mongodb
- name: YAMBAS_SERVICE_NAME
  description: "Service name of yambas. Yambas is the 'heart' and backend of ApiOmat."
  value: yambas
- name: YAMBAS_ROUTE
  description: "Route to yambas service (generated)"
  generate: expression
  from: "yambas[a-z]{15}"
- name: YAMBAS_LICENSE_KEY
  description: "License key of ApiOmat"
  value: <license key>
- name: YAMBAS_LIMITS_MAX_COMPILE_TIME_IN_MINUTES
  description: "Maximal compile time (in minutes)"
  value: '15'
- name: YAMBAS_DEFAULT_MODULES
  description: "Default Modules"
  value: 'Basics'
- name: YAMBAS_STRICT_CHECKS
  description: "Strict authorization checks in nativemodules, false will do less checks and is only allow backward"
  value: 'true'
- name: YAMBAS_LIMITS_MAX_RESULTS
  description: "Max Results for data queries "
  value: '1000'
- name: YAMBAS_GIT_CONFLICTMODE
  description: "Git ConflictMode "
  value: 'branch'
- name: YAMBAS_CONFIG_ENCRYPTION_KEY
  description: "Config encryption key (generated) "
  generate: expression
  from: "[a-z0-9]{16}"
- 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: YAMBAS_MEMORY_LIMIT
  description: "Memory limit of yambas (min. 4Gi)"
  value: 4Gi
- name: YAMBAS_IMAGE
  description: "Url to the docker yambas image"
  value: docker.io/apiomat/alpine-yambas:2.6.3