Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Fresh Espresso & Open Source Cloud


I have a passion for all things open source. I live in Ipswich MA and work for Red Hat, on the fabric8 project. Fabric8 is a cloud micro-services platform so you can deploy your applications to an all open source cloud. I kayak on the Atlantic Ocean along the coastal North East from Massachusetts to Maine whenever I can.

Getting started with Fabric8 and OpenShift v3 on OSX

The full fabric8 docs can be found here. Here I took the relavant sections applicable to running on OSX, and I added some notes. OpenShift v3 relies on Docker for its container management. OSX does not support Docker natively. The recommended way is to use vagrant to create a VM with the correct Docker configuration.

1. Prerequisites

Install whatever the newest version is of the following:

  • Docker Client - Just following the instructions for Docker on OSX, but know we will not be using Boot2Docker.

  • Vagrant - Download the OSX version from Vagrant and install.

  • VirtualBox - Download the OSX version from VirtualBox and install.

2. Creating the fabric8 Virtual Machine

To create the VM on Virtual Box we simply use the Vagrantfile in the root of the fabric8 root directory. Either download the zip of use git to get a clone of the repository

git clone https://github.com/fabric8io/fabric8.git
The Vagrantfile is configured to build a VM with 4 VPUs and 8192MB of Ram. It is recommended to not exceed about half of your machine’s resources. In my case that meant having to set this to 2 VPUs and 4096MB of Ram.
Hopefully we can reduce the resource usage, we can bundle it up in a less resource intensive VM!

Now that we have updates the Vagrantfile with resonable settings for your machine we can create it using

vagrant up

vagrant.png

Figure 1. Creating of a VM using Vagrant.

This can take a bit depending on your network speed. Currently it builds Ubuntu-trusty-64 image, but hopefully it will build a Centos-7 image soon. Alternatively there are a few other linux distros at here. I tried the Centos-7 distro but ran into an issue with Docker, so for now I’m staying with the Ubuntu image.

If you don’t have the Vagrant Snapshot plugin installed yet run

vagrant plugin install vagrant-vbox-snapshot

So that you can create a snapshot from the command line

vagrant snapshot take default cleanstart

Now you can revert to the current clean state at any time using

vagrant snapshot go default cleanstart

3. Deploying Fabric8 onto the Virtual Machine

Now that you have a running VM it is time to install OpenShift and Fabric8. To make things easy everything you need is shipped in Docker containers.

mac_docker_host.png

Figure 2. Docker running inside the Fabric8 VM.

Simply log into the Fabric8 VM using

vagrant ssh

and then run the get-fabric8 script to install the minimal installation.

 bash <(curl -sSL https://bit.ly/get-fabric8) -fu -m 172.28.128.4

I’m using -u to update, -f to force a clean refresh of all the containers. This is needed because you actually already have the openshift container installed in the VM and we want to make sure we have the latest. The -m flag allows us to pass in the IP address of the SSO server. Optionally you can add -P password123 to set a password - if you do not, any password will be valid. The output of the script looks something like this:

Cleaning up all existing k8s containers
openshift
56a1f113c23f
e733a45e9c2c
370647a0100b
9ae886fad365
79f5c9f95822
e10401999205
1385573c0c69
da837413817c
4d786fa113ec
5746daf54ecc
b7865d8b5375
249c855b9c69
5baab2eb88af
ed7cbe3ded31
8f9613b2d988

Validating your environment...

Updating all necessary images
Pulling repository openshift/origin
a00a12aa8e24: Download complete
511136ea3c5a: Download complete
b6718650e87e: Download complete
493bab5fff45: Download complete
9dbcac75201e: Download complete
7f6603425b89: Download complete
c217dd459af6: Download complete
b0bfd5cae454: Download complete
3397ad7cd1bf: Download complete
566013b60517: Download complete
6215b28d51bb: Download complete
d2ea575b9c95: Download complete
Status: Image is up to date for openshift/origin:v0.4.3
Pulling repository fabric8/hawtio-kubernetes
2eb1b077c165: Download complete
511136ea3c5a: Download complete
b6718650e87e: Download complete
3d3c8202a574: Download complete
0114405f9ff1: Download complete
cfa5ae1c5323: Download complete
80e9f2334b20: Download complete
06d6147d139d: Download complete
d26b5293026b: Download complete
4f56bb054109: Download complete
25172d8560c5: Download complete
a2df1b022f72: Download complete
6c57ae774233: Download complete
fde24c85ca36: Download complete
Status: Downloaded newer image for fabric8/hawtio-kubernetes:latest
Pulling repository fabric8/app-library
a46290b40e53: Download complete
511136ea3c5a: Download complete
50215b109eda: Download complete
53f380325ee9: Download complete
c833f22e5538: Download complete
09bea8871551: Download complete
a5dc33fb8f1c: Download complete
53785b8e884b: Download complete
4f3361619fcb: Download complete
7f5939cb73c2: Download complete
e7728f6ab005: Download complete
87cb51defb50: Download complete
031a623046a2: Download complete
05e53cd6074a: Download complete
3274fd4092b9: Download complete
9d14c20bac47: Download complete
81e044fcdef5: Download complete
ac24517ff7a4: Download complete
464dc85702b5: Download complete
a4f30ff92248: Download complete
10591d43d892: Download complete
e26a89208727: Download complete
aabb26bbc9a4: Download complete
410212c37a39: Download complete
Status: Image is up to date for fabric8/app-library:2.0.43
Pulling repository openshift/origin-docker-registry
e8ea8243a325: Download complete
511136ea3c5a: Download complete
b6718650e87e: Download complete
493bab5fff45: Download complete
9dbcac75201e: Download complete
2b883fe33571: Download complete
6717803bd751: Download complete
f237ceb6de05: Download complete
48fe0adfcfc8: Download complete
8733545185a5: Download complete
c78f4c43001e: Download complete
ac15356be874: Download complete
Status: Image is up to date for openshift/origin-docker-registry:v0.4.3
Pulling repository openshift/origin-haproxy-router
b90784c8d1eb: Download complete
511136ea3c5a: Download complete
b6718650e87e: Download complete
493bab5fff45: Download complete
9dbcac75201e: Download complete
7f6603425b89: Download complete
24ccc2b386a5: Download complete
e639971f7494: Download complete
e1e0614115b2: Download complete
a508fd6ff7c9: Download complete
ffc24809af88: Download complete
e592f593e680: Download complete
8f8879d7450d: Download complete
085b86fb230d: Download complete
b200c70dcd8f: Download complete
Status: Image is up to date for openshift/origin-haproxy-router:v0.4.3

Validating firewall rules

Waiting for Kubernetes master
services/router
deploymentConfigs/router
services/docker-registry
deploymentConfigs/docker-registry
secrets/openshift-cert-secrets
services/app-library
replicationControllers/app-library-controller
services/app-library-jolokia
services/fabric8-forge
replicationControllers/fabric8-forge-controller
services/fabric8-console-service
replicationControllers/fabric8-console-controller

Waiting for services to fully come up - shouldn't be too long for you to wait

Waiting for Fabric8 console
Configuring OpenShift routes for Fabric8
routes/fabric8-console-route
routes/fabric8-logs-route
routes/fabric8-metrics-console-route
routes/letschat-route
routes/gogs-http-service-route
routes/jbpm-designer-route
routes/orion-route
routes/taiga-route
Configuring OpenShift oauth
oAuthClients/fabric8-console

Waiting for Docker registry

You're all up & running! Here are the available services:

Service              | URL
-------              | ---
Kubernetes master    | https://127.0.0.1:8443
Fabric8 console      | http://172.28.128.4
Docker Registry      | 172.30.17.159:5000

Set these environment variables on your development machine:

export FABRIC8_CONSOLE=http://172.28.128.4
export DOCKER_REGISTRY=172.30.17.159:5000
export KUBERNETES_TRUST_CERT=true
export DOCKER_IP=172.28.128.4
export DOCKER_HOST=tcp://172.28.128.4:2375
export KUBERNETES_MASTER=https://172.28.128.4:8443

Note that when it says: 'Waiting for' something it is looking for a docker container to get started. You should not need to wait longer then about a minute or so per container. Note that if something is wrong, it may sit there forever, and you should stop the script and try to rerun it, and seek help from one of us if that does not help.

The script ends with a final instruction to set 6 environment variables on your development machine. Please go ahead and copy and paste that fragment at the end of your .bash_profile on your development machine, and make sure they are set. Finally you will need to add some routes on your developement machine so you can access the IP addresses of services and pods hosted in your Virtual Machine (e.g. the Fabric8 Console), you’ll need to add a network route for the 172.X.X.X IP range:

sudo route -n delete 172.0.0.0/8
sudo route -n add 172.0.0.0/8 $DOCKER_IP

Going back to the bash shell on the VM we can now get a list of all running containers by running

docker ps

You should see 11 containers:

CONTAINER ID        IMAGE                                                  COMMAND                CREATED              STATUS             PORTS                                      NAMES
85c9a58b44dc        fabric8/app-library:2.0.46                             "/fabric8/run.sh"      About a minute ago   Up About a minute                                              k8s_app-library-container.7f4176cd_app-library-controller-a1zr7_default_8bea7eae-e91c-11e4-b222-080027381590_174b1b5a
c85c2f4f33c8        registry.hub.docker.com/fabric8/fabric8-forge:2.0.46   "/bin/sh -c /opt/jet   About a minute ago   Up About a minute                                              k8s_fabric8-forge-container.3e353d17_fabric8-forge-controller-8hjqp_default_8c7ff6e8-e91c-11e4-b222-080027381590_947d1770
fafa98bb8483        openshift/origin-haproxy-router:v0.4.3                 "/usr/bin/openshift-   About a minute ago   Up About a minute                                              k8s_router.2612a6d6_router-1-4k3ly_default_8f05c5ee-e91c-11e4-b222-080027381590_73a9ad9a
6e69c8e9599e        openshift/origin-docker-registry:v0.4.3                "/openshift-docker-r   About a minute ago   Up About a minute                                              k8s_registry.7a1964a2_docker-registry-1-504e8_default_8f654398-e91c-11e4-b222-080027381590_82b7c335
9f9c3d9976de        openshift/origin-pod:v0.4.3                            "/pod"                 About a minute ago   Up About a minute                                              k8s_POD.9e16f974_docker-registry-1-504e8_default_8f654398-e91c-11e4-b222-080027381590_e6b13c0e
c6c2a2fce85e        openshift/origin-pod:v0.4.3                            "/pod"                 About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   k8s_POD.f301bdd_router-1-4k3ly_default_8f05c5ee-e91c-11e4-b222-080027381590_af615f8e
0d61e479bf45        fabric8/hawtio-kubernetes:latest                       "/kuisp -p 9090 -c /   About a minute ago   Up About a minute                                              k8s_fabric8-console-container.d5a565b4_fabric8-console-controller-9aqxo_default_8d01fe5b-e91c-11e4-b222-080027381590_b07c75f1
2d10edbd91ab        openshift/origin-pod:v0.4.3                            "/pod"                 About a minute ago   Up About a minute                                              k8s_POD.b741f981_fabric8-console-controller-9aqxo_default_8d01fe5b-e91c-11e4-b222-080027381590_5c59972d
5c9806a584a3        openshift/origin-pod:v0.4.3                            "/pod"                 About a minute ago   Up About a minute                                              k8s_POD.fe4b208e_app-library-controller-a1zr7_default_8bea7eae-e91c-11e4-b222-080027381590_0b6118d8
22f2ac9b66e9        openshift/origin-pod:v0.4.3                            "/pod"                 About a minute ago   Up About a minute                                              k8s_POD.7c22fc76_fabric8-forge-controller-8hjqp_default_8c7ff6e8-e91c-11e4-b222-080027381590_85d16287
a1ccd1ffd4df        openshift/origin:v0.4.3                                "/usr/bin/openshift    2 minutes ago        Up 2 minutes                                                   openshift

4. Fabric8 and the OpenShift Commandline (OSC)

To be able to connect to docker as well as your local registry running in the VM we need to add some routing to Docker. On Ubuntu locate the /etc/default/docker file and add the following options:

DOCKER_OPTS="-H unix://var/run/docker.sock -H tcp://0.0.0.0:2375 --insecure-registry 172.0.0.0/8"

now restart Docker using

restart docker
docker start openshift

Now on your development machine you can connect to Docker, and it is convenient to create the following alias (make sure to use the origin version you have installed)

alias osc="docker run --rm -i -e KUBERNETES_MASTER=https://$DOCKER_IP:8443 --entrypoint=osc --net=host openshift/origin:v0.4.3 --insecure-skip-tls-verify"

Now you can talk to Kubernetes and issue commands like

osc get pods
osc get services

If you see a nice list of services you are now ready to open the console.

5. Fabric8 Console

On your developer machine you can now open your brower to http://172.28.128.4

origin.png

Figure 3. The Fabric8/Origin Console.

and login using admin/<anypasswd>, and get a list of all the services that are running by default.

hawtio.png

Figure 4. Overview of all Services.

You can start a new App of Quickstart by navigating to the Library tab. Figure 5 shows a the list of apps. You can select and run any of the apps or quickstarts.

apps.png

6. Deploy a new app to your install

Figure 5. Overview of Fabric8 applications you can run.

In my case I’m building the apiman-manager-api application, and to deploy it, I build it using the docker-build, and then I push it to my local docker registry:

mvn clean install -Pdocker-build
docker push $DOCKER_REGISTRY/fabric8/apiman-manager-api:2.2-SNAPSHOT

Then, to run it, drag and drop the apiman-manager-api-2.2-SNAPSHOT-app.zip onto the library tab of the console, right on top of the apps and quickstarts folders that should turn green when you dragging on onto it. By the way -for me- this works on Safari but not on Firefox. If successful a apiman-manager-api folwer should appear, and when entering into this app folder you can click the green run button.

7. Conclusion

You now have a running Fabric8 installation on OSX and are ready to explore its functionality. Look for more posts on this on this blog.

Cheers!

--Kurt


About the author

Kurt Stam


Discussions

comments powered by Disqus