How to deploy an application using Red Hat OpenShift Service on AWS

Learn how to deploy an application on a cluster using Red Hat OpenShift Service on AWS.

 

One way to deploy the application would be to have the images for the front-end and back-end microservice containers already created (via CI/CD) and stored in an image repository. You can then create Kubernetes deployments (YAML) and use those to deploy the application. 

For information on deploying using Source-to-Image methods, please see the S2I section later in this learning path. 

What will you learn?

  • Deploying an application via Kubernetes on a Red Hat OpenShift Service on AWS (ROSA) cluster

What do you need before starting?

  • Working OpenShift Service on AWS cluster
  • OpenShift CLI
  • GitHub account

Steps for deployment

  1. Retrieve the login command.
    1. If you are not logged in via the CLI, access your cluster via the web console, then click on the dropdown arrow next to your name in the top-right and select Copy Login Command (Figure 3).
Screenshot of the username dropdown menu on OpenShift Cloud Manager with a red outline around the first option, “Copy login command”
Figure 3. The username dropdown menu on OpenShift Cloud Manager with a red outline around the first option, “Copy login command”.
  1. Click Display Token.
  2. Copy the command under where it says Log in with this token.
  3. Go to your terminal, paste that command, and press enter. You will see a similar confirmation message if you successfully logged in.
    $ oc login --token=RYhFlXXXXXXXXXXXX --server=https://api.osd4-demo.abc1.p1.openshiftapps.com:6443
    Logged into "https://api.osd4-demo.abc1.p1.openshiftapps.com:6443" as "0kashi" using the token provided.
    
    You don't have any projects. You can try to create a new project, by running
    
    oc new-project <projectname>
  4. Create a new project called "ostoy" in your cluster by entering the following command:

    $ oc new-project ostoy
    Now using project "ostoy" on server "https://api.osd4-demo.abc1.p1.openshiftapps.com:6443".
    
    You can add applications to this project with the 'new-app' command. For example, try:
    
        oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
    
    to build a new example application in Ruby.
    

    Note: Equivalently you can also create this new project using the web console UI by clicking on Projects under Home on the left menu, then clicking Create Project button on the right.

  5. In your terminal, deploy the microservice using the following command:

    oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml

    You should see the following response:

    $ oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-microservice-deployment.yaml
    
    deployment.apps/ostoy-microservice created
    
    service/ostoy-microservice-svc created
  6. Deploy the front-end service. 
    1. If you open the ostoy-fe-deployment.yaml you will see we are defining:
      1. Persistent Volume Claim
      2. Deployment Object
      3. Service
      4. Route
      5. ConfigMaps
      6. Secrets
  7. In your terminal, deploy the front-end along and create all the preceding objects by entering:

    oc apply -f https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/yaml/ostoy-fe-deployment.yaml
  8. Get the route so that we can access the application via:

    oc get route

    You should see the following response:

    NAME          HOST/PORT                                                 PATH   SERVICES             PORT    TERMINATION   WILDCARD
    
    ostoy-route   ostoy-route-ostoy.apps.my-rosa-cluster.g14t.p1.openshiftapps.com          ostoy-frontend-svc   <all>                 None
  9. Copy the following command, paste it into your browser, and press enter. You should see the OSToy homepage. (Figure 4)
    ostoy-route-ostoy.apps.my-rosa-cluster.g14t.p1.openshiftapps.com
    Note: If the page does not come up, make sure that it is using http and not https.
Screenshot of OSToy page on Red Hat OpenShift console user interface displaying pod and log message options for your application.
Figure 4. The OSToy page on Red Hat OpenShift console user interface displaying pod and log message options for your application.


Success! You now have a deployed application running on your OpenShift Service on AWS cluster. You are now ready to check its health.

Get more support

More OpenShift resources

Previous resource
Red Hat OpenShift concepts explained
Next resource
Checking application health in Red Hat OpenShift Service on AWS clusters