About
The intention in the steps and references pointed out in this document is to simplify your self study about OpenShift and microservices.
The steps were designed to run the latest OpenShift version (v1.5.0-alpha.3) available at "2017-03-06 22:45:20 BRT".
About the author: http://j.mp/whoispj
Installing OpenShift locally (on a macOS, using Minishift)
Installing (Xhye)
$ brew update
$ brew install --HEAD xhyve
$ brew install docker-machine-driver-xhyve
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
Installing (Minishift)
$ brew tap caskroom/versions
$ brew cask install minishift-beta
$ minishift version
Configuring
$ minishift config set memory 7168
$ minishift config set cpus 4
$ minishift config set v 999
$ minishift config view
Starting
-
Starting:
$ openshift_version=v1.5.0-alpha.3 $ minishift start --openshift-version=$openshift_version --logtostderr --show-libmachine-logs $ minishift status
Restarting Minishift without parameters
-
This will starts Minishift using the default OpenShift version (v1.4.1)
$ minishift stop $ minishift start
-
To configure Minishift to start OpenShift with version v1.5.0-alpha.3 do:
$ minishift stop $ tree ~/.minishift | less $ minishift config set openshift-version $openshift_version
-
View config and restart Minishift:
$ minishift config view $ minishift start
Testing the oc command
-
Configuring PATH to find
oc
command:
$ tree ~/.minishift | less $ f=~/.bash_profile $ echo "export PATH=~/.minishift/cache/oc/$openshift_version:\$PATH" >> $f $ source $f $ echo $PATH
-
Getting projects:
$ oc get projects
Running a Docker container (hello-world)
$ eval $(minishift docker-env)
$ docker run hello-world
$ docker ps -a
$ docker images
$ docker rmi -f hello-world
$ docker images
Getting ip
$ minishift ip
Deploying a Node.js application
$ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp
$ oc logs -f bc/nodejs-ex &
$ open -a Firefox https://$(minishift ip):8443
-
The comand
oc logs
(above) will take some time …
$ docker images
$ oc get pods
$ oc expose svc/nodejs-ex
$ curl http://nodejs-ex-myproject.$(minishift ip).xip.io
Fast Iterative Java Development on OpenShift/Kubernetes Using Rsync
$ IMAGE=registry.access.redhat.com/jboss-eap-7/eap70-openshift
$ REPO=https://github.com/paulojeronimo/openshift-javaee-helloworld
$ git clone $REPO
$ cd ${REPO##*/}
$ oc new-app $IMAGE~$REPO
$ oc logs -f bc/${REPO##*/} # it will take some time ...
$ oc expose service ${REPO##*/}
$ mvn package -Popenshift
$ oc get pods # To get the name of the running pod you will sync to
$ oc rsync --include="ROOT.war" --exclude="*" target/ <pod_name>:/deployments/ --no-perms=true --watch # Replace <pod_name> with the value from the previous step
Stoping
$ minishift stop
Removing (Minishift)
$ rm -rf ~/.{minishift,kubes}
$ brew cask remove minishift
Removing (Xhyve)
$ brew remove docker-machine-driver-xhyve
$ brew remove xhyve
Building microservices
Converting a monolithic Java EE application to microservices (using Docker Swarm)
Using WildFly Swarm
-
Refs:
How to run Java fat-jars in Docker, Kubernetes and Openshift
-
Cloning and going to REPO dir:
$ REPO=https://github.com/redhat-helloworld-msa/hola $ git clone $REPO && cd $_ $ tree
-
Running locally (via Maven):
$ log=/tmp/hola.log $ mvn wildfly-swarm:run &> $log & $ tail -f $log & $ open http://localhost:8080/api/hola $ kill %1
-
Running in Docker:
$ mvn clean $ mvn package wildfly-swarm:package $ find . -name 'hola*.jar' $ cat Dockerfile $ docker build -t redhatmsa/hola . $ docker images $ docker run redhatmsa/hola &> $log & $ kill %3 $ docker run -e JAVA_OPTIONS=-Xmx1g redhatmsa/hola &> $log & $ !-2
-
Removing "Exited" "redhatmsa/hola" containers:
$ docker ps -a $ !! | awk '$2 == "redhatmsa/hola" { print $1 }' $ docker rm $(!!) $ !-3
-
Deploy on OpenShift (via
oc
):
$ oc new-app redhatmsa/hola -e JAVA_OPTIONS=Xmx1g $ oc env dc/hola JAVA_OPTIONS=-Xmx200m
-
Running in OpenShift (via Maven/Fabric8)
$ mvn clean package docker:build fabric8:json fabric8:apply
Finishing tail
:
$ kill %2
Other aproaches to run WildFly Swarm in OpenShift
More references
-
Refs:
-
Other ways to install OpenShift locally:
-
v JUG hagouts:
-
Book Reading Club: "Building Microservices" by Sam Newman (Part 1), (Part 2), (Part 3)
-
-
Other DFJUG hangouts (pt-br)
-