To demonstrate a multi-tiered web application, I used ghost, the microblogging platform to deploy the application using kustomize. Kustomize is a higher-level orchestration of the steps to deploy an application with environment specific overlays.
Steps
- Clone the repository
git clone https://github.com/prb112/openshift-demo.git
- Install kustomize
$ brew install kustomize
-
Login to your cluster using
oc
. -
Generate a randomized password
$ ENV_PASS=$(openssl rand -hex 10)
$ echo ${ENV_PASS}
Note, save the output…
- Generate the working url for the cluster/ghost app.
$ export WEB_DOMAIN=https://web-route-ghost.apps.$(oc get ingress.config.openshift.io cluster -o yaml | grep domain | awk '{print $NF}')
$ echo ${WEB_DOMAIN}
-
Change to the ghost/deploy directory using
cd openshift-demo/ghost/deploy
-
Create the secret for the database
$ cat secrets/01_db_secret.yml | sed "s|ENV_PASS|${ENV_PASS}|" | oc apply -f -
- Create the configmap for the Ghost app URL.
$ cat secrets/02_web_cm.yml | sed "s|WEB_DOMAIN|${WEB_DOMAIN}|" | oc apply -f -
- Create the deployment for the website
$ oc apply -k overlays/dev
namespace/ghost configured
service/db-service unchanged
service/web unchanged
persistentvolumeclaim/db-pvc unchanged
persistentvolumeclaim/web-content unchanged
deployment.apps/ghost-db unchanged
deployment.apps/web unchanged
route.route.openshift.io/web-route unchanged
- To clean it up you can run…
$ oc delete -k overlays/dev
namespace "ghost" deleted
service "db-service" deleted
service "web" deleted
persistentvolumeclaim "db-pvc" deleted
persistentvolumeclaim "web-content" deleted
deployment.apps "ghost-db" deleted
deployment.apps "web" deleted
route.route.openshift.io "web-route" deleted
- To see your website URL, you can grab the config map.
$ oc get cm -o yaml
- Navigate to the URL, such as https://web-route-ghost.apps.xyz.zzz.zyz.com/ghost/ to start setting up your site.
Note, if I had time, I would have generated a non-privileged user for MySQL and used that on the MySQL instance.
References
- https://elixm.com/how-to-deploy-ghost-blog-with-kubernetes/
- https://hub.docker.com/_/ghost
- https://hub.docker.com/_/mysql
- https://github.com/openshift-cs/ghost-example/blob/master/ghost_template.yaml