{
  "apiVersion": "v1",
  "kind": "Template",
  "metadata": {
    "annotations": {
      "openshift.io/display-name": "Red Hat Fuse 7.1 Camel on Spring Boot with XA Transactions",
      "openshift.io/provider-display-name": "Red Hat, Inc.",
      "description": "Spring Boot, Camel and XA Transactions. This example demonstrates how to run a Camel Service on Spring-Boot that supports XA transactions on two external transactional resources: a JMS resource (A-MQ) and a database (PostgreSQL). This quickstart requires the PostgreSQL database and the A-MQ broker have been deployed and running first, one simple way to run them is to use the templates provided in the Openshift service catalog",
      "tags": "quickstart,java,springboot,fis,jboss-fuse",
      "iconClass": "icon-rh-integration",
      "version": "1.1"
    },
    "name": "s2i-fuse71-spring-boot-camel-xa"
  },
  "labels": {
    "template": "s2i-fuse71-spring-boot-camel-xa"
  },
  "parameters": [
    {
      "name": "APP_NAME",
      "displayName": "Application Name",
      "required": true,
      "value": "s2i-fuse71-xa",
      "description": "The name assigned to the application (max 20 characters)."
    },
    {
      "name": "GIT_REPO",
      "displayName": "Git Repository URL",
      "required": true,
      "value": "https://github.com/jboss-fuse/spring-boot-camel-xa.git",
      "description": "The URL of the repository with your application source code."
    },
    {
      "name": "GIT_REF",
      "displayName": "Git Reference",
      "value": "spring-boot-camel-xa-1.0.0.fuse-710006-redhat-00003",
      "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
    },
    {
      "name": "BROKER_HOST",
      "displayName": "A-MQ Broker Service",
      "required": true,
      "value": "broker-amq-tcp",
      "description": "Set this to the name of the TCP service of the A-MQ broker. You may need to create a broker first."
    },
    {
      "name": "BROKER_USERNAME",
      "displayName": "A-MQ Broker Username",
      "required": true,
      "description": "The username used to authenticate with the A-MQ broker."
    },
    {
      "name": "BROKER_PASSWORD",
      "displayName": "A-MQ Broker Password",
      "required": true,
      "description": "The password used to authenticate with the A-MQ broker."
    },
    {
      "name": "DATABASE_HOST",
      "displayName": "PostgreSQL Service",
      "required": true,
      "value": "postgresql",
      "description": "Set this to the name of the PostgreSQL service. You may need to create the database first."
    },
    {
      "name": "DATABASE_USERNAME",
      "displayName": "PostgreSQL Username",
      "required": true,
      "description": "The username used to authenticate with the PostgreSQL database."
    },
    {
      "name": "DATABASE_PASSWORD",
      "displayName": "PostgreSQL Password",
      "required": true,
      "description": "The password used to authenticate with the PostgreSQL database."
    },
    {
      "name": "VOLUME_SIZE",
      "displayName": "Volume size for transaction log",
      "required": true,
      "value": "1Gi",
      "description": "The size of the volume used to store the transaction log."
    },
    {
      "name": "BUILDER_VERSION",
      "displayName": "Builder version",
      "value": "1.1",
      "description": "The version of the Fuse S2I builder image to use."
    },
    {
      "name": "APP_VERSION",
      "displayName": "Application Version",
      "value": "1.0.0.fuse-710006-redhat-00003",
      "description": "The application version."
    },
    {
      "name": "MAVEN_ARGS",
      "displayName": "Maven Arguments",
      "value": "package -DskipTests -Dfabric8.skip -e -B",
      "description": "Arguments passed to mvn in the build."
    },
    {
      "name": "MAVEN_ARGS_APPEND",
      "displayName": "Extra Maven Arguments",
      "description": "Extra arguments passed to mvn, e.g. for multi-module builds."
    },
    {
      "name": "ARTIFACT_DIR",
      "displayName": "Maven build directory",
      "description": "Directory of the artifact to be built, e.g. for multi-module builds."
    },
    {
      "name": "IMAGE_STREAM_NAMESPACE",
      "displayName": "Image Stream Namespace",
      "value": "openshift",
      "required": true,
      "description": "Namespace in which the Fuse ImageStreams are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you've installed the ImageStreams in a different namespace/project."
    },
    {
      "name": "BUILD_SECRET",
      "displayName": "Git Build Secret",
      "generate": "expression",
      "description": "The secret needed to trigger a build.",
      "from": "[a-zA-Z0-9]{40}"
    },
    {
      "name": "CPU_REQUEST",
      "displayName": "CPU request",
      "value": "0.2",
      "required": true,
      "description": "The amount of CPU to request."
    },
    {
      "name": "MEMORY_REQUEST",
      "displayName": "Memory request",
      "value": "256Mi",
      "required": true,
      "description": "The amount of memory required for the container to run."
    },
    {
      "name": "CPU_LIMIT",
      "displayName": "CPU limit",
      "value": "1.0",
      "required": true,
      "description": "The amount of CPU the container is limited to use."
    },
    {
      "name": "MEMORY_LIMIT",
      "displayName": "Memory limit",
      "value": "256Mi",
      "required": true,
      "description": "The amount of memory the container is limited to use."
    },
    {
      "name": "BUILD_MEMORY_REQUEST",
      "displayName": "Build Memory request",
      "value": "0.7G",
      "required": true,
      "description": "The amount of memory to request for builds."
    },
    {
      "name": "BUILD_MEMORY_LIMIT",
      "displayName": "Build Memory limit",
      "value": "0.8G",
      "required": true,
      "description": "The amount of memory the build container is limited to use."
    }
  ],
  "objects": [
    {
      "kind": "ImageStream",
      "apiVersion": "v1",
      "metadata": {
        "name": "${APP_NAME}",
        "creationTimestamp": null,
        "labels": {
          "component": "${APP_NAME}",
          "group": "quickstarts",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}"
        }
      },
      "spec": {
        "lookupPolicy": {
          "local": true
        }
      },
      "status": {
        "dockerImageRepository": ""
      }
    },
    {
      "kind": "BuildConfig",
      "apiVersion": "v1",
      "metadata": {
        "name": "${APP_NAME}",
        "creationTimestamp": null,
        "labels": {
          "component": "${APP_NAME}",
          "group": "quickstarts",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}"
        }
      },
      "spec": {
        "triggers": [
          {
            "type": "GitHub",
            "github": {
              "secret": "${BUILD_SECRET}"
            }
          },
          {
            "type": "Generic",
            "generic": {
              "secret": "${BUILD_SECRET}"
            }
          },
          {
            "type": "ConfigChange"
          },
          {
            "type": "ImageChange",
            "imageChange": {}
          }
        ],
        "source": {
          "type": "Git",
          "git": {
            "uri": "${GIT_REPO}",
            "ref": "${GIT_REF}"
          }
        },
        "strategy": {
          "type": "Source",
          "sourceStrategy": {
            "from": {
              "kind": "ImageStreamTag",
              "namespace": "${IMAGE_STREAM_NAMESPACE}",
              "name": "fuse7-java-openshift:${BUILDER_VERSION}"
            },
            "forcePull": true,
            "incremental": true,
            "env": [
              {
                "name": "BUILD_LOGLEVEL",
                "value": "5"
              },
              {
                "name": "ARTIFACT_DIR",
                "value": "${ARTIFACT_DIR}"
              },
              {
                "name": "MAVEN_ARGS",
                "value": "${MAVEN_ARGS}"
              },
              {
                "name": "MAVEN_ARGS_APPEND",
                "value": "${MAVEN_ARGS_APPEND}"
              }
            ]
          }
        },
        "output": {
          "to": {
            "kind": "ImageStreamTag",
            "name": "${APP_NAME}:latest"
          }
        },
        "resources": {
          "requests": {
            "memory": "${BUILD_MEMORY_REQUEST}"
          },
          "limits": {
            "memory": "${BUILD_MEMORY_LIMIT}"
          }
        }
      },
      "status": {
        "lastVersion": 0
      }
    },
    {
      "kind": "StatefulSet",
      "apiVersion": "apps/v1beta1",
      "metadata": {
        "name": "${APP_NAME}",
        "labels": {
          "component": "${APP_NAME}",
          "group": "quickstarts",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}"
        },
        "annotations": {
          "image.openshift.io/triggers": "[{\"from\":{\"kind\":\"ImageStreamTag\",\"name\":\"${APP_NAME}:latest\"},\"fieldPath\":\"spec.template.spec.containers[?(@.name==\\\"${APP_NAME}\\\")].image\"}]"
        }
      },
      "spec": {
        "podManagementPolicy": "Parallel",
        "updateStrategy": {
          "type": "RollingUpdate"
        },
        "replicas": 1,
        "selector": {
          "matchLabels": {
            "app": "${APP_NAME}",
            "provider": "s2i",
            "group": "quickstarts"
          }
        },
        "serviceName": "${APP_NAME}-headless",
        "template": {
          "metadata": {
            "labels": {
              "component": "${APP_NAME}",
              "app": "${APP_NAME}",
              "provider": "s2i",
              "version": "${APP_VERSION}",
              "group": "quickstarts"
            }
          },
          "spec": {
            "containers": [
              {
                "env": [
                  {
                    "name": "CLUSTER_RECOVERY_ENABLED",
                    "value": "true"
                  },
                  {
                    "name": "CLUSTER_BASE_DIR",
                    "value": "/var/transaction/data"
                  },
                  {
                    "name": "CLUSTER_NAME",
                    "value": "${APP_NAME}"
                  },
                  {
                    "name": "CLUSTER_NODENAME",
                    "valueFrom": {
                      "fieldRef": {
                        "apiVersion": "v1",
                        "fieldPath": "metadata.name"
                      }
                    }
                  },
                  {
                    "name": "BROKER_HOST",
                    "value": "${BROKER_HOST}"
                  },
                  {
                    "name": "BROKER_USERNAME",
                    "value": "${BROKER_USERNAME}"
                  },
                  {
                    "name": "BROKER_PASSWORD",
                    "value": "${BROKER_PASSWORD}"
                  },
                  {
                    "name": "DATABASE_HOST",
                    "value": "${DATABASE_HOST}"
                  },
                  {
                    "name": "DATABASE_USERNAME",
                    "value": "${DATABASE_USERNAME}"
                  },
                  {
                    "name": "DATABASE_PASSWORD",
                    "value": "${DATABASE_PASSWORD}"
                  },
                  {
                    "name": "KUBERNETES_NAMESPACE",
                    "valueFrom": {
                      "fieldRef": {
                        "fieldPath": "metadata.namespace"
                      }
                    }
                  }
                ],
                "image": "${APP_NAME}:latest",
                "imagePullPolicy": "Always",
                "livenessProbe": {
                  "httpGet": {
                    "path": "/health",
                    "port": 8080,
                    "scheme": "HTTP"
                  },
                  "initialDelaySeconds": 180
                },
                "name": "${APP_NAME}",
                "ports": [
                  {
                    "containerPort": 8080,
                    "name": "http",
                    "protocol": "TCP"
                  },
                  {
                    "containerPort": 8778,
                    "name": "jolokia",
                    "protocol": "TCP"
                  }
                ],
                "readinessProbe": {
                  "httpGet": {
                    "path": "/health",
                    "port": 8080,
                    "scheme": "HTTP"
                  },
                  "initialDelaySeconds": 10
                },
                "resources": {
                  "limits": {
                    "cpu": "1.0",
                    "memory": "256Mi"
                  },
                  "requests": {
                    "cpu": "0.2",
                    "memory": "256Mi"
                  }
                },
                "securityContext": {
                  "privileged": false
                },
                "volumeMounts": [
                  {
                    "mountPath": "/var/transaction/data",
                    "name": "${APP_NAME}-data"
                  }
                ]
              }
            ],
            "serviceAccountName": "${APP_NAME}",
            "terminationGracePeriodSeconds": 180,
            "volumes": [
              {
                "name": "${APP_NAME}-data",
                "persistentVolumeClaim": {
                  "claimName": "${APP_NAME}"
                }
              }
            ]
          }
        }
      }
    },
    {
      "apiVersion": "v1",
      "kind": "Service",
      "metadata": {
        "labels": {
          "component": "${APP_NAME}",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}",
          "group": "quickstarts"
        },
        "name": "${APP_NAME}"
      },
      "spec": {
        "ports": [
          {
            "name": "http",
            "port": 8080,
            "protocol": "TCP",
            "targetPort": 8080
          }
        ],
        "selector": {
          "app": "${APP_NAME}",
          "provider": "s2i",
          "group": "quickstarts"
        }
      }
    },
    {
      "apiVersion" : "v1",
      "kind" : "Service",
      "metadata" : {
        "labels": {
          "component": "${APP_NAME}",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}",
          "group": "quickstarts"
        },
        "name" : "${APP_NAME}-headless"
      },
      "spec" : {
        "clusterIP" : "None",
        "ports" : [ {
          "name" : "http",
          "port" : 8080,
          "protocol" : "TCP",
          "targetPort" : 8080
        } ],
        "selector" : {
          "app" : "${APP_NAME}",
          "group" : "quickstarts",
          "provider" : "s2i"
        }
      }
    },
    {
      "apiVersion" : "route.openshift.io/v1",
      "kind" : "Route",
      "metadata" : {
        "labels" : {
          "component" : "${APP_NAME}",
          "app" : "${APP_NAME}",
          "provider" : "s2i",
          "version" : "${APP_VERSION}",
          "group" : "quickstarts"
        },
        "name" : "${APP_NAME}"
      },
      "spec" : {
        "port" : {
          "targetPort" : 8080
        },
        "to" : {
          "kind" : "Service",
          "name" : "${APP_NAME}"
        }
      }
    },
    {
      "apiVersion": "v1",
      "kind": "ServiceAccount",
      "metadata": {
        "labels": {
          "component": "${APP_NAME}",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}",
          "group": "quickstarts"
        },
        "name": "${APP_NAME}"
      }
    },
    {
      "apiVersion": "v1",
      "kind": "RoleBinding",
      "metadata": {
        "labels": {
          "component": "${APP_NAME}",
          "app": "${APP_NAME}",
          "provider": "s2i",
          "version": "${APP_VERSION}",
          "group": "quickstarts"
        },
        "name": "${APP_NAME}"
      },
      "roleRef": {
        "name": "edit"
      },
      "subjects": [
        {
          "kind": "ServiceAccount",
          "name": "${APP_NAME}"
        }
      ]
    },
    {
      "apiVersion": "v1",
      "kind": "PersistentVolumeClaim",
      "metadata": {
        "labels": {
          "component": "${APP_NAME}",
          "app": "${APP_NAME}",
          "group": "quickstarts",
          "provider": "s2i",
          "version": "${APP_VERSION}"
        },
        "name": "${APP_NAME}"
      },
      "spec": {
        "accessModes": [
          "ReadWriteMany"
        ],
        "resources": {
          "requests": {
            "storage": "${VOLUME_SIZE}"
          }
        }
      }
    }
  ]
}
