### OpenShift Local

Here we follow the instructions on https://www.openshift.org[Try Origin,window=_blank].
We use the https://www.openshift.org/vm[All-In-One VM,window=_blank] approach through https://www.openshift.org/minishift[Minishift,window=_blank] on VirtualBox VM.

After having installed Minishift and VirtualBox, we run:

[source,options="nowrap"]
----
$ minishift start --vm-driver=virtualbox --memory 12048 --cpus 3
...
   OpenShift server started.
   The server is accessible via web console at:
       https://192.168.99.100:8443

   You are logged in as:
       User:     developer
       Password: developer

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

==== Client Tools

The client tools are available from the Minishift installation.

----
$ export PATH=$PATH:~/.minishift/cache/oc/v3.6.0
----

==== Docker access

When running OpenShift in a single VM, it is recommended to reuse the Docker daemon which Minishift uses for pure Docker use-cases as well. By using the same docker daemon as Minishift, you can speed up your local experiments.

To be able to work with the docker daemon on your Mac or GNU/Linux host use the docker-env command in your shell:

----
$ eval $(minishift docker-env)
----

You should now be able to use docker on the command line of your host, talking to the docker daemon inside the Minishift VM:

----
$ docker ps
----

#### Running {wildfly-camel}

With every {wildfly-camel} release we also publish the latest https://registry.hub.docker.com/u/wildflyext/wildfly-camel/[wildflyext/wildfly-camel,window=_blank] image.

You can run the standalone container like this

[source,options="nowrap"]
$ docker run --rm -ti -e WILDFLY_MANAGEMENT_USER=admin -e WILDFLY_MANAGEMENT_PASSWORD=admin -p 8080:8080 -p 9990:9990 wildflyext/wildfly-camel

and access the admin console like this: http://192.168.99.100:9990/console[,window=_blank]

image::console-standalone.png[]

#### Create an OpenShift project

Here we run a set of {wildfly-camel} servers on https://www.openshift.org[OpenShift Origin,window=_blank].
The target platform is the local OpenShift instance that we created above.

image::example-rest-design.png[]

The example architecture consists of a set of three high available (HA) servers running REST endpoints. For server replication and failover we use http://kubernetes.io[Kubernetes,window=_blank].
Each server runs in a dedicated https://github.com/GoogleCloudPlatform/kubernetes/blob/v1.0.0/docs/pods.md[Pod,window=_blank]
that we access via https://github.com/GoogleCloudPlatform/kubernetes/blob/v1.0.0/docs/services.md[Services,window=_blank].

A project allows us to create deployments, pods, services, routes, etc. under our own custom 'wildfly-camel' namespace.

 $ oc login -u user -p user
 $ oc new-project wildfly-camel

##### Create a new application

Now, lets create a new application from an existing wildfly-camel based image.

 $ oc new-app wildflyext/example-camel-rest

It's good practice to add liveness and readiness probes to the deployment.

 $ oc set probe dc/example-camel-rest --liveness --initial-delay-seconds 60 -- echo ok

 $ oc set probe dc/example-camel-rest --readiness --initial-delay-seconds 60 --get-url=http://:8080/example-camel-cxf-jaxrs/cxf

Scale up the deployment.

 $ oc scale --replicas=3 dc example-camel-rest

After a while you should see the pod running

image::openshift-standalone-pods.png[]

The pods running the JAX-RS endpoints are however not yet exposed to the world.

##### Exposing the container externally

Now, lets expose the HTTP root context of the running WildFly server.

 $ oc expose service example-camel-rest

You can discover the exposed route host name with.

 $ oc get route example-camel-rest

From a remote client, you should now be able to access the service like this

http://example-camel-rest-wildfly-camel.192.168.99.100.nip.io/rest/greet/hello/Kermit[,window=_blank]

 Hello Kermit from 172.17.0.8

You can clean up all created resources with.

 $ oc delete all -l "app=example-camel-rest"
