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](/images/6-deployapp/00019.png?featherlight=false&width=90pc)
- 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](/images/6-deployapp/0001.png?featherlight=false&width=90pc)
- Open the cluster and open Open console to login with the created cluster account.
![ROSA](/images/6-deployapp/0002.png?featherlight=false&width=90pc)
- Select **Log in with htpasswd1
![ROSA](/images/6-deployapp/0003.png?featherlight=false&width=90pc)
- Complete login
![ROSA](/images/6-deployapp/0004.png?featherlight=false&width=90pc)
- Login to cluster on CLI
oc login [CLUSTER_URL] --username [ADMIN_USER] --password [ADMIN_PASSWORD]
![ROSA](/images/6-deployapp/0005.png?featherlight=false&width=90pc)
- Check project list
oc projects
![ROSA](/images/6-deployapp/0006.png?featherlight=false&width=90pc)
- Use git clone Repository
![ROSA](/images/6-deployapp/0007.png?featherlight=false&width=90pc)
- Create new application via CLI
oc new-project rosa-voting-app
![ROSA](/images/6-deployapp/0008.png?featherlight=false&width=90pc)
- 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](/images/6-deployapp/0009.png?featherlight=false&width=90pc)
- 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](/images/6-deployapp/00010.png?featherlight=false&width=90pc)
- Create a temporary Redis server (ephemeral)
oc process redis-ephemeral -n openshift \
-p REDIS_PASSWORD=redis | oc apply -f - -n rosa-voting-app
![ROSA](/images/6-deployapp/00011.png?featherlight=false&width=90pc)
- Deploy services, routes, and image streams available in the example source code
oc apply -f openshift-specifications/ -n rosa-voting-app
![ROSA](/images/6-deployapp/00012.png?featherlight=false&width=90pc)
- Create DeploymentConfig and BuildConfig using Dockerfile
oc apply -f openshift-specifications/with-dockerfile -n rosa-voting-app
![ROSA](/images/6-deployapp/00013.png?featherlight=false&width=90pc)
- 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](/images/6-deployapp/00014.png?featherlight=false&width=90pc)
- Check the status of the created services and try to access the service vote and result
oc status
![ROSA](/images/6-deployapp/00015.png?featherlight=false&width=90pc)
- Submit your choice in the service vote…
![ROSA](/images/6-deployapp/00016.png?featherlight=false&width=90pc)
- Corresponding changes will be viewable in the service result
![ROSA](/images/6-deployapp/00017.png?featherlight=false&width=90pc)
- View project on the console.
![ROSA](/images/6-deployapp/00018.png?featherlight=false&width=90pc)