Running a quickstart on Jube

Note currently Jube got broken as fabric8 followed OpenShift 1.0 and Kubernetes 1.0. We will be fixing this soon ;)

We are going to run a quickstart in Jube using the mvn fabric8:run goal. Type the following:

git clone https://github.com/fabric8io/quickstarts.git
cd quickstarts
mvn install
cd quickstarts/java/camel-spring
mvn clean install fabric8:json fabric8:run

If the above fails it could be you have not setup your environment variables so that the maven plugin can communicate with kubernetes REST API.

Once you have run the mvn fabric8:run command you should see it succeed. If you hit any issues check out the FAQ, get in touch or raise an issue

Now you should be able to see any created kubernetes resources in the tabs: Pods, Replication Controllers or Services in the web console. Note that the first thing to be created are the replication controllers which then try to start the pods.

What just happened?

Jube supports the Kubernetes REST API for orchestrating containers which uses JSON to define pods, replication controllers or services.

In the above example we used the maven tooling to generate the Kuberenetes JSON for a quickstart (to define replication controller which will then create a pod for the container and keep it running) and then POST the JSON to Jube via the Kubernetes REST API to create the replication controller.

The mvn fabric8:run goal then generated the kubernetes JSON and POSTed it to the Jube server at the URL defined by the KUBERNETES_MASTER environment variable.

The build will generated a target/classes/kubernetes.json file as part of the build (the fabric8:json goal does that), then the fabric8:run goal will use the Kubernetes REST API to create the necessary pods, replication controllers or services.

Troubleshooting

If maven builds fail it may be you have not setup the environment variables correctly; see above.

Otherwise check out the Jube Troubleshooting Guide for details of how to check the logs and web console.

Using another maven project

Note if you are trying this on your own maven project you may wish to add the jube:build goal to your projects package goal or you can run the jube:build goal via

mvn clean install jube:build fabric8:json fabric8:run

If a pod fails to start

Sometimes you may see a pod not start; it may then try again and create more pods. If you hover over the status icon on the Pods tab you should see a tooltip explanation for the failure (or click on the pod and look at the detail view).

Usually this means that Jube could not find the image zip in a maven repository for the docker container names referenced in your pod JSON. You may want to check that you properly built the associated image zip and it's available in a maven repository at the maven coordinates that the exception reports it used.

Scaling your replication controllers

When you are running some replication controllers you can use the Replication Controllers tab and update the replica count (then hit Save) and in a few moments you should see Jube create or destroy pods so that the current running system matches your required number of replicas.

Another approach is to specify the replica count in your pom.xml via the fabric8.replicas property. For example to run 2 pods (containers) for a project try:

mvn fabric8:run -Dfabric8.replicas=2

Stopping pods

The easiest way to stop pods is to set the number of replicas to 0 on the Replication Controllers tab. Then delete the replication controller if you wish.