{ "kind": "Template", "apiVersion": "v1", "metadata": { "name": "wordpress-classic-standalone", "annotations": { "openshift.io/display-name": "WordPress (Classic / Standalone)", "description": "Creates a WordPress installation with separate MySQL database instance. Requires that two persistent volumes be available. If a ReadWriteMany persistent volume type is available and used, WordPress can be scaled to multiple replicas and the deployment strategy switched to Rolling to permit rolling deployments on restarts.", "tags": "quickstart,php,wordpress", "iconClass": "icon-php" } }, "parameters": [ { "name": "APPLICATION_NAME", "description": "The name of the WordPress instance.", "value": "my-wordpress-site", "from": "[a-zA-Z0-9]", "required": true }, { "name": "QUICKSTART_REPOSITORY_URL", "description": "The URL of the quickstart Git repository.", "value": "https://github.com/openshift-evangelists/wordpress-quickstart", "required": true }, { "name": "WORDPRESS_VOLUME_SIZE", "description": "Size of the persistent volume for Wordpress.", "value": "1Gi", "required": true }, { "name": "WORDPRESS_VOLUME_TYPE", "description": "Type of the persistent volume for Wordpress.", "value": "ReadWriteOnce", "required": true }, { "name": "WORDPRESS_DEPLOYMENT_STRATEGY", "description": "Type of the deployment strategy for Wordpress.", "value": "Recreate", "required": true }, { "name": "WORDPRESS_MEMORY_LIMIT", "description": "Amount of memory available to WordPress.", "value": "512Mi", "required": true }, { "name": "DATABASE_VOLUME_SIZE", "description": "Size of the persistent volume for the database.", "value": "1Gi", "required": true }, { "name": "DATABASE_MEMORY_LIMIT", "description": "Amount of memory available to the database.", "value": "512Mi", "required": true }, { "description": "The name of the database user.", "name": "DATABASE_USERNAME", "from": "user[a-f0-9]{8}", "generate": "expression" }, { "description": "The password for the database user.", "name": "DATABASE_PASSWORD", "from": "[a-zA-Z0-9]{12}", "generate": "expression" }, { "name": "MYSQL_VERSION", "description": "The version of the MySQL database.", "value": "5.7", "required": true }, { "name": "PHP_VERSION", "description": "The version of the PHP builder.", "value": "7.0", "required": true } ], "objects": [ { "kind": "ImageStream", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}-img", "labels": { "app": "${APPLICATION_NAME}" } } }, { "kind": "BuildConfig", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "triggers": [ { "type": "ConfigChange" }, { "type": "ImageChange" } ], "source": { "type": "Git", "git": { "uri": "${QUICKSTART_REPOSITORY_URL}" } }, "strategy": { "type": "Source", "sourceStrategy": { "from": { "kind": "ImageStreamTag", "namespace": "openshift", "name": "php:${PHP_VERSION}" } } }, "output": { "to": { "kind": "ImageStreamTag", "name": "${APPLICATION_NAME}-img:latest" }, "imageLabels": [ { "name": "io.k8s.display-name", "value": "WordPress" }, { "name": "io.k8s.description", "value": "WordPress application and S2I builder." }, { "name": "io.openshift.s2i.scripts-url", "value": "image:///opt/app-root/s2i" }, { "name": "io.s2i.scripts-url", "value": "image:///opt/app-root/s2i" }, { "name": "io.openshift.tags", "value": "builder,php,wordpress" } ] } } }, { "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "strategy": { "type": "${WORDPRESS_DEPLOYMENT_STRATEGY}" }, "triggers": [ { "type": "ConfigChange" }, { "type": "ImageChange", "imageChangeParams": { "automatic": true, "containerNames": [ "wordpress" ], "from": { "kind": "ImageStreamTag", "name": "${APPLICATION_NAME}-img:latest" } } } ], "replicas": 1, "selector": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}" }, "template": { "metadata": { "labels": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}" } }, "spec": { "volumes": [ { "name": "data", "persistentVolumeClaim": { "claimName": "${APPLICATION_NAME}-wordpress-data" } } ], "containers": [ { "name": "wordpress", "image": "${APPLICATION_NAME}-img", "ports": [ { "containerPort": 8080, "protocol": "TCP" } ], "resources": { "limits": { "memory": "${WORDPRESS_MEMORY_LIMIT}" } }, "readinessProbe": { "failureThreshold": 3, "httpGet": { "path": "/wp-admin/install.php", "port": 8080, "scheme": "HTTP", "httpHeaders": [ { "name": "X-Forwarded-Proto", "value": "https" } ] }, "periodSeconds": 10, "successThreshold": 1, "timeoutSeconds": 1 }, "livenessProbe": { "failureThreshold": 3, "httpGet": { "path": "/wp-admin/install.php", "port": 8080, "scheme": "HTTP", "httpHeaders": [ { "name": "X-Forwarded-Proto", "value": "https" } ] }, "periodSeconds": 10, "successThreshold": 1, "timeoutSeconds": 1 }, "env": [ { "name": "MYSQL_DATABASE", "value": "wordpress" }, { "name": "MYSQL_USER", "value": "${DATABASE_USERNAME}" }, { "name": "MYSQL_PASSWORD", "value": "${DATABASE_PASSWORD}" }, { "name": "MYSQL_HOST", "value": "${APPLICATION_NAME}-db" }, { "name": "MYSQL_TABLE_PREFIX", "value": "wp_" } ], "volumeMounts": [ { "name": "data", "mountPath": "/opt/app-root/src" } ] } ] } } } }, { "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}-db", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "strategy": { "type": "Recreate" }, "triggers": [ { "type": "ConfigChange" }, { "type": "ImageChange", "imageChangeParams": { "automatic": true, "containerNames": [ "mysql" ], "from": { "kind": "ImageStreamTag", "namespace": "openshift", "name": "mysql:${MYSQL_VERSION}" } } } ], "replicas": 1, "selector": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}-db" }, "template": { "metadata": { "labels": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}-db" } }, "spec": { "volumes": [ { "name": "data", "persistentVolumeClaim": { "claimName": "${APPLICATION_NAME}-mysql-data" } } ], "containers": [ { "name": "mysql", "image": "mysql", "ports": [ { "containerPort": 3306, "protocol": "TCP" } ], "resources": { "limits": { "memory": "${DATABASE_MEMORY_LIMIT}" } }, "readinessProbe": { "timeoutSeconds": 1, "initialDelaySeconds": 5, "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'"] } }, "livenessProbe": { "timeoutSeconds": 1, "initialDelaySeconds": 30, "tcpSocket": { "port": 3306 } }, "env": [ { "name": "MYSQL_DATABASE", "value": "wordpress" }, { "name": "MYSQL_USER", "value": "${DATABASE_USERNAME}" }, { "name": "MYSQL_PASSWORD", "value": "${DATABASE_PASSWORD}" } ], "volumeMounts": [ { "name": "data", "mountPath": "/var/lib/mysql/data" } ] } ] } } } }, { "kind": "Service", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "ports": [ { "name": "8080-tcp", "protocol": "TCP", "port": 8080, "targetPort": 8080 } ], "selector": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}" } } }, { "kind": "Service", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}-db", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "ports": [ { "name": "3306-tcp", "protocol": "TCP", "port": 3306, "targetPort": 3306 } ], "selector": { "app": "${APPLICATION_NAME}", "deploymentconfig": "${APPLICATION_NAME}-db" } } }, { "kind": "Route", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "host": "", "to": { "kind": "Service", "name": "${APPLICATION_NAME}", "weight": 100 }, "port": { "targetPort": 8080 }, "tls": { "termination": "edge", "insecureEdgeTerminationPolicy": "Allow" } } }, { "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}-mysql-data", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "${DATABASE_VOLUME_SIZE}" } } } }, { "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "${APPLICATION_NAME}-wordpress-data", "labels": { "app": "${APPLICATION_NAME}" } }, "spec": { "accessModes": [ "${WORDPRESS_VOLUME_TYPE}" ], "resources": { "requests": { "storage": "${WORDPRESS_VOLUME_SIZE}" } } } } ] }