OpenShift is a Platform as a Service (PaaS) product from Red Hat. It is an on-premise application platform that allows developers to quickly develop, host, and scale applications in a cloud environment.
OpenShift is based on top of Kubernetes and provides a set of tools to help developers with application deployment, management, and scaling.
In this post, we will learn how to deploy a Spring Boot application on OpenShift. We will also learn how to manage and scale the application using OpenShift tools.
Before we start, there are a few things that we need to have in place:
We can deploy our Spring Boot application on OpenShift in two ways: using the OpenShift web console or using the oc command line interface.
Log in to the OpenShift web console and click on the "Create Project" button.
Enter a name for the project and click on the "Create" button.
In the "Add to Project" page, select the "Deploy Image" option and click on the "Select Image" button.
In the "Image Name" field, enter the name of the Spring Boot application image. If the image is not in the OpenShift registry, you can enter the full URL of the image.
In the "Image Configuration" section, specify the name of the application, the port that the application will be running on, and the path to the application's jar file.
Click on the "Deploy" button.
In the "Overview" page, you should see the application running. Click on the application name to go to the application's page.
In the application page, you will see the application's URL. Click on the URL to open the application in a new tab.
Log in to the OpenShift cluster using the oc login command.
Create a new project using the oc new-project command.
Deploy the application using the oc new-app command. Specify the name of the application, the port that the application will be running on, and the path to the application's jar file.
In the "Overview" page, you should see the application running. Click on the application name to go to the application's page.
In the application page, you will see the application's URL. Click on the URL to open the application in a new tab.
Once the application is deployed, we can manage and scale it using the OpenShift web console or the oc command line interface.
In the OpenShift web console, click on the "Applications" menu and select the "Deployments" option.
In the "Deployments" page, you will see a list of all the deployments in the project. Click on the name of the deployment to go to the deployment's page.
In the deployment page, you will see the deployment's details, such as the number of replicas, the deployment strategy, and the rollout history.
To scale the deployment, click on the "Scale" button and enter the desired number of replicas.
To trigger a new rollout, click on the "Rollout" button.
To delete the deployment, click on the "Delete" button.
Log in to the OpenShift cluster using the oc login command.
To list all the deployments in the project, use the oc get deployments command.
To get the details of a deployment, use the oc describe deployment command.
To scale a deployment, use the oc scale deployment command.
To trigger a new rollout, use the oc rollout latest command.
To delete a deployment, use the oc delete deployment command.
In this post, we learned how to deploy a Spring Boot application on OpenShift. We also learned how to manage and scale the application using OpenShift tools.