Skip to main content

Deploying Workload

In this section we will deploy a simple Wordpress application with MYSQL as the backend database store.

We will test backup and recovery of this application in next section.

Deploying Wordpress App

  1. In your LinuxToolsVM on the browser

  2. Create a new directory for your wordpress application and configuration files

    mkdir wordpress 
    cd wordpress
  3. Make sure default is the current namespace

    oc config set-context --current --namespace=default
  4. Download wordpress and mysql config yaml files

    curl -LO https://raw.githubusercontent.com/nutanix-japan/ocp-hci/main/ocp_wordpress_deploy/mysql_deployment.yaml
    curl -LO https://raw.githubusercontent.com/nutanix-japan/ocp-hci/main/ocp_wordpress_deploy/wordpress_deployment.yaml
  5. We need to grant anyuid security context constraint to the service account

    oc adm policy add-scc-to-user anyuid -z default
    caution

    Take care with granting Security Contenxt Constraints in production environments.

  6. Make sure the nutanix-volume is the default storage class

    oc get sc

    If it is not default, run the following command

    oc patch storageclass nutanix-volumes -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  7. Create kustomization file to specify mysql password]

    cat << EOF > kustomization.yaml
    secretGenerator:
    - name: mysql-pass
    literals:
    - password=XXXXXXX # change to your preferred MYSQL password
    resources:
    - mysql_deployment.yaml
    - wordpress_deployment.yaml
    EOF
  8. Edit the kustomization.yaml to change your MYSQL password to a preferred password

    vi kustomization.yaml
  9. Apply all your configuration files

    oc apply -k ./
  10. Monitor pods until they are running

    oc get po -w
    # Sample output for the command above

    NAME READY STATUS RESTARTS AGE
    pod/wordpress-9c5b954c6-vdp4r 1/1 Running 0 3m11s
    pod/wordpress-mysql-77756785c8-vgtvb 1/1 Running 0 3m11s

Exposing Wordpress to the World

  1. Once both mysql and wordpress pods are running, we can expose the wordpress service to be able to access wordpress\' Web UI.

    oc expose service/wordpress
    Output
    route.route.openshift.io/wordpress exposed
    info

    OCP exposes internal services to the outside world using the concept of routes. This routes concept existed even before the popular kubernetes Ingress object was developed.

    As a result, when you create Ingress object in latest versions of OCP, this will automatically create routes in the background.

    For more information about OCP Routes see here.

  2. Get the OCP route information by running the following command

    oc get route
    Output
    NAME        HOST/PORT                                   PATH   SERVICES    PORT   TERMINATION   WILDCARD
    wordpress wordpress-default.apps.xyz9.ntnxlab.local wordpress 80 None
  3. Add to the hosts file entry on your Mac/PC for accessing Wordpress UI with the following content:

    10.x.x.x       pc.ntnxlab.local
    10.x.x.x console-openshift-console.apps.ocpuser0X.ntnxlab.local
    10.x.x.x oauth-openshift.apps.ocpuser0X.ntnxlab.local
    10.x.x.x k10-route-kasten-io.apps.ocpuser0X.ntnxlab.local
    10.x.x.x wordpress-default.apps.ocpuser0X.ntnxlab.local
  4. Copy the value of HOST/PORT field and prepend a http:// to it as we not using SSL (secure) termination

    Your route should look as follows:

    http://wordpress-default.apps.ocpuserXX.ntnxlab.local
  1. Copy the URL and paste in a browser in your Mac/PC

  2. You should see a configuration page

  3. Select English - United States and click on Continue

  4. Fill in the following fields as shown in the figure below

  5. Note the auto-generated password and copy it somewhere safe. You are also free to use your own password.

  6. You should see a installation confirmation page

    You will get re-directed to login page

  7. Login to the wordpress site using admin and the password you used to install wordpress application

  8. You will see the wordpress administration page

  9. Lets populate some data by creating a new admin user

  10. Click on Users > Add New

  11. Fill in the following fields as shown in the figure below

  12. Click on Add New User

  13. You will be able to see the list of users

You have succesfully set up Wordpress application with mysql backend. In the next section we will backup and restore a deleted wordpress user using Kasten K10 software.