Getting Started with native OpenShift

As an alternative to the all-in-one Vagrant image, fabric8 can be installed on top of a native OpenShift V3 Linux installation.

Install OpenShift on Linux

The following steps work on a Linux box. If you are on OS X or Windows then check out how to use the Fabric8 Vagrant box which contains a full feature OpenShift V3 installation.

OpenShift Origin installation

We recommend you check out the OpenShift Origin Installation documentation as the default way to install OpenShift V3 before trying the alternative approach. Be sure that you install the router and registry as described below which has to be done in any case.

Alternative Installation route

Here's an alternative installation approach which could be tried if the guide in the previous section doesn't work for you.

curl -L https://github.com/openshift/origin/releases/download/v1.1.1/openshift-origin-server-v1.1.1-e1d9873-linux-64bit.tar.gz | tar xzv

Now setup $OPENSHIFT_MASTER to point to the IP address or host name of the OpenShift master:

export OPENSHIFT_MASTER=https://$HOST_IP:8443

Note Be sure to use the host ip instead of localhost or 127.0.0.1. This ip will be used from inside a container to connect to the openshift api. Therefor localhost would point to the container itself and it won't be able to connect.

Move the extracted folder to be /var/lib/openshift/ and cd into that directory.

Then start OpenShift:

nohup ./openshift start \
        --cors-allowed-origins='.*' \
        --master=$OPENSHIFT_MASTER \
        --volume-dir=/var/lib/openshift/openshift.local.volumes \
        --etcd-dir=/var/lib/openshift/openshift.local.etcd \
        > /var/lib/openshift/openshift.log &

When running commands on the OpenShift master type the following to avoid you having to add --config=.... arguments:

mkdir -p ~/.kube
ln -s `pwd`/openshift.local.config/master/admin.kubeconfig ~/.kube/config

In order to be able to run oadm command add /var/lib/openshift to your $PATH:

export PATH="$PATH:/var/lib/openshift"

OpenShift configuration

OpenShift needs some extra installation steps in order to be able to run all the Fabric8 apps. Various apps (like Continuous Delivery and MQ requires secrets and service accounts to be setup).

Add roles

The following commands assume you are on the OpenShift master machine :

  • Enable the cluster-admin role to user admin
oadm policy add-cluster-role-to-user cluster-admin admin

Run the gofabric8 installer

gofabric8 is a useful installer for fabric8.

Download a gofabric8 binary, extract it and add it to your $PATH

Now type the following:

gofabric8 deploy -y
gofabric8 secrets -y

Note: If you install not locally you might have to pass the domain name to the -d option so you can access any app later in the browser. E.g.:

gofabric8 deploy -d mydomain.com -y
gofabric8 secrets -y

At any point you can validate your installation via:

gofabric8 validate

You can also eagerly pull docker images for a Fabric8 template via the pull command

gofabric8 pull cd-pipeline

Install or upgrade applications using Helm

You can install or upgrade application using the helm command line tool.

Enable the OpenShift router and registry

The OpenShift Router enables external access to services inside a Kubernetes cluster using HAProxy; e.g. so you can access web apps from your browser for apps running inside Kubernetes.

The OpenShift Registry is used as an internal registry for holding Docker images for Kubernetes.

The detailed instructions for installing these components can be found in the Router installation documentation and the Registry installation documentation. In short it boils down to these two commands:

oadm router --create --service-account=router --credentials=/var/lib/openshift/openshift.local.config/master/openshift-router.kubeconfig
oadm registry --create --credentials=/var/lib/openshift/openshift.local.config/master/openshift-registry.kubeconfig

Next steps

As the next step you can now setup the OpenShift client and install the fabric8 applications

Troubleshooting

If you are having issues logging into the console, ensure you've enabled cors-allowed as shown above in the ./openshift start command.

Another way to do that is to edit the /etc/openshift/master/master-config.yaml file and add an entry like the following:

$vi /etc/openshift/master/master-config.yaml

then add:

corsAllowedOrigins:
  - .*

After making a change run:

$ restart master
systemctl restart openshift-master

Also make sure your user has a login via web console e.g. if using HTPasswdPasswordIdentityProvider in OSEv3

htpasswd -b /etc/openshift-passwd admin admin

If you ran gofabric8 with the wrong domain

You might have the wrong domain setup for the fabric8 ServiceAccount. You should be able to see this via

oc get oauthclient fabric8

If its got the wrong domain for the redirect URIs, just delete it and re-run gofabric8.

oc delete oauthclient fabric8
gofabric8 deploy -y -d my-new-domain.com
gofabric8 secrets -y
oc get oauthclient fabric8

Though there's a pending issue to do this automatically whenever you run gofabric8 deploy