Git Product home page Git Product logo

springbin's Introduction

Deploy a Spring Boot binary (jar) to OpenShift

Using the odo client

Grab odo from https://mirror.openshift.com/pub/openshift-v4/clients/odo/

odo project create myproj
odo create java backend --binary targets/ola.jar
odo push
odo url create --port 8080
odo log

Wait for the microservice to become ready.

INFO 135 --- [           main] c.r.developers.msa.ola.OlaApplication    : Started OlaApplication in 49.901 seconds (JVM running for 55.196)

Cleanup from odo

Delete from server.

odo delete backend

Delete from server and local.

odo delete --app backend --all

Delete the project.

odo delete project myproj

Using the oc client

This procedure uses OpenShift's source to image workflow and the openjdk18 builder image to push a local jar file into the OpenShift build configuration.

If you don't have the openjdk18 builder image, create the image-stream object I obtained from Thomas's blog post and import it into your project.

oc create -f openjdk-s2i-imagestream.json

If you need an example Spring Boot jar, clone, compile and package the following example.

git clone https://github.com/redhat-helloworld-msa/ola.git
cd ola
mvn clean package

Now create a build config with a binary build strategy and push the jar. If you want to push your own jar, make sure it is located in the target directory.

oc create -f openjdk-s2i-imagestream.json
oc new-build --binary=true --name=ola --image-stream=redhat-openjdk18-openshift

Next, create a deployment config, a service and a route.

oc start-build ola --from-dir=target --follow
oc new-app ola -l app=ola,hystrix.enabled=true
oc expose service ola

Wait for the pod to become ready then test it.

host=`oc get route ola --template={{.spec.host}}`
curl $host/api/health

Optionally, add a readiness probe.

oc env dc/ola AB_ENABLED=jolokia; oc patch dc/ola -p '{"spec":{"template":{"spec":{"containers":[{"name":"ola","ports":[{"containerPort": 8778,"name":"jolokia"}]}]}}}}'
oc set probe dc/ola --readiness --get-url=http://:8080/api/health

Reference

springbin's People

Contributors

bkoz avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.