In the last lab to deploy a spring boot application, we used the S2I image directly from a docker registry that is outside OpenShift environment. The Spring Boot image was not in the catalog. In this lab, we will learn how to add the Spring Boot image to the project catalog so that you can deploy the application directly from your screen.
Step 1: Create a new project
Important
|
Please replace userxx with the username assigned to you in the commands below. |
Important
|
Please replace userxx with your username |
-
login to web UI via https://master.ocp.tauil.org
-
Use the same username and password that assigned to you
-
Click
Create Project
-
Enter project name (all lower case) as spring-userxx and other information
-
Click
Create
Step 2: Add the Spring Boot image stream.
-
Open a browser and go to this location https://github.com/VeerMuchandi/openshift-springboot/blob/master/springboot-imagestream.json Please go through the contents of this file.
.... { "kind": "ImageStream", "apiVersion": "v1", "metadata": { "name": "springboot" }, "spec": { "tags": [ { "name": "latest", "annotations": { "description": "Spring Boot S2I Image CentOS based", "iconClass": "icon-jboss", "tags": "builder,springboot,java,maven", "supports": "springboot,java:8,maven", "version": "1.0" }, "from": { "kind": "DockerImage", "name": "docker.io/veermuchandi/spring-mvn-base:latest" } } ] } } ....
Notice, that this json points to the Spring Boot S2I builder Image on
docker hub. Also note the tags used in this imagestream. The tag
builder
will display this in the catalog.
You have two ways to add this to the catalog. 1. Add from command line 2. Add using the web console
To add using Web UI
-
Click
Add to Project
-→ selectImport YAML/JSON
-
Copy the contents from https://raw.githubusercontent.com/VeerMuchandi/openshift-springboot/master/springboot-imagestream.json into the text area
-
Click
Create
-
Click
Builds
-→Images
to validate your spring boot image if it is listed
Step 3 - Create application
Now it is time to create your application. Press on Add to Project
button on the web console. This will take you to Browse Catalog
. You
will start seeing springboot
listed in the catalog. If you have
trouble finding it, type spring in the filter box, and you should find
it.
Now use that S2I image to deploy your sample spring boot application https://github.com/RedHatWorkshops/spring-sample-app on OpenShift using your experience from the previous labs.
Congratulations!! you have learnt to make an image stream available in your project.
If you got a question in mind - Well how can I make this image
available for everyone? Pat yourself on your back.. or ask your
colleague to do it ;). You are thinking right. All you need to do is
tell your openshift cluster administrator.
Answer The cluster administrator will add the image to the openshift
project and everyone will start seeing it.