Using Ghost on OpenShift Container Platform

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

  1. Clone the repository
git clone https://github.com/prb112/openshift-demo.git
  1. Install kustomize
$ brew install kustomize
  1. Login to your cluster using oc.

  2. Generate a randomized password

$ ENV_PASS=$(openssl rand -hex 10)
$ echo ${ENV_PASS}

Note, save the output…

  1. 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}
  1. Change to the ghost/deploy directory using cd openshift-demo/ghost/deploy

  2. Create the secret for the database

$ cat secrets/01_db_secret.yml | sed "s|ENV_PASS|${ENV_PASS}|" | oc apply -f -
  1. Create the configmap for the Ghost app URL.
$ cat secrets/02_web_cm.yml | sed "s|WEB_DOMAIN|${WEB_DOMAIN}|" | oc apply -f -
  1. 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
  1. 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
  1. To see your website URL, you can grab the config map.
$ oc get cm -o yaml
  1. 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

  1. https://elixm.com/how-to-deploy-ghost-blog-with-kubernetes/
  2. https://hub.docker.com/_/ghost
  3. https://hub.docker.com/_/mysql
  4. https://github.com/openshift-cs/ghost-example/blob/master/ghost_template.yaml

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.