kind: List
apiVersion: v1
metadata: {}

items:

  - apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: oshinko
      annotations:
        serviceaccounts.openshift.io/oauth-redirectreference.first: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"oshinko-web-oaproxy"}}'

  - apiVersion: v1
    kind: RoleBinding
    metadata:
      name: oshinko-edit
    roleRef:
      name: edit
    subjects:
      - kind: ServiceAccount
        name: oshinko

  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: oshinko-py36-conf
    data:
      sparkimage: openshift-spark-py36:2.4-latest

  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: default-oshinko-cluster-config
    data:
      sparkimage: openshift-spark:2.4-latest

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: radanalytics-pyspark
      labels:
        radanalytics.io/imagestream: radanalytics-pyspark
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/radanalytics-pyspark:stable
        importPolicy: {}
        name: stable
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: radanalytics-pyspark-py36
      labels:
        radanalytics.io/imagestream: radanalytics-pyspark-py36
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/radanalytics-pyspark-py36:stable
        importPolicy: {}
        name: stable
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: radanalytics-java-spark
      labels:
        radanalytics.io/imagestream: radanalytics-java-spark
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/radanalytics-java-spark:stable
        importPolicy: {}
        name: stable
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: radanalytics-scala-spark
      labels:
        radanalytics.io/imagestream: radanalytics-scala-spark
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/radanalytics-scala-spark:stable
        importPolicy: {}
        name: stable
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: openshift-spark
      labels:
        radanalytics.io/imagestream: openshift-spark
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/openshift-spark:2.4-latest
        importPolicy: {}
        name: 2.4-latest
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: openshift-spark-py36
      labels:
        radanalytics.io/imagestream: openshift-spark-py36
    spec:
      lookupPolicy:
        local: true
      tags:
      - annotations: null
        from:
          kind: DockerImage
          name: radanalyticsio/openshift-spark-py36:2.4-latest
        importPolicy: {}
        name: 2.4-latest
        referencePolicy:
          type: Source

  - apiVersion: v1
    kind: Template
    labels:
      application: oshinko-python-spark
      createdBy: template-oshinko-python-spark-build-dc
    metadata:
      annotations:
        description: Create a buildconfig, imagestream and deploymentconfig using source-to-image and Python Spark source files hosted in git
        openshift.io/display-name: Apache Spark Python
      name: oshinko-python-spark-build-dc
    objects:
    - apiVersion: v1
      kind: ImageStream
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        dockerImageRepository: ${APPLICATION_NAME}
        tags:
        - name: latest
    - apiVersion: v1
      kind: BuildConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        output:
          to:
            kind: ImageStreamTag
            name: ${APPLICATION_NAME}:latest
        source:
          contextDir: ${CONTEXT_DIR}
          git:
            ref: ${GIT_REF}
            uri: ${GIT_URI}
          type: Git
        strategy:
          sourceStrategy:
            env:
            - name: APP_FILE
              value: ${APP_FILE}
            from:
              kind: ImageStreamTag
              name: radanalytics-pyspark:stable
          type: Source
        triggers:
        - imageChange: {}
          type: ImageChange
        - type: ConfigChange
        - github:
            secret: ${APPLICATION_NAME}
          type: GitHub
        - generic:
            secret: ${APPLICATION_NAME}
          type: Generic
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          deploymentConfig: ${APPLICATION_NAME}
          app: ${APPLICATION_NAME}
      spec:
        replicas: 1
        selector:
          deploymentConfig: ${APPLICATION_NAME}
        strategy:
          type: Rolling
        template:
          metadata:
            labels:
              deploymentConfig: ${APPLICATION_NAME}
              app: ${APPLICATION_NAME}
          spec:
            containers:
            - env:
              - name: DRIVER_HOST
                value: ${APPLICATION_NAME}-headless
              - name: OSHINKO_CLUSTER_NAME
                value: ${OSHINKO_CLUSTER_NAME}
              - name: APP_ARGS
                value: ${APP_ARGS}
              - name: SPARK_OPTIONS
                value: ${SPARK_OPTIONS}
              - name: OSHINKO_DEL_CLUSTER
                value: ${OSHINKO_DEL_CLUSTER}
              - name: APP_EXIT
                value: "true"
              - name: OSHINKO_NAMED_CONFIG
                value: ${OSHINKO_NAMED_CONFIG}
              - name: OSHINKO_SPARK_DRIVER_CONFIG
                value: ${OSHINKO_SPARK_DRIVER_CONFIG}
              - name: POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              image: ${APPLICATION_NAME}
              imagePullPolicy: IfNotPresent
              name: ${APPLICATION_NAME}
              resources: {}
              terminationMessagePath: /dev/termination-log
              volumeMounts:
              - mountPath: /etc/podinfo
                name: podinfo
                readOnly: false
            dnsPolicy: ClusterFirst
            restartPolicy: Always
            serviceAccount: oshinko
            volumes:
            - downwardAPI:
                items:
                - fieldRef:
                    fieldPath: metadata.labels
                  path: labels
              name: podinfo
        triggers:
        - imageChangeParams:
            automatic: true
            containerNames:
              - ${APPLICATION_NAME}
            from:
              kind: ImageStreamTag
              name: ${APPLICATION_NAME}:latest
          type: ImageChange
        - type: ConfigChange
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        ports:
        - name: 8080-tcp
          port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}-headless
        labels:
          app: ${APPLICATION_NAME}
      spec:
        clusterIP: None
        ports:
        - name: driver-rpc-port
          port: 7078
          protocol: TCP
          targetPort: 7078
        - name: blockmanager
          port: 7079
          protocol: TCP
          targetPort: 7079
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    parameters:
    - description: 'The name to use for the buildconfig, imagestream and deployment components'
      from: 'python-spark-[a-z0-9]{4}'
      generate: expression
      name: APPLICATION_NAME
      required: true
    - description: The URL of the repository with your application source code
      displayName: Git Repository URL
      name: GIT_URI
    - description: Optional branch, tag or commit
      displayName: Git Reference
      name: GIT_REF
    - description: Git sub-directory path
      name: CONTEXT_DIR
    - description: The name of the main py file to run. If this is not specified and there is a single py file at top level of the git respository, that file will be chosen.
      name: APP_FILE
    - description: Command line arguments to pass to the Spark application
      name: APP_ARGS
    - description: List of additional Spark options to pass to spark-submit (for exmaple --conf property=value --conf property=value). Note, --master and --class are set by the launcher and should not be set here
      name: SPARK_OPTIONS
    - description: The name of the Spark cluster to run against. The cluster will be created if it does not exist, and a random cluster name will be chosen if this value is left blank.
      name: OSHINKO_CLUSTER_NAME
    - description: The name of a stored cluster configuration to use if a cluster is created, default is 'default'.
      name: OSHINKO_NAMED_CONFIG
    - description: The name of a configmap to use for the Spark configuration of the driver. If this configmap is empty the default Spark configuration will be used.
      name: OSHINKO_SPARK_DRIVER_CONFIG
    - description: If a cluster is created on-demand, delete the cluster when the application finishes if this option is set to 'true'
      name: OSHINKO_DEL_CLUSTER
      required: true
      value: 'true'

  - apiVersion: v1
    kind: Template
    labels:
      application: oshinko-python36-spark
      createdBy: template-oshinko-python36-spark-build-dc
    metadata:
      annotations:
        description: Create a buildconfig, imagestream and deploymentconfig using source-to-image and Python 3.6 Spark source files hosted in git
        openshift.io/display-name: Apache Spark Python 3.6
      name: oshinko-python36-spark-build-dc
    objects:
    - apiVersion: v1
      kind: ImageStream
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        dockerImageRepository: ${APPLICATION_NAME}
        tags:
        - name: latest
    - apiVersion: v1
      kind: BuildConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        output:
          to:
            kind: ImageStreamTag
            name: ${APPLICATION_NAME}:latest
        source:
          contextDir: ${CONTEXT_DIR}
          git:
            ref: ${GIT_REF}
            uri: ${GIT_URI}
          type: Git
        strategy:
          sourceStrategy:
            env:
            - name: APP_FILE
              value: ${APP_FILE}
            from:
              kind: ImageStreamTag
              name: radanalytics-pyspark-py36:stable
          type: Source
        triggers:
        - imageChange: {}
          type: ImageChange
        - type: ConfigChange
        - github:
            secret: ${APPLICATION_NAME}
          type: GitHub
        - generic:
            secret: ${APPLICATION_NAME}
          type: Generic
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          deploymentConfig: ${APPLICATION_NAME}
          app: ${APPLICATION_NAME}
      spec:
        replicas: 1
        selector:
          deploymentConfig: ${APPLICATION_NAME}
        strategy:
          type: Rolling
        template:
          metadata:
            labels:
              deploymentConfig: ${APPLICATION_NAME}
              app: ${APPLICATION_NAME}
          spec:
            containers:
            - env:
              - name: DRIVER_HOST
                value: ${APPLICATION_NAME}-headless
              - name: OSHINKO_CLUSTER_NAME
                value: ${OSHINKO_CLUSTER_NAME}
              - name: APP_ARGS
                value: ${APP_ARGS}
              - name: SPARK_OPTIONS
                value: ${SPARK_OPTIONS}
              - name: OSHINKO_DEL_CLUSTER
                value: ${OSHINKO_DEL_CLUSTER}
              - name: APP_EXIT
                value: "true"
              - name: OSHINKO_NAMED_CONFIG
                value: ${OSHINKO_NAMED_CONFIG}
              - name: OSHINKO_SPARK_DRIVER_CONFIG
                value: ${OSHINKO_SPARK_DRIVER_CONFIG}
              - name: POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              image: ${APPLICATION_NAME}
              imagePullPolicy: IfNotPresent
              name: ${APPLICATION_NAME}
              resources: {}
              terminationMessagePath: /dev/termination-log
              volumeMounts:
              - mountPath: /etc/podinfo
                name: podinfo
                readOnly: false
            dnsPolicy: ClusterFirst
            restartPolicy: Always
            serviceAccount: oshinko
            volumes:
            - downwardAPI:
                items:
                - fieldRef:
                    fieldPath: metadata.labels
                  path: labels
              name: podinfo
        triggers:
        - imageChangeParams:
            automatic: true
            containerNames:
              - ${APPLICATION_NAME}
            from:
              kind: ImageStreamTag
              name: ${APPLICATION_NAME}:latest
          type: ImageChange
        - type: ConfigChange
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        ports:
        - name: 8080-tcp
          port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}-headless
        labels:
          app: ${APPLICATION_NAME}
      spec:
        clusterIP: None
        ports:
        - name: driver-rpc-port
          port: 7078
          protocol: TCP
          targetPort: 7078
        - name: blockmanager
          port: 7079
          protocol: TCP
          targetPort: 7079
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    parameters:
    - description: 'The name to use for the buildconfig, imagestream and deployment components'
      from: 'python-spark-[a-z0-9]{4}'
      generate: expression
      name: APPLICATION_NAME
      required: true
    - description: The URL of the repository with your application source code
      displayName: Git Repository URL
      name: GIT_URI
    - description: Optional branch, tag or commit
      displayName: Git Reference
      name: GIT_REF
    - description: Git sub-directory path
      name: CONTEXT_DIR
    - description: The name of the main py file to run. If this is not specified and there is a single py file at top level of the git respository, that file will be chosen.
      name: APP_FILE
    - description: Command line arguments to pass to the Spark application
      name: APP_ARGS
    - description: List of additional Spark options to pass to spark-submit (for exmaple --conf property=value --conf property=value). Note, --master and --class are set by the launcher and should not be set here
      name: SPARK_OPTIONS
    - description: The name of the Spark cluster to run against. The cluster will be created if it does not exist, and a random cluster name will be chosen if this value is left blank.
      name: OSHINKO_CLUSTER_NAME
    - description: The name of a stored cluster configuration to use if a cluster is created, default is 'default'.
      name: OSHINKO_NAMED_CONFIG
      value: oshinko-py36-conf
    - description: The name of a configmap to use for the Spark configuration of the driver. If this configmap is empty the default Spark configuration will be used.
      name: OSHINKO_SPARK_DRIVER_CONFIG
    - description: If a cluster is created on-demand, delete the cluster when the application finishes if this option is set to 'true'
      name: OSHINKO_DEL_CLUSTER
      required: true
      value: 'true'

  - apiVersion: v1
    kind: Template
    labels:
      application: oshinko-java-spark
      createdBy: template-oshinko-java-spark-build-dc
    metadata:
      annotations:
        description: Create a buildconfig, imagestream and deploymentconfig using source-to-image and Java Spark source files hosted in git'
        openshift.io/display-name: Apache Spark Java
      name: oshinko-java-spark-build-dc
    objects:
    - apiVersion: v1
      kind: ImageStream
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        dockerImageRepository: ${APPLICATION_NAME}
        tags:
        - name: latest
    - apiVersion: v1
      kind: BuildConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        output:
          to:
            kind: ImageStreamTag
            name: ${APPLICATION_NAME}:latest
        source:
          contextDir: ${CONTEXT_DIR}
          git:
            ref: ${GIT_REF}
            uri: ${GIT_URI}
          type: Git
        strategy:
          sourceStrategy:
            env:
            - name: APP_FILE
              value: ${APP_FILE}
            from:
              kind: ImageStreamTag
              name: radanalytics-java-spark:stable
          type: Source
        triggers:
        - imageChange: {}
          type: ImageChange
        - type: ConfigChange
        - github:
            secret: ${APPLICATION_NAME}
          type: GitHub
        - generic:
            secret: ${APPLICATION_NAME}
          type: Generic
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          deploymentConfig: ${APPLICATION_NAME}
          app: ${APPLICATION_NAME}
      spec:
        replicas: 1
        selector:
          deploymentConfig: ${APPLICATION_NAME}
        strategy:
          type: Rolling
        template:
          metadata:
            labels:
              deploymentConfig: ${APPLICATION_NAME}
              app: ${APPLICATION_NAME}
          spec:
            containers:
            - env:
              - name: DRIVER_HOST
                value: ${APPLICATION_NAME}-headless
              - name: OSHINKO_CLUSTER_NAME
                value: ${OSHINKO_CLUSTER_NAME}
              - name: APP_ARGS
                value: ${APP_ARGS}
              - name: SPARK_OPTIONS
                value: ${SPARK_OPTIONS}
              - name: APP_MAIN_CLASS
                value: ${APP_MAIN_CLASS}
              - name: OSHINKO_DEL_CLUSTER
                value: ${OSHINKO_DEL_CLUSTER}
              - name: APP_EXIT
                value: "true"
              - name: OSHINKO_NAMED_CONFIG
                value: ${OSHINKO_NAMED_CONFIG}
              - name: OSHINKO_SPARK_DRIVER_CONFIG
                value: ${OSHINKO_SPARK_DRIVER_CONFIG}
              - name: POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              image: ${APPLICATION_NAME}
              imagePullPolicy: IfNotPresent
              name: ${APPLICATION_NAME}
              resources: {}
              terminationMessagePath: /dev/termination-log
              volumeMounts:
              - mountPath: /etc/podinfo
                name: podinfo
                readOnly: false
            dnsPolicy: ClusterFirst
            restartPolicy: Always
            serviceAccount: oshinko
            volumes:
            - downwardAPI:
                items:
                - fieldRef:
                    fieldPath: metadata.labels
                  path: labels
              name: podinfo
        triggers:
        - imageChangeParams:
            automatic: true
            containerNames:
              - ${APPLICATION_NAME}
            from:
              kind: ImageStreamTag
              name: ${APPLICATION_NAME}:latest
          type: ImageChange
        - type: ConfigChange
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        ports:
        - name: 8080-tcp
          port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}-headless
        labels:
          app: ${APPLICATION_NAME}
      spec:
        clusterIP: None
        ports:
        - name: driver-rpc-port
          port: 7078
          protocol: TCP
          targetPort: 7078
        - name: blockmanager
          port: 7079
          protocol: TCP
          targetPort: 7079
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    parameters:
    - description: 'The name to use for the buildconfig, imagestream and deployment objects'
      from: 'java-spark-[a-z0-9]{4}'
      generate: expression
      name: APPLICATION_NAME
      required: true
    - description: Git source URI for application
      name: GIT_URI
    - description: Git branch/tag reference
      name: GIT_REF
      value: master
    - description: Git sub-directory path
      name: CONTEXT_DIR
    - description: The name of the main JAR file. If this is not specified and there is a single JAR produced by the build, that JAR will be chosen.
      name: APP_FILE
    - description: Command line arguments to pass to the Spark application
      name: APP_ARGS
    - description: Application main class for jar-based applications
      name: APP_MAIN_CLASS
    - description: List of additional Spark options to pass to spark-submit (for example --conf property=value --conf property=value). Note, --master and --class are set by the launcher and should not be set here
      name: SPARK_OPTIONS
    - description: The name of the Spark cluster to run against. The cluster will be created if it does not exist, and a random cluster name will be chosen if this value is left blank.
      name: OSHINKO_CLUSTER_NAME
    - description: The name of a stored cluster configuration to use if a cluster is created, default is 'default'.
      name: OSHINKO_NAMED_CONFIG
    - description: The name of a configmap to use for the Spark configuration of the driver. If this configmap is empty the default Spark configuration will be used.
      name: OSHINKO_SPARK_DRIVER_CONFIG
    - description: If a cluster is created on-demand, delete the cluster when the application finishes if this option is set to 'true'
      name: OSHINKO_DEL_CLUSTER
      required: true
      value: "true"

  - apiVersion: v1
    kind: Template
    labels:
      application: oshinko-scala-spark
      createdBy: template-oshinko-scala-spark-build-dc
    metadata:
      annotations:
        description: Create a buildconfig, imagestream and deploymentconfig using source-to-image and Scala Spark source files hosted in git
        openshift.io/display-name: Apache Spark Scala
      name: oshinko-scala-spark-build-dc
    objects:
    - apiVersion: v1
      kind: ImageStream
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        dockerImageRepository: ${APPLICATION_NAME}
        tags:
        - name: latest
    - apiVersion: v1
      kind: BuildConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        output:
          to:
            kind: ImageStreamTag
            name: ${APPLICATION_NAME}:latest
        source:
          contextDir: ${CONTEXT_DIR}
          git:
            ref: ${GIT_REF}
            uri: ${GIT_URI}
          type: Git
        strategy:
          sourceStrategy:
            env:
            - name: APP_FILE
              value: ${APP_FILE}
            - name: SBT_ARGS
              value: ${SBT_ARGS}
            - name: SBT_ARGS_APPEND
              value: ${SBT_ARGS_APPEND}
            from:
              kind: ImageStreamTag
              name: radanalytics-scala-spark:stable
          type: Source
        triggers:
        - imageChange: {}
          type: ImageChange
        - type: ConfigChange
        - github:
            secret: ${APPLICATION_NAME}
          type: GitHub
        - generic:
            secret: ${APPLICATION_NAME}
          type: Generic
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          deploymentConfig: ${APPLICATION_NAME}
          app: ${APPLICATION_NAME}
      spec:
        replicas: 1
        selector:
          deploymentConfig: ${APPLICATION_NAME}
        strategy:
          type: Rolling
        template:
          metadata:
            labels:
              deploymentConfig: ${APPLICATION_NAME}
              app: ${APPLICATION_NAME}
          spec:
            containers:
            - env:
              - name: DRIVER_HOST
                value: ${APPLICATION_NAME}-headless
              - name: OSHINKO_CLUSTER_NAME
                value: ${OSHINKO_CLUSTER_NAME}
              - name: APP_ARGS
                value: ${APP_ARGS}
              - name: SPARK_OPTIONS
                value: ${SPARK_OPTIONS}
              - name: APP_MAIN_CLASS
                value: ${APP_MAIN_CLASS}
              - name: OSHINKO_DEL_CLUSTER
                value: ${OSHINKO_DEL_CLUSTER}
              - name: APP_EXIT
                value: "true"
              - name: OSHINKO_NAMED_CONFIG
                value: ${OSHINKO_NAMED_CONFIG}
              - name: OSHINKO_SPARK_DRIVER_CONFIG
                value: ${OSHINKO_SPARK_DRIVER_CONFIG}
              - name: POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              image: ${APPLICATION_NAME}
              imagePullPolicy: IfNotPresent
              name: ${APPLICATION_NAME}
              resources: {}
              terminationMessagePath: /dev/termination-log
              volumeMounts:
              - mountPath: /etc/podinfo
                name: podinfo
                readOnly: false
            dnsPolicy: ClusterFirst
            restartPolicy: Always
            serviceAccount: oshinko
            volumes:
            - downwardAPI:
                items:
                - fieldRef:
                    fieldPath: metadata.labels
                  path: labels
              name: podinfo
        triggers:
        - imageChangeParams:
            automatic: true
            containerNames:
              - ${APPLICATION_NAME}
            from:
              kind: ImageStreamTag
              name: ${APPLICATION_NAME}:latest
          type: ImageChange
        - type: ConfigChange
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}
        labels:
          app: ${APPLICATION_NAME}
      spec:
        ports:
        - name: 8080-tcp
          port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    - apiVersion: v1
      kind: Service
      metadata:
        name: ${APPLICATION_NAME}-headless
        labels:
          app: ${APPLICATION_NAME}
      spec:
        clusterIP: None
        ports:
        - name: driver-rpc-port
          port: 7078
          protocol: TCP
          targetPort: 7078
        - name: blockmanager
          port: 7079
          protocol: TCP
          targetPort: 7079
        selector:
          deploymentConfig: ${APPLICATION_NAME}
    parameters:
    - description: The name to use for the buildconfig, imagestream and deployment objects
      from: 'scala-spark-[a-z0-9]{4}'
      generate: expression
      name: APPLICATION_NAME
      required: true
    - description: Git source URI for application
      name: GIT_URI
    - description: Git branch/tag reference
      name: GIT_REF
      value: master
    - description: Git sub-directory path
      name: CONTEXT_DIR
    - description: The name of the main JAR file. If this is not specified and there is a single JAR produced by the build, that JAR will be chosen.
      name: APP_FILE
    - description: Command line arguments to pass to the spark application
      name: APP_ARGS
    - description: Application main class for jar-based applications
      name: APP_MAIN_CLASS
    - description: List of additional spark options to pass to spark-submit (for exmaple --conf property=value --conf property=value). Note, --master and --class are set by the launcher and should not be set here
      name: SPARK_OPTIONS
    - description: The name of the spark cluster to run against. The cluster will be created if it does not exist, and a random cluster name will be chosen if this value is left blank.
      name: OSHINKO_CLUSTER_NAME
    - description: The name of a stored cluster configuration to use if a cluster is created, default is 'default'.
      name: OSHINKO_NAMED_CONFIG
    - description: The name of a configmap to use for the spark configuration of the driver. If this configmap is empty the default spark configuration will be used.
      name: OSHINKO_SPARK_DRIVER_CONFIG
    - description: If a cluster is created on-demand, delete the cluster when the application finishes if this option is set to 'true'
      name: OSHINKO_DEL_CLUSTER
      required: true
      value: 'true'
    - description: Arguments to use when calling sbt, replacing the default `package`
      name: SBT_ARGS
    - description: Additional sbt arguments, useful for adding task arguments to sbt like `publish makePom`
      name: SBT_ARGS_APPEND

  - apiVersion: v1
    kind: Template
    template: oshinko-webui-secure
    metadata:
      name: oshinko-webui-secure
      annotations:
        description: |-
          Launch the Oshinko Apache Spark cluster management WebUI, with a
          secure login backed by OpenShift.
        openshift.io/display-name: Oshinko WebUI(secure)
    objects:
      - kind: Service
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}-ocproxy
          labels:
            name: ${OSHINKO_WEB_NAME}-ocproxy
            appName: ${OSHINKO_WEB_NAME}
        spec:
          ports:
          - name: oc-proxy-port
            protocol: TCP
            port: 8001
            targetPort: 8001
          selector:
            name: ${OSHINKO_WEB_NAME}
      - kind: Service
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}
          labels:
            name: ${OSHINKO_WEB_NAME}
            appName: ${OSHINKO_WEB_NAME}
        spec:
          ports:
            - name: o-web-port
              protocol: TCP
              port: 8080
              targetPort: 8080
          selector:
            name: ${OSHINKO_WEB_NAME}
      - kind: Route
        apiVersion: route.openshift.io/v1
        metadata:
          name: ${OSHINKO_WEB_NAME}-oaproxy
        spec:
          path: /webui
          to:
            name: ${OSHINKO_WEB_NAME}-oaproxy
          tls:
            termination: Reencrypt
          alternateBackends:
            - kind: Service
              name: ${OSHINKO_WEB_NAME}-oaproxy
      - kind: Service
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}-oaproxy
          annotations:
            service.alpha.openshift.io/serving-cert-secret-name: proxy-tls
        spec:
          ports:
          - name: oaproxy-port
            port: 443
            targetPort: 8443
          selector:
            name: ${OSHINKO_WEB_NAME}
      - kind: DeploymentConfig
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}
          labels:
            name: ${OSHINKO_WEB_NAME}
            appName: ${OSHINKO_WEB_NAME}
        spec:
          strategy:
            type: Rolling
          triggers:
            - type: ConfigChange
          replicas: 1
          selector:
            name: ${OSHINKO_WEB_NAME}
          template:
            metadata:
              labels:
                name: ${OSHINKO_WEB_NAME}
                appName: ${OSHINKO_WEB_NAME}
            spec:
              containers:
                - name: oauth-proxy
                  image: openshift/oauth-proxy:v1.1.0
                  imagePullPolicy: IfNotPresent
                  ports:
                  - containerPort: 8443
                    name: public
                  args:
                    - --https-address=:8443
                    - --provider=openshift
                    - --openshift-service-account=oshinko
                    - --upstream=http://localhost:8080
                    - --tls-cert=/etc/tls/private/tls.crt
                    - --tls-key=/etc/tls/private/tls.key
                    - --cookie-secret=SECRET
                    - --skip-provider-button
                    - -openshift-sar={"namespace":"$(CURRENT_NAMESPACE)","resource":"services","name":"${OSHINKO_WEB_NAME}","verb":"get"}
                    - --proxy-prefix=/webui
                    - -cookie-expire=24h0m0s
                    - -proxy-prefix=/webui
                    - -cookie-expire=24h0m0s
                  volumeMounts:
                  - mountPath: /etc/tls/private
                    name: proxy-tls
                  env:
                    - name: CURRENT_NAMESPACE
                      valueFrom:
                        fieldRef:
                          fieldPath: metadata.namespace
                - name: ${OSHINKO_WEB_NAME}
                  image: ${OSHINKO_WEB_IMAGE}
                  imagePullPolicy: IfNotPresent
                  ports:
                    - name: o-web-port
                      containerPort: 8080
                      protocol: TCP
                  env:
                    - name: SPARK_DEFAULT
                      value: ${SPARK_DEFAULT}
                    - name: OSHINKO_REFRESH_INTERVAL
                      value: ${OSHINKO_REFRESH_INTERVAL}
                    - name: WEB_ROUTE_NAME
                      value: ${OSHINKO_WEB_NAME}
                    - name: INSECURE_WEBUI
                      value: "false"
                    - name: CURRENT_NAMESPACE
                      valueFrom:
                        fieldRef:
                          fieldPath: metadata.namespace
                  readinessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /webui
                      port: 8080
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
                  livenessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /webui
                      port: 8080
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
                - name: oc-proxy
                  image: ${OSHINKO_WEB_IMAGE}
                  imagePullPolicy: IfNotPresent
                  command:
                    - "/usr/src/app/oc"
                  args:
                    - proxy
                    - "-p"
                    - '8001'
                    - "--address=0.0.0.0"
                    - "--disable-filter=true"
                    - "--api-prefix=/proxy"
                  ports:
                    - name: oc-proxy-port
                      containerPort: 8001
                      protocol: TCP
              volumes:
                - name: proxy-tls
                  secret:
                    secretName: proxy-tls
              serviceAccount: oshinko
    parameters:
      - name: SPARK_DEFAULT
        description: Full name of the spark image to use when creating clusters
        required: false
      - name: OSHINKO_WEB_NAME
        description: Name of the oshinko web service
        value: "oshinko-web"
      - name: OSHINKO_WEB_IMAGE
        description: Full name of the oshinko web image
        required: true
        value: radanalyticsio/oshinko-webui:stable
      - name: OSHINKO_WEB_ROUTE_HOSTNAME
        description: The hostname used to create the external route for the webui
      - name: OSHINKO_REFRESH_INTERVAL
        value: "5"
        description: Refresh interval for updating cluster list in seconds

  - apiVersion: v1
    kind: Template
    template: oshinko-webui
    metadata:
      name: oshinko-webui
      annotations:
        description: Launch the Oshinko Apache Spark cluster management WebUI.
        openshift.io/display-name: Oshinko WebUI
    objects:
      - kind: Service
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}-proxy
          labels:
            name: ${OSHINKO_WEB_NAME}-proxy
        spec:
          ports:
          - name: oc-proxy-port
            protocol: TCP
            port: 8001
            targetPort: 8001
          selector:
            name: ${OSHINKO_WEB_NAME}
      - kind: Service
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}
          labels:
            name: ${OSHINKO_WEB_NAME}
        spec:
          ports:
            - name: o-web-port
              protocol: TCP
              port: 8080
              targetPort: 8080
          selector:
            name: ${OSHINKO_WEB_NAME}
      - kind: Route
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}
        spec:
          host: ${OSHINKO_WEB_ROUTE_HOSTNAME}
          path: /webui
          to:
            kind: Service
            name: ${OSHINKO_WEB_NAME}
          alternateBackends:
            - kind: Service
              name: ${OSHINKO_WEB_NAME}
      - kind: DeploymentConfig
        apiVersion: v1
        metadata:
          name: ${OSHINKO_WEB_NAME}
        spec:
          strategy:
            type: Rolling
          triggers:
            - type: ConfigChange
          replicas: 1
          selector:
            name: ${OSHINKO_WEB_NAME}
          template:
            metadata:
              labels:
                name: ${OSHINKO_WEB_NAME}
            spec:
              containers:
                - name: ${OSHINKO_WEB_NAME}
                  image: ${OSHINKO_WEB_IMAGE}
                  imagePullPolicy: Always
                  ports:
                    - name: o-web-port
                      containerPort: 8080
                      protocol: TCP
                  env:
                    - name: SPARK_DEFAULT
                      value: ${SPARK_DEFAULT}
                    - name: OSHINKO_REFRESH_INTERVAL
                      value: ${OSHINKO_REFRESH_INTERVAL}
                    - name: WEB_ROUTE_NAME
                      value: ${OSHINKO_WEB_NAME}
                    - name: INSECURE_WEBUI
                      value: "true"
                    - name: CURRENT_NAMESPACE
                      valueFrom:
                        fieldRef:
                          fieldPath: metadata.namespace
                  readinessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /webui
                      port: 8080
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
                  livenessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /webui
                      port: 8080
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
                - name: oc-proxy
                  image: ${OSHINKO_WEB_IMAGE}
                  imagePullPolicy: IfNotPresent
                  command:
                    - "/usr/src/app/oc"
                  args:
                    - proxy
                    - "-p"
                    - '8001'
                    - "--address=0.0.0.0"
                    - "--disable-filter=true"
                    - "--api-prefix=/proxy"
                  ports:
                    - name: oc-proxy-port
                      containerPort: 8001
                      protocol: TCP
              serviceAccount: oshinko
    parameters:
      - name: SPARK_DEFAULT
        description: Full name of the spark image to use when creating clusters
        required: false
      - name: OSHINKO_WEB_NAME
        description: Name of the oshinko web service
        value: "oshinko-web"
      - name: OSHINKO_WEB_IMAGE
        description: Full name of the oshinko web image
        required: true
        value: radanalyticsio/oshinko-webui:stable
      - name: OSHINKO_WEB_ROUTE_HOSTNAME
        description: The hostname used to create the external route for the webui
      - name: OSHINKO_REFRESH_INTERVAL
        value: "5"
        description: Refresh interval for updating cluster list in seconds

  - apiVersion: v1
    kind: Template
    labels:
      application: radanalytics-jupyter-notebook
      createdBy: template-radanalytics-jupyter-notebook
    metadata:
      annotations:
        description: Launch a Jupyter notebook
        openshift.io/display-name: Jupyter Notebook
      name: radanalytics-jupyter-notebook
    objects:
      - kind: Service
        metadata:
          name: ${NAME}
          labels:
            app: ${NAME}
        apiVersion: v1
        spec:
          ports:
          - name: http-port
            protocol: TCP
            port: 8888
            targetPort: 8888
          selector:
            deploymentConfig: ${NAME}
      - kind: Route
        metadata:
          name: ${NAME}
          labels:
            app: ${NAME}
        apiVersion: v1
        spec:
          path: /
          to:
            name: ${NAME}
            kind: Service
      - kind: DeploymentConfig
        metadata:
          name: ${NAME}
          labels:
            app: ${NAME}
            deploymentConfig: ${NAME}
        apiVersion: v1
        spec:
          selector:
            deploymentConfig: ${NAME}
          strategy:
            type: Rolling
          triggers:
            - type: ConfigChange
          replicas: 1
          template:
            metadata:
              labels:
                app: ${NAME}
                deploymentConfig: ${NAME}
            spec:
              containers:
                - name: ${NAME}
                  image: radanalyticsio/base-notebook
                  imagePullPolicy: IfNotPresent
                  ports:
                    - name: http-port
                      containerPort: 8888
                      protocol: TCP
                  env:
                    - name: JUPYTER_NOTEBOOK_PASSWORD
                      value: ${JUPYTER_NOTEBOOK_PASSWORD}
                    - name: JUPYTER_NOTEBOOK_X_INCLUDE
                      value: ${JUPYTER_NOTEBOOK_X_INCLUDE}
                  readinessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /
                      port: 8888
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
                  livenessProbe:
                    failureThreshold: 3
                    httpGet:
                      path: /
                      port: 8888
                      scheme: HTTP
                    periodSeconds: 10
                    successThreshold: 1
                    timeoutSeconds: 1
                    initialDelaySeconds: 20
    parameters:
      - name: NAME
        description: A name for this notebook instance
        generate: expression
        from: 'jupyter-[a-z0-9]{4}'
      - name: JUPYTER_NOTEBOOK_PASSWORD
        description: A password for the notebook interface
        required: true
      - name: JUPYTER_NOTEBOOK_X_INCLUDE
        description: A URI to a single notebook file that will be downloaded into the container, must be a network accessable location.
        required: false
