Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 2.86 KB

14-deploy-springboot-app.adoc

File metadata and controls

79 lines (60 loc) · 2.86 KB

Deploy a SpringBoot Application

In this exercise we will deploy a SpringBoot application using a custom source to image builder image.

Important
Please replace userxx with the username assigned to you in the commands below.

Step 1: Using the knowledge you gained from the earlier labs create a new project with name spring-userxx.

Step 2: Create a new application using SpringBoot S2I Builder image. Here we will deploy sample code from a git repository https://github.com/RedHatWorkshops/spring-sample-app. Please take time to understand the code; it is pretty simple.

You may want to clone this into your git repository and deploy that, if you want to make changes and test.

Note
We are using an S2I builder image from docker directly. This S2I builder image was created using this Dockerfile. https://github.com/codecentric/springboot-maven3-centos/blob/master/Dockerfile
$ oc new-app veermuchandi/spring-mvn-base~https://github.com/RedHatWorkshops/spring-sample-app --name=bootapp
--> Found Docker image c3ddd9e (7 days old) from Docker Hub for "veermuchandi/spring-mvn-base"

    Spring Boot Maven 3
    -------------------
    Platform for building and running Spring Boot applications

    Tags: builder, java, java8, maven, maven3, springboot

    * An image stream will be created as "spring-mvn-base:latest" that will track the source image
    * A source build using source code from https://github.com/RedHatWorkshops/spring-sample-app will be created
      * The resulting image will be pushed to image stream "bootapp:latest"
      * Every time "spring-mvn-base:latest" changes a new build will be triggered
    * This image will be deployed in deployment config "bootapp"
    * Port 8080/tcp will be load balanced by service "bootapp"
      * Other containers can access this service through the hostname "bootapp"

--> Creating resources with label app=bootapp ...
    imagestream "spring-mvn-base" created
    imagestream "bootapp" created
    buildconfig "bootapp" created
    deploymentconfig "bootapp" created
    service "bootapp" created
--> Success
    Build scheduled, use 'oc logs -f bc/bootapp' to track its progress.
    Run 'oc status' to view your app.

Expose Service to create a route

$ oc expose service bootapp
route "bootapp" exposed

Check the route

$ oc get route
NAME      HOST/PORT                                      PATH      SERVICES   PORT       TERMINATION
bootapp   bootapp-spring-userxx.{{APPS_ADDRESS}}             bootapp    8080-tcp

Wait for your application to be built and deployed. Using the knowlege you gained from the previous labs, check your build logs by running oc logs -f <build pod name>

Step 3

Test your application by using the hostname assigned in the route.

Congratulations!! You are now running a SpringBoot application on OpenShift.