{
	"kind": "Template",
	"apiVersion": "v1",
	"metadata": {
		"name": "sso72-mysql",
		"creationTimestamp": null,
		"annotations": {
			"description": "An example RH-SSO 7 application with a MySQL database. For more information about using this template, see https://github.com/jboss-openshift/application-templates.",
			"iconClass": "icon-sso",
			"openshift.io/display-name": "Red Hat Single Sign-On 7.2 + MySQL (Ephemeral with passthrough TLS)",
			"openshift.io/provider-display-name": "Red Hat, Inc.",
			"tags": "sso,keycloak,jboss,hidden",
			"template.openshift.io/documentation-url": "https://access.redhat.com/documentation/en/red-hat-single-sign-on/",
			"template.openshift.io/long-description": "This template defines resources needed to develop Red Hat Single Sign-On 7.2 server based deployment, deployment configuration for MySQL using ephemeral (temporary) storage, and securing RH-SSO communication using passthrough TLS.",
			"template.openshift.io/support-url": "https://access.redhat.com",
			"version": "rh-sso-7.2-v1.4.0"
		}
	},
	"message": "A new RH-SSO service (using MySQL) has been created in your project. The admin username/password for accessing the master realm via the RH-SSO console is ${SSO_ADMIN_USERNAME}/${SSO_ADMIN_PASSWORD}. The username/password for accessing the MySQL database \"${DB_DATABASE}\" is ${DB_USERNAME}/${DB_PASSWORD}. Please be sure to create the following secrets: \"${HTTPS_SECRET}\" containing the ${HTTPS_KEYSTORE} file used for serving secure content; \"${JGROUPS_ENCRYPT_SECRET}\" containing the ${JGROUPS_ENCRYPT_KEYSTORE} file used for securing JGroups communications; \"${SSO_TRUSTSTORE_SECRET}\" containing the ${SSO_TRUSTSTORE} file used for securing RH-SSO requests.",
	"objects": [
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The web server's http port.",
					"service.alpha.openshift.io/dependencies": "[{\"name\": \"${APPLICATION_NAME}-mysql\", \"kind\": \"Service\"}]"
				},
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "server"
				},
				"name": "${APPLICATION_NAME}"
			},
			"spec": {
				"ports": [
					{
						"port": 8080,
						"targetPort": 8080
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The web server's https port.",
					"service.alpha.openshift.io/dependencies": "[{\"name\": \"${APPLICATION_NAME}-mysql\", \"kind\": \"Service\"}]"
				},
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "server"
				},
				"name": "secure-${APPLICATION_NAME}"
			},
			"spec": {
				"ports": [
					{
						"port": 8443,
						"targetPort": 8443
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The database server's port."
				},
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "database"
				},
				"name": "${APPLICATION_NAME}-mysql"
			},
			"spec": {
				"ports": [
					{
						"port": 3306,
						"targetPort": 3306
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-mysql"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "Service",
			"metadata": {
				"annotations": {
					"description": "The JGroups ping port for clustering.",
					"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true"
				},
				"labels": {
					"application": "${APPLICATION_NAME}"
				},
				"name": "${APPLICATION_NAME}-ping"
			},
			"spec": {
				"clusterIP": "None",
				"ports": [
					{
						"name": "ping",
						"port": 8888
					}
				],
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}"
				}
			}
		},
		{
			"apiVersion": "v1",
			"id": "${APPLICATION_NAME}-http",
			"kind": "Route",
			"metadata": {
				"annotations": {
					"description": "Route for application's http service."
				},
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "server"
				},
				"name": "${APPLICATION_NAME}"
			},
			"spec": {
				"host": "${HOSTNAME_HTTP}",
				"to": {
					"name": "${APPLICATION_NAME}"
				}
			}
		},
		{
			"apiVersion": "v1",
			"id": "${APPLICATION_NAME}-https",
			"kind": "Route",
			"metadata": {
				"annotations": {
					"description": "Route for application's https service."
				},
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "server"
				},
				"name": "secure-${APPLICATION_NAME}"
			},
			"spec": {
				"host": "${HOSTNAME_HTTPS}",
				"tls": {
					"termination": "passthrough"
				},
				"to": {
					"name": "secure-${APPLICATION_NAME}"
				}
			}
		},
		{
			"apiVersion": "v1",
			"kind": "DeploymentConfig",
			"metadata": {
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "server"
				},
				"name": "${APPLICATION_NAME}"
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}"
				},
				"strategy": {
					"type": "Recreate"
				},
				"template": {
					"metadata": {
						"labels": {
							"application": "${APPLICATION_NAME}",
							"component": "server",
							"deploymentConfig": "${APPLICATION_NAME}"
						},
						"name": "${APPLICATION_NAME}"
					},
					"spec": {
						"containers": [
							{
								"env": [
									{
										"name": "DB_SERVICE_PREFIX_MAPPING",
										"value": "${APPLICATION_NAME}-mysql=DB"
									},
									{
										"name": "DB_JNDI",
										"value": "${DB_JNDI}"
									},
									{
										"name": "DB_USERNAME",
										"value": "${DB_USERNAME}"
									},
									{
										"name": "DB_PASSWORD",
										"value": "${DB_PASSWORD}"
									},
									{
										"name": "DB_DATABASE",
										"value": "${DB_DATABASE}"
									},
									{
										"name": "TX_DATABASE_PREFIX_MAPPING",
										"value": "${APPLICATION_NAME}-mysql=DB"
									},
									{
										"name": "DB_MIN_POOL_SIZE",
										"value": "${DB_MIN_POOL_SIZE}"
									},
									{
										"name": "DB_MAX_POOL_SIZE",
										"value": "${DB_MAX_POOL_SIZE}"
									},
									{
										"name": "DB_TX_ISOLATION",
										"value": "${DB_TX_ISOLATION}"
									},
									{
										"name": "JGROUPS_PING_PROTOCOL",
										"value": "openshift.DNS_PING"
									},
									{
										"name": "OPENSHIFT_DNS_PING_SERVICE_NAME",
										"value": "${APPLICATION_NAME}-ping"
									},
									{
										"name": "OPENSHIFT_DNS_PING_SERVICE_PORT",
										"value": "8888"
									},
									{
										"name": "HTTPS_KEYSTORE_DIR",
										"value": "/etc/eap-secret-volume"
									},
									{
										"name": "HTTPS_KEYSTORE",
										"value": "${HTTPS_KEYSTORE}"
									},
									{
										"name": "HTTPS_KEYSTORE_TYPE",
										"value": "${HTTPS_KEYSTORE_TYPE}"
									},
									{
										"name": "HTTPS_NAME",
										"value": "${HTTPS_NAME}"
									},
									{
										"name": "HTTPS_PASSWORD",
										"value": "${HTTPS_PASSWORD}"
									},
									{
										"name": "JGROUPS_ENCRYPT_SECRET",
										"value": "${JGROUPS_ENCRYPT_SECRET}"
									},
									{
										"name": "JGROUPS_ENCRYPT_KEYSTORE_DIR",
										"value": "/etc/jgroups-encrypt-secret-volume"
									},
									{
										"name": "JGROUPS_ENCRYPT_KEYSTORE",
										"value": "${JGROUPS_ENCRYPT_KEYSTORE}"
									},
									{
										"name": "JGROUPS_ENCRYPT_NAME",
										"value": "${JGROUPS_ENCRYPT_NAME}"
									},
									{
										"name": "JGROUPS_ENCRYPT_PASSWORD",
										"value": "${JGROUPS_ENCRYPT_PASSWORD}"
									},
									{
										"name": "JGROUPS_CLUSTER_PASSWORD",
										"value": "${JGROUPS_CLUSTER_PASSWORD}"
									},
									{
										"name": "SSO_ADMIN_USERNAME",
										"value": "${SSO_ADMIN_USERNAME}"
									},
									{
										"name": "SSO_ADMIN_PASSWORD",
										"value": "${SSO_ADMIN_PASSWORD}"
									},
									{
										"name": "SSO_REALM",
										"value": "${SSO_REALM}"
									},
									{
										"name": "SSO_SERVICE_USERNAME",
										"value": "${SSO_SERVICE_USERNAME}"
									},
									{
										"name": "SSO_SERVICE_PASSWORD",
										"value": "${SSO_SERVICE_PASSWORD}"
									},
									{
										"name": "SSO_TRUSTSTORE",
										"value": "${SSO_TRUSTSTORE}"
									},
									{
										"name": "SSO_TRUSTSTORE_DIR",
										"value": "/etc/sso-secret-volume"
									},
									{
										"name": "SSO_TRUSTSTORE_PASSWORD",
										"value": "${SSO_TRUSTSTORE_PASSWORD}"
									}
								],
								"image": "${APPLICATION_NAME}",
								"imagePullPolicy": "Always",
								"livenessProbe": {
									"exec": {
										"command": [
											"/bin/bash",
											"-c",
											"/opt/eap/bin/livenessProbe.sh"
										]
									},
									"initialDelaySeconds": 60
								},
								"name": "${APPLICATION_NAME}",
								"ports": [
									{
										"containerPort": 8778,
										"name": "jolokia",
										"protocol": "TCP"
									},
									{
										"containerPort": 8080,
										"name": "http",
										"protocol": "TCP"
									},
									{
										"containerPort": 8443,
										"name": "https",
										"protocol": "TCP"
									},
									{
										"containerPort": 8888,
										"name": "ping",
										"protocol": "TCP"
									}
								],
								"readinessProbe": {
									"exec": {
										"command": [
											"/bin/bash",
											"-c",
											"/opt/eap/bin/readinessProbe.sh"
										]
									}
								},
								"resources": {
									"limits": {
										"memory": "${MEMORY_LIMIT}"
									}
								},
								"volumeMounts": [
									{
										"mountPath": "/etc/eap-secret-volume",
										"name": "eap-keystore-volume",
										"readOnly": true
									},
									{
										"mountPath": "/etc/jgroups-encrypt-secret-volume",
										"name": "eap-jgroups-keystore-volume",
										"readOnly": true
									},
									{
										"mountPath": "/etc/sso-secret-volume",
										"name": "sso-truststore-volume",
										"readOnly": true
									}
								]
							}
						],
						"terminationGracePeriodSeconds": 75,
						"volumes": [
							{
								"name": "eap-keystore-volume",
								"secret": {
									"secretName": "${HTTPS_SECRET}"
								}
							},
							{
								"name": "eap-jgroups-keystore-volume",
								"secret": {
									"secretName": "${JGROUPS_ENCRYPT_SECRET}"
								}
							},
							{
								"name": "sso-truststore-volume",
								"secret": {
									"secretName": "${SSO_TRUSTSTORE_SECRET}"
								}
							}
						]
					}
				},
				"triggers": [
					{
						"imageChangeParams": {
							"automatic": true,
							"containerNames": [
								"${APPLICATION_NAME}"
							],
							"from": {
								"kind": "ImageStreamTag",
								"name": "redhat-sso72-openshift:1.4",
								"namespace": "${IMAGE_STREAM_NAMESPACE}"
							}
						},
						"type": "ImageChange"
					},
					{
						"type": "ConfigChange"
					}
				]
			}
		},
		{
			"apiVersion": "v1",
			"kind": "DeploymentConfig",
			"metadata": {
				"labels": {
					"application": "${APPLICATION_NAME}",
					"component": "database"
				},
				"name": "${APPLICATION_NAME}-mysql"
			},
			"spec": {
				"replicas": 1,
				"selector": {
					"deploymentConfig": "${APPLICATION_NAME}-mysql"
				},
				"strategy": {
					"type": "Recreate"
				},
				"template": {
					"metadata": {
						"labels": {
							"application": "${APPLICATION_NAME}",
							"component": "database",
							"deploymentConfig": "${APPLICATION_NAME}-mysql"
						},
						"name": "${APPLICATION_NAME}-mysql"
					},
					"spec": {
						"containers": [
							{
								"env": [
									{
										"name": "MYSQL_USER",
										"value": "${DB_USERNAME}"
									},
									{
										"name": "MYSQL_PASSWORD",
										"value": "${DB_PASSWORD}"
									},
									{
										"name": "MYSQL_DATABASE",
										"value": "${DB_DATABASE}"
									},
									{
										"name": "MYSQL_LOWER_CASE_TABLE_NAMES",
										"value": "${MYSQL_LOWER_CASE_TABLE_NAMES}"
									},
									{
										"name": "MYSQL_MAX_CONNECTIONS",
										"value": "${MYSQL_MAX_CONNECTIONS}"
									},
									{
										"name": "MYSQL_FT_MIN_WORD_LEN",
										"value": "${MYSQL_FT_MIN_WORD_LEN}"
									},
									{
										"name": "MYSQL_FT_MAX_WORD_LEN",
										"value": "${MYSQL_FT_MAX_WORD_LEN}"
									},
									{
										"name": "MYSQL_AIO",
										"value": "${MYSQL_AIO}"
									}
								],
								"image": "mysql",
								"imagePullPolicy": "Always",
								"livenessProbe": {
									"initialDelaySeconds": 30,
									"tcpSocket": {
										"port": 3306
									},
									"timeoutSeconds": 1
								},
								"name": "${APPLICATION_NAME}-mysql",
								"ports": [
									{
										"containerPort": 3306,
										"protocol": "TCP"
									}
								],
								"readinessProbe": {
									"exec": {
										"command": [
											"/bin/sh",
											"-i",
											"-c",
											"MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"
										]
									},
									"initialDelaySeconds": 5,
									"timeoutSeconds": 1
								},
								"volumeMounts": [
									{
										"mountPath": "/var/lib/mysql/data",
										"name": "${APPLICATION_NAME}-data"
									}
								]
							}
						],
						"terminationGracePeriodSeconds": 60,
						"volumes": [
							{
								"emptyDir": {
									"medium": ""
								},
								"name": "${APPLICATION_NAME}-data"
							}
						]
					}
				},
				"triggers": [
					{
						"imageChangeParams": {
							"automatic": true,
							"containerNames": [
								"${APPLICATION_NAME}-mysql"
							],
							"from": {
								"kind": "ImageStreamTag",
								"name": "mysql:${MYSQL_IMAGE_STREAM_TAG}",
								"namespace": "${IMAGE_STREAM_NAMESPACE}"
							}
						},
						"type": "ImageChange"
					},
					{
						"type": "ConfigChange"
					}
				]
			}
		}
	],
	"parameters": [
		{
			"name": "APPLICATION_NAME",
			"displayName": "Application Name",
			"description": "The name for the application.",
			"value": "sso",
			"required": true
		},
		{
			"name": "HOSTNAME_HTTP",
			"displayName": "Custom http Route Hostname",
			"description": "Custom hostname for http service route. Leave blank for default hostname, e.g.: \u003capplication-name\u003e.\u003cproject\u003e.\u003cdefault-domain-suffix\u003e"
		},
		{
			"name": "HOSTNAME_HTTPS",
			"displayName": "Custom https Route Hostname",
			"description": "Custom hostname for https service route. Leave blank for default hostname, e.g.: \u003capplication-name\u003e.\u003cproject\u003e.\u003cdefault-domain-suffix\u003e"
		},
		{
			"name": "DB_JNDI",
			"displayName": "Database JNDI Name",
			"description": "Database JNDI name used by application to resolve the datasource, e.g. java:/jboss/datasources/mysql",
			"value": "java:jboss/datasources/KeycloakDS"
		},
		{
			"name": "DB_DATABASE",
			"displayName": "Database Name",
			"description": "Database name",
			"value": "root",
			"required": true
		},
		{
			"name": "HTTPS_SECRET",
			"displayName": "Server Keystore Secret Name",
			"description": "The name of the secret containing the keystore file",
			"value": "sso-app-secret"
		},
		{
			"name": "HTTPS_KEYSTORE",
			"displayName": "Server Keystore Filename",
			"description": "The name of the keystore file within the secret",
			"value": "keystore.jks"
		},
		{
			"name": "HTTPS_KEYSTORE_TYPE",
			"displayName": "Server Keystore Type",
			"description": "The type of the keystore file (JKS or JCEKS)"
		},
		{
			"name": "HTTPS_NAME",
			"displayName": "Server Certificate Name",
			"description": "The name associated with the server certificate (e.g. jboss)"
		},
		{
			"name": "HTTPS_PASSWORD",
			"displayName": "Server Keystore Password",
			"description": "The password for the keystore and certificate (e.g. mykeystorepass)"
		},
		{
			"name": "DB_MIN_POOL_SIZE",
			"displayName": "Datasource Minimum Pool Size",
			"description": "Sets xa-pool/min-pool-size for the configured datasource."
		},
		{
			"name": "DB_MAX_POOL_SIZE",
			"displayName": "Datasource Maximum Pool Size",
			"description": "Sets xa-pool/max-pool-size for the configured datasource."
		},
		{
			"name": "DB_TX_ISOLATION",
			"displayName": "Datasource Transaction Isolation",
			"description": "Sets transaction-isolation for the configured datasource."
		},
		{
			"name": "MYSQL_LOWER_CASE_TABLE_NAMES",
			"displayName": "MySQL Lower Case Table Names",
			"description": "Sets how the table names are stored and compared."
		},
		{
			"name": "MYSQL_MAX_CONNECTIONS",
			"displayName": "MySQL Maximum number of connections",
			"description": "The maximum permitted number of simultaneous client connections."
		},
		{
			"name": "MYSQL_FT_MIN_WORD_LEN",
			"displayName": "MySQL FullText Minimum Word Length",
			"description": "The minimum length of the word to be included in a FULLTEXT index."
		},
		{
			"name": "MYSQL_FT_MAX_WORD_LEN",
			"displayName": "MySQL FullText Maximum Word Length",
			"description": "The maximum length of the word to be included in a FULLTEXT index."
		},
		{
			"name": "MYSQL_AIO",
			"displayName": "MySQL AIO",
			"description": "Controls the innodb_use_native_aio setting value if the native AIO is broken."
		},
		{
			"name": "DB_USERNAME",
			"displayName": "Database Username",
			"description": "Database user name",
			"generate": "expression",
			"from": "user[a-zA-Z0-9]{3}",
			"required": true
		},
		{
			"name": "DB_PASSWORD",
			"displayName": "Database Password",
			"description": "Database user password",
			"generate": "expression",
			"from": "[a-zA-Z0-9]{8}",
			"required": true
		},
		{
			"name": "JGROUPS_ENCRYPT_SECRET",
			"displayName": "JGroups Secret Name",
			"description": "The name of the secret containing the keystore file",
			"value": "sso-app-secret"
		},
		{
			"name": "JGROUPS_ENCRYPT_KEYSTORE",
			"displayName": "JGroups Keystore Filename",
			"description": "The name of the keystore file within the secret",
			"value": "jgroups.jceks"
		},
		{
			"name": "JGROUPS_ENCRYPT_NAME",
			"displayName": "JGroups Certificate Name",
			"description": "The name associated with the server certificate (e.g. secret-key)"
		},
		{
			"name": "JGROUPS_ENCRYPT_PASSWORD",
			"displayName": "JGroups Keystore Password",
			"description": "The password for the keystore and certificate (e.g. password)"
		},
		{
			"name": "JGROUPS_CLUSTER_PASSWORD",
			"displayName": "JGroups Cluster Password",
			"description": "JGroups cluster password",
			"generate": "expression",
			"from": "[a-zA-Z0-9]{8}",
			"required": true
		},
		{
			"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
		},
		{
			"name": "SSO_ADMIN_USERNAME",
			"displayName": "RH-SSO Administrator Username",
			"description": "RH-SSO Server administrator username",
			"generate": "expression",
			"from": "[a-zA-Z0-9]{8}",
			"required": true
		},
		{
			"name": "SSO_ADMIN_PASSWORD",
			"displayName": "RH-SSO Administrator Password",
			"description": "RH-SSO Server administrator password",
			"generate": "expression",
			"from": "[a-zA-Z0-9]{8}",
			"required": true
		},
		{
			"name": "SSO_REALM",
			"displayName": "RH-SSO Realm",
			"description": "Realm to be created in the RH-SSO server (e.g. demorealm)."
		},
		{
			"name": "SSO_SERVICE_USERNAME",
			"displayName": "RH-SSO Service Username",
			"description": "The username used to access the RH-SSO service. This is used by clients to create the appliction client(s) within the specified RH-SSO realm."
		},
		{
			"name": "SSO_SERVICE_PASSWORD",
			"displayName": "RH-SSO Service Password",
			"description": "The password for the RH-SSO service user."
		},
		{
			"name": "SSO_TRUSTSTORE",
			"displayName": "RH-SSO Trust Store",
			"description": "The name of the truststore file within the secret (e.g. truststore.jks)"
		},
		{
			"name": "SSO_TRUSTSTORE_PASSWORD",
			"displayName": "RH-SSO Trust Store Password",
			"description": "The password for the truststore and certificate (e.g. mykeystorepass)"
		},
		{
			"name": "SSO_TRUSTSTORE_SECRET",
			"displayName": "RH-SSO Trust Store Secret",
			"description": "The name of the secret containing the truststore file (e.g. truststore-secret). Used for volume secretName",
			"value": "sso-app-secret"
		},
		{
			"name": "MYSQL_IMAGE_STREAM_TAG",
			"displayName": "MySQL Image Stream Tag",
			"description": "The tag to use for the \"mysql\" image stream. Typically, this aligns with the major.minor version of MySQL.",
			"value": "5.7",
			"required": true
		},
		{
			"name": "MEMORY_LIMIT",
			"displayName": "Container Memory Limit",
			"description": "Container memory limit.",
			"value": "1Gi"
		}
	],
	"labels": {
		"rh-sso": "7.2-v1.4.0",
		"template": "sso72-mysql"
	}
}