Deploy application on OpenShift cluster

Deploy application on OpenShift cluster

Deploying the application via OC CLI

In this section, we will try to deploy a multier application to OpenShift Cluster. The application architecture is as follows

ROSA

  1. Create a cluster admin account
rosa create admin -c rosa-lab

Note: Please save this account information to use login to OpenShift cluster through Red Hat HybridCloud Console

ROSA

  1. Open the cluster and open Open console to login with the created cluster account.

ROSA

  1. Select **Log in with htpasswd1

ROSA

  1. Complete login

ROSA

  1. Login to cluster on CLI
oc login [CLUSTER_URL] --username [ADMIN_USER] --password [ADMIN_PASSWORD]

ROSA

  1. Check project list
oc projects

ROSA

  1. Use git clone Repository

ROSA

  1. Create new application via CLI
oc new-project rosa-voting-app

ROSA

  1. Allow the default service account of the rosa-voting-app project to run the container without root privileges
  • In this example, we will run with the user with uid=1001
oc adm policy add-scc-to-user nonroot -z default -n rosa-voting-app

ROSA

  1. Create a temporary PostgreSQL database (ephemeral)
oc process postgresql-ephemeral -n openshift \
    -p DATABASE_SERVICE_NAME=db \
    -p POSTGRESQL_USER=postgres \
    -p POSTGRESQL_PASSWORD=postgres \
    -p POSTGRESQL_DATABASE=postgres | oc apply -f - -n rosa-voting-app

ROSA

  1. Create a temporary Redis server (ephemeral)
oc process redis-ephemeral -n openshift \
    -p REDIS_PASSWORD=redis | oc apply -f - -n rosa-voting-app

ROSA

  1. Deploy services, routes, and image streams available in the example source code
oc apply -f openshift-specifications/ -n rosa-voting-app

ROSA

  1. Create DeploymentConfig and BuildConfig using Dockerfile
oc apply -f openshift-specifications/with-dockerfile -n rosa-voting-app

ROSA

  1. Run the following commands to build the image. DeploymentConfig will be triggered when the build is complete.
oc start-build result
oc start-build vote
oc start-build worker

ROSA

  1. Check the status of the created services and try to access the service vote and result
oc status

ROSA

  1. Submit your choice in the service vote…

ROSA

  1. Corresponding changes will be viewable in the service result

ROSA

  1. View project on the console.

ROSA