Unified Push Server (UPS) on OpenShift

Unified Push Server (UPS) on OpenShift

Prerequisites

You should have a locally installed version of OpenShift, or access to an OpenShift cluster. If you don’t have either, you can set up your own OpenShift local cluster by reading this document.

Bringing up your cluster

Bring up your cluster with:
oc cluster up --public-hostname=127.0.0.1 --host-data-dir=$HOME/os/data-dir --host-config-dir=$HOME/os/config-dir

oc-cluster-up

Log into your cluster

Log into your cluster via oc login

oc-login

Deploy MySQL containers

We will be using the UPS docker image from Docker Hub. This image requires that we have 2 MySQL instances named ‘unifiedpush’ and ‘keycloak’. Create these by:

deploy-mysql-keycloak

deploy-mysql-unified-push

Confirm that both MySQL instances have come online by checking the OpenShift console, or via the terminal with oc status.

pod-keycloak
pod-unifiedpush

Deploy AeroGear UPS

With both required MySQL instances installed and running, UPS can now be deployed by running the following command in your terminal:

oc new-app aerogear/unifiedpush-wildfly \ 
UNIFIEDPUSH_PORT_3306_TCP_ADDR=unifiedpush \ 
UNIFIEDPUSH_PORT_3306_TCP_PORT=3306 \ 
UNIFIEDPUSH_ENV_MYSQL_DATABASE=unifiedpush \ 
KEYCLOAK_PORT_3306_TCP_ADDR=keycloak \ 
KEYCLOAK_PORT_3306_TCP_PORT=3306 \ 
KEYCLOAK_ENV_MYSQL_DATABASE=keycloak \ 
UNIFIEDPUSH_ENV_MYSQL_USER=unifiedpush \ 
UNIFIEDPUSH_ENV_MYSQL_PASSWORD=unifiedpush \ 
KEYCLOAK_ENV_MYSQL_USER=unifiedpush \ 
KEYCLOAK_ENV_MYSQL_PASSWORD=unifiedpush \ 
--name=unifiedpush-wildfly  

deploy-unifiedpush-wildfly
pod-unifiedpush-wildfly

This will deploy UPS and pass in the necessary environmental variables for UPS to pick up the MySQL instances. You can see these environmental variables in the OpenShift console:

deploy-unifiedpush-wildfly-env-vars

Exposing routes to UPS deployment

With UPS deployed, the final step is to expose route(s) so we can access our UPS instance through a web browser. The following creates 2 routes; one to access UPS through localhost on our web browser, and one through which the android emulator can access UPS:

You should see confirmation that the routes have been created:

terminal-route-1
terminal-route-2

The OpenShift console will confirm that this also:

pod-unifiedpush-wildfly-routes-2
pod-unifiedpush-wildfly-routes-1

** if you require any other routes to be exposed to UPS for your apps, you can simply add them in the above manner.

Fixing Keycloak Linking

UPS uses an embedded Keycloak server to handle its authentication. Right now there is an issue when the UPS pod starts up it can’t route to Keycloak using the public route. To work around this, do the following after the pod has loaded fully

applications-pods

pod-unifiedpush-wildfly-terminal

Configuring UPS

UPS can now be configured via the browser and the route you have created:

browser-ups

ups-front-screen

** This tutorial does not cover how to configure UPS to send push notifications to your mobile app. For guidance on how to do so, the AeroGear HelloPush tutorial may be found here which covers cover how to configure push notifications to an app with UPS.