Skip to main content

Create a CakePHP Application in OpenShift on Azure

Hands-On Lab

 

Photo of Jesse Hoch

Jesse Hoch

DevOps Training Architect II

Length

03:30:00

Difficulty

Intermediate

In this lab you will ssh into your master node and create a project named twinkie. You will then create a CakePHP application named twinkies using a pre-built template. After you create the application, you will then need to scale your CakePHP application to three pods.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Creating an Application

Introduction

In this hands-on lab, we will create a CakePHP app named "twinkies" in a project called "twinkie," and scale the app to three pods to handle the testing load.

Log in to the Azure Portal using the credentials provided on the lab instructions page.

Configure Cloud Shell

  1. If prompted with a Welcome to Microsoft Azure get started window, click Maybe layer.

  2. On the left-hand side navigation menu, click All Resources.

  3. Let's set up Cloud Shell by clicking the Cloud Shell button in the top-right corner of the screen:

    "Azure Cloud Shell"

  4. Begin configuring the Cloud Shell, click Bash.

  5. Leave the default for the storage mounted window.

  6. Click Show advanced settings.

  7. Leave the existing subscription, resource group, and storage account.

    Note: If the storage account does not populate, ensure that **US West is selected for the Cloud Shell region field .

  8. Under Storage account, click the radio button for Use existing.

  9. Under File share, choose the radio button Create new and specify okdcloudshell as the new file share.

  10. Click Create Storage.

    Note: We should see a status of Cloud Shell.Succeeded.

Download SSH Keys for the Lab

  1. We will need to pull down the SSH keys to be able connect to the VMs using SSH. First, make the .ssh directory, if it isn't already there, with:

    mkdir .ssh
  2. Then, cd into the directory with:

    cd .ssh
  3. Now, use wget to pull down the SSH keys using these links:

    wget https://raw.githubusercontent.com/linuxacademy/content-openshift-origin-azure/master/ssh/id_rsa
    wget https://raw.githubusercontent.com/linuxacademy/content-openshift-origin-azure/master/ssh/id_rsa.pub
  4. Check the files with:

    ls
  5. Set the correct permissions with:

    chmod 600 id_rsa*

Reset the SSH public key for each VM

  1. Use cd to go back to our home directory.
  2. On the left-hand side navigation menu, click Virtual machines.
  3. Click bastionVM-0.
  4. Scroll down till you see Support + troubleshooting.
  5. Click Reset password.
  6. Make sure Reset SSH public key is selected.
  7. In the username field, type azureuser
  8. Copy the contents of your id_rsa.pub file and past it in the SSH public key field.
  9. Click update and then click it again.
  10. Now repeat these steps for the other VMs.

SSH to the bastion node

  1. Go back to the overview of your bastionVM-0
  2. Click the Connect button.
  3. On the Connect to virtual machine window, click the "Copy to clipboard" icon button for the Login using VM local account section.
  4. Paste it into the Bash environment terminal. It should look similar to this:

    ssh azureuser@104.214.65.210
  5. Type y for yes when asked to continue connecting.

Create the App twinkies

  1. On the left-hand side navigation menu, click Virtual machines.
  2. Click masterVM-0.
  3. Click Connect.
  4. On the Connect to virtual machine window, click the "Copy to clipboard" icon button for the Login using VM local account section.
  5. Paste it into the Bash environment terminal. It should look similar to this:

    ssh azureuser@40.84.153.202
  6. Create a project for the app:

    oc new-project twinkie
  7. Once then new project is created, run the following to make a template:

    oc new-app --search cakephp
  8. Deploy the app:

    oc new-app --template=cakephp-mysql-example --name="twinkies"
  9. Check the build:

    oc get pods

Scale Up the Application

  1. Scale the "twinkies" application up to three pods:

    oc scale --replicas=3 dc/cakephp-mysql-example
  2. Verify the scaling process, again with:

    oc get pods

    Conclusion

    Congratulations — you've completed this hands-on lab!