Skip to content

Latest commit

 

History

History

01-openshift-3-origin-console-local

openshift 3 docker spring boot app local (dev) deployment

1) build app, run locally

env variable
export SPRING_PROFILES_ACTIVE=ololo
bash build/libs/app-0.0.1.jar
run args
export RUN_ARGS="--spring.profiles.active=trololo"
bash build/libs/app-0.0.1.jar
script parameter
bash build/libs/app-0.0.1.jar --spring.profiles.active=trololo

2) build image and publish it to docker registry

push
bash gradlew clean build
docker build --rm -t daggerok/openshift-spring-boot-app .
docker tag daggerok/openshift-spring-boot-app daggerok/openshift-spring-boot-app:latest
docker tag daggerok/openshift-spring-boot-app:latest daggerok/openshift-spring-boot-app:v1
docker push daggerok/openshift-spring-boot-app:v1
docker push daggerok/openshift-spring-boot-app:latest
build and run
bash gradlew clean build

docker build -t daggerok/openshift-spring-boot-app .

docker run -p 8080:8080 daggerok/openshift-spring-boot-app

docker rm -f -v $(docker ps -a|grep -v CONTAINER|awk '{print $1}')

3) bootstrap cluster

bootstrap local development cluster
oc cluster up
...
Starting OpenShift using openshift/origin:v3.6.0 ...
OpenShift server started.

The server is accessible via web console at:
    https://127.0.0.1:8443

You are logged in as:
    User:     developer
    Password: <any value>

To login as administrator:
    oc login -u system:admin

4) deploy app on openshift 3

open console
open https://127.0.0.1:8443

create app from docker image

when pod will be ready create a route. for me it’s:

5) verify

http http://openshift-spring-boot-ap-app.127.0.0.1.nip.io/message/message
HTTP/1.1 200
Cache-control: private
Content-Type: application/json;charset=UTF-8
Date: Fri, 15 Sep 2017 01:28:42 GMT
Set-Cookie: a24c4650d0385710537546a6e4c39846=4e67cf5991f232f6962f93f136f02575; path=/; HttpOnly
Transfer-Encoding: chunked

{
    "message": "ololo"
}

6) stop cluster

oc cluster down

7) problem solving

problem 1.1: if you have error like

-- Checking Docker daemon configuration ... FAIL
   Error: did not detect an --insecure-registry argument on the Docker daemon
   Solution:

     Ensure that the Docker daemon is running with the following argument:
     	--insecure-registry 172.30.0.0/16

     You can run this command with --create-machine to create a machine with the
     right argument.

solution 1.1: then you can fix like so:

go to Docker → Preferences…​ → Daemon → insecure registries → add: 172.30.0.0/16 → Apply & Restart

now you can use command:

oc cluster up

solution 1.2: or use command:

oc cluster up --skip-registry-check=true

problem 2: if you have and error such

-- Starting OpenShift container ... FAIL
   Error: exec: "socat": executable file not found in $PATH

solution 2: then install openshift client using brew (if you on mac):

brew install openshift-cli
...

read some:

enjoy :)