{
	"kind": "Template",
	"apiVersion": "v1",
	"metadata": {
		"name": "amq63-persistent",
		"creationTimestamp": null,
		"annotations": {
			"description": "An example JBoss A-MQ application. For more information about using this template, see https://github.com/jboss-openshift/application-templates.",
			"iconClass": "icon-amq",
			"openshift.io/display-name": "JBoss A-MQ 6.3 (no SSL)",
			"openshift.io/provider-display-name": "Red Hat, Inc.",
			"tags": "messaging,amq,jboss",
			"template.openshift.io/documentation-url": "https://access.redhat.com/documentation/en/red-hat-jboss-amq/",
			"template.openshift.io/long-description": "This template defines resources needed to develop Red Hat JBoss A-MQ 6.3 based application, including a deployment configuration and using persistence.",
			"template.openshift.io/support-url": "https://access.redhat.com",
			"version": "1.4.17"
		}
	},
	"message": "A new persistent messaging service has been created in your project. It will handle the protocol(s) \"${MQ_PROTOCOL}\". The username/password for accessing the service is ${MQ_USERNAME}/${MQ_PASSWORD}.",
	"objects": [
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The broker's AMQP port."
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-amqp"
			},
			"spec": {
				"ports": [
					{
						"port": 5672,
						"targetPort": 5672
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The broker's MQTT port."
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-mqtt"
			},
			"spec": {
				"ports": [
					{
						"port": 1883,
						"targetPort": 1883
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The broker's STOMP port."
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-stomp"
			},
			"spec": {
				"ports": [
					{
						"port": 61613,
						"targetPort": 61613
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The broker's OpenWire port.",
					"service.alpha.openshift.io/dependencies": "[{\"name\": \"${APPLICATION_NAME}-amq-amqp\", \"kind\": \"Service\"},{\"name\": \"${APPLICATION_NAME}-amq-mqtt\", \"kind\": \"Service\"},{\"name\": \"${APPLICATION_NAME}-amq-stomp\", \"kind\": \"Service\"}]"
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-tcp"
			},
			"spec": {
				"ports": [
					{
						"port": 61616,
						"targetPort": 61616
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "Supports node discovery for mesh formation.",
					"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true"
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-mesh"
			},
			"spec": {
				"clusterIP": "None",
				"ports": [
					{
						"name": "mesh",
						"port": 61616
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "DeploymentConfig",
			"metadata": {
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq"
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-amq"
				},
				"strategy": {
					"rollingParams": {
						"maxSurge": 0
					},
					"type": "Rolling"
				},
				"template": {
					"metadata": {
						"labels": {
							"application": "${APPLICATION_NAME}",
							"deploymentConfig": "${APPLICATION_NAME}-amq"
						},
						"name": "${APPLICATION_NAME}-amq"
					},
					"spec": {
						"containers": [
							{
								"env": [
									{
										"name": "AMQ_USER",
										"value": "${MQ_USERNAME}"
									},
									{
										"name": "AMQ_PASSWORD",
										"value": "${MQ_PASSWORD}"
									},
									{
										"name": "AMQ_TRANSPORTS",
										"value": "${MQ_PROTOCOL}"
									},
									{
										"name": "AMQ_QUEUES",
										"value": "${MQ_QUEUES}"
									},
									{
										"name": "AMQ_TOPICS",
										"value": "${MQ_TOPICS}"
									},
									{
										"name": "MQ_SERIALIZABLE_PACKAGES",
										"value": "${MQ_SERIALIZABLE_PACKAGES}"
									},
									{
										"name": "AMQ_SPLIT",
										"value": "${AMQ_SPLIT}"
									},
									{
										"name": "AMQ_MESH_DISCOVERY_TYPE",
										"value": "${AMQ_MESH_DISCOVERY_TYPE}"
									},
									{
										"name": "AMQ_MESH_SERVICE_NAME",
										"value": "${APPLICATION_NAME}-amq-mesh"
									},
									{
										"name": "AMQ_MESH_SERVICE_NAMESPACE",
										"valueFrom": {
											"fieldRef": {
												"fieldPath": "metadata.namespace"
											}
										}
									},
									{
										"name": "AMQ_STORAGE_USAGE_LIMIT",
										"value": "${AMQ_STORAGE_USAGE_LIMIT}"
									},
									{
										"name": "AMQ_QUEUE_MEMORY_LIMIT",
										"value": "${AMQ_QUEUE_MEMORY_LIMIT}"
									}
								],
								"image": "jboss-amq-63",
								"imagePullPolicy": "Always",
								"name": "${APPLICATION_NAME}-amq",
								"ports": [
									{
										"containerPort": 8778,
										"name": "jolokia",
										"protocol": "TCP"
									},
									{
										"containerPort": 5672,
										"name": "amqp",
										"protocol": "TCP"
									},
									{
										"containerPort": 1883,
										"name": "mqtt",
										"protocol": "TCP"
									},
									{
										"containerPort": 61613,
										"name": "stomp",
										"protocol": "TCP"
									},
									{
										"containerPort": 61616,
										"name": "tcp",
										"protocol": "TCP"
									}
								],
								"readinessProbe": {
									"exec": {
										"command": [
											"/bin/bash",
											"-c",
											"/opt/amq/bin/readinessProbe.sh"
										]
									}
								},
								"volumeMounts": [
									{
										"mountPath": "/opt/amq/data",
										"name": "${APPLICATION_NAME}-amq-pvol"
									}
								]
							}
						],
						"terminationGracePeriodSeconds": 60,
						"volumes": [
							{
								"name": "${APPLICATION_NAME}-amq-pvol",
								"persistentVolumeClaim": {
									"claimName": "${APPLICATION_NAME}-amq-claim"
								}
							}
						]
					}
				},
				"triggers": [
					{
						"imageChangeParams": {
							"automatic": true,
							"containerNames": [
								"${APPLICATION_NAME}-amq"
							],
							"from": {
								"kind": "ImageStreamTag",
								"name": "jboss-amq-63:1.4",
								"namespace": "${IMAGE_STREAM_NAMESPACE}"
							}
						},
						"type": "ImageChange"
					},
					{
						"type": "ConfigChange"
					}
				]
			}
		},
		{
			"apiVersion": "v1",
			"kind": "DeploymentConfig",
			"metadata": {
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-drainer"
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-drainer"
				},
				"strategy": {
					"type": "Recreate"
				},
				"template": {
					"metadata": {
						"labels": {
							"application": "${APPLICATION_NAME}",
							"deploymentConfig": "${APPLICATION_NAME}-drainer"
						},
						"name": "${APPLICATION_NAME}-drainer"
					},
					"spec": {
						"containers": [
							{
								"command": [
									"/opt/amq/bin/drain.sh"
								],
								"env": [
									{
										"name": "AMQ_USER",
										"value": "${MQ_USERNAME}"
									},
									{
										"name": "AMQ_PASSWORD",
										"value": "${MQ_PASSWORD}"
									},
									{
										"name": "AMQ_MESH_SERVICE_NAME",
										"value": "${APPLICATION_NAME}-amq-mesh"
									},
									{
										"name": "AMQ_MESH_SERVICE_NAMESPACE",
										"valueFrom": {
											"fieldRef": {
												"fieldPath": "metadata.namespace"
											}
										}
									}
								],
								"image": "jboss-amq-63",
								"imagePullPolicy": "Always",
								"name": "${APPLICATION_NAME}-drainer",
								"ports": [
									{
										"containerPort": 8778,
										"name": "jolokia",
										"protocol": "TCP"
									},
									{
										"containerPort": 61616,
										"name": "tcp",
										"protocol": "TCP"
									}
								],
								"volumeMounts": [
									{
										"mountPath": "/opt/amq/data",
										"name": "${APPLICATION_NAME}-amq-pvol"
									}
								]
							}
						],
						"terminationGracePeriodSeconds": 60,
						"volumes": [
							{
								"name": "${APPLICATION_NAME}-amq-pvol",
								"persistentVolumeClaim": {
									"claimName": "${APPLICATION_NAME}-amq-claim"
								}
							}
						]
					}
				},
				"triggers": [
					{
						"imageChangeParams": {
							"automatic": true,
							"containerNames": [
								"${APPLICATION_NAME}-drainer"
							],
							"from": {
								"kind": "ImageStreamTag",
								"name": "jboss-amq-63:1.4",
								"namespace": "${IMAGE_STREAM_NAMESPACE}"
							}
						},
						"type": "ImageChange"
					},
					{
						"type": "ConfigChange"
					}
				]
			}
		},
		{
			"apiVersion": "v1",
			"kind": "PersistentVolumeClaim",
			"metadata": {
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-amq-claim"
			},
			"spec": {
				"accessModes": [
					"ReadWriteMany"
				],
				"resources": {
					"requests": {
						"storage": "${VOLUME_CAPACITY}"
					}
				}
			}
		}
	],
	"parameters": [
		{
			"name": "APPLICATION_NAME",
			"displayName": "Application Name",
			"description": "The name for the application.",
			"value": "broker",
			"required": true
		},
		{
			"name": "AMQ_SPLIT",
			"displayName": "Split Data?",
			"description": "Split the data directory for each node in a mesh, this is now the default behaviour.",
			"value": "true"
		},
		{
			"name": "MQ_PROTOCOL",
			"displayName": "A-MQ Protocols",
			"description": "Protocols to configure, separated by commas.  Allowed values are: `openwire`, `amqp`, `stomp` and `mqtt`.",
			"value": "openwire"
		},
		{
			"name": "MQ_QUEUES",
			"displayName": "Queues",
			"description": "Queue names, separated by commas.  These queues will be automatically created when the broker starts.  If left empty, queues will be still created dynamically."
		},
		{
			"name": "MQ_TOPICS",
			"displayName": "Topics",
			"description": "Topic names, separated by commas.  These topics will be automatically created when the broker starts.  If left empty, topics will be still created dynamically."
		},
		{
			"name": "MQ_SERIALIZABLE_PACKAGES",
			"displayName": "A-MQ Serializable Packages",
			"description": "List of packages that are allowed to be serialized for use in ObjectMessage, separated by commas. If your app doesn't use ObjectMessages, leave this blank. This is a security enforcement. For the rationale, see http://activemq.apache.org/objectmessage.html"
		},
		{
			"name": "VOLUME_CAPACITY",
			"displayName": "A-MQ Volume Size",
			"description": "Size of the volume used by A-MQ for persisting messages.",
			"value": "1Gi",
			"required": true
		},
		{
			"name": "MQ_USERNAME",
			"displayName": "A-MQ Username",
			"description": "User name for standard broker user.  It is required for connecting to the broker.  If left empty, it will be generated.",
			"generate": "expression",
			"from": "user[a-zA-Z0-9]{3}"
		},
		{
			"name": "MQ_PASSWORD",
			"displayName": "A-MQ Password",
			"description": "Password for standard broker user.  It is required for connecting to the broker.  If left empty, it will be generated.",
			"generate": "expression",
			"from": "[a-zA-Z0-9]{8}"
		},
		{
			"name": "AMQ_MESH_DISCOVERY_TYPE",
			"displayName": "A-MQ Mesh Discovery Type",
			"description": "The discovery agent type to use for discovering mesh endpoints.  'dns' will use OpenShift's DNS service to resolve endpoints.  'kube' will use Kubernetes REST API to resolve service endpoints.  If using 'kube' the service account for the pod must have the 'view' role, which can be added via 'oc policy add-role-to-user view system:serviceaccount:\u003cnamespace\u003e:default' where \u003cnamespace\u003e is the project namespace.",
			"value": "dns"
		},
		{
			"name": "AMQ_STORAGE_USAGE_LIMIT",
			"displayName": "A-MQ Store Usage Limit",
			"description": "Sets the store disk limit usage in activemq.xml. If the value set is greater than the disk size, it will be resized to the available disk space.",
			"value": "100 gb"
		},
		{
			"name": "AMQ_QUEUE_MEMORY_LIMIT",
			"displayName": "Queue Memory Limit",
			"description": "The queue memory limit (default is 1mb)"
		},
		{
			"name": "IMAGE_STREAM_NAMESPACE",
			"displayName": "ImageStream Namespace",
			"description": "Namespace in which the ImageStreams for Red Hat Middleware images 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.",
			"value": "openshift",
			"required": true
		}
	],
	"labels": {
		"template": "amq63-persistent",
		"xpaas": "1.4.17"
	}
}