. . .

OpenShift (Kubernetes, AppAgile)

Content

OpenShift distinguishes between pods, services and routes. Pods are the smallest unit and contain at least one docker container. Services include at least one pod and provide an internal interface. Routes bring service interfaces to the outside world.

ApiOmat uses 3 pods, 3 services and 2 routes.

The OpenShift templates are presented and explained below, as well as the execution of the templates.

OpenShift Templates

MongoDB

openshift_mongo.yml

As our MongoDB image requires a volume, a PersistentVolumeClaim is created first. We can then access this claim in the configuration of the deployment. This configuration file comes next and describes the pod that will be created. The environment variables are also set in this configuration file and some of them are already preconfigured. This defines the service, which also contains the ports and the internal interface. Finally, the parameters are defined, which can be set later using Openshift.

Yambas

openshift_yambas.yml

The deployment config file also contains the configuration of the pod. A service is defined again below. This one has more port paramters, which are only available internally. The route is optional and represents the connection from Yambas to the outside world. This is not necessary as the Dashboard accepts all queries via its own route.

Dashboard

openshift_dashboard.yml

The template is similar to the Yambas template. Again, there is a Deployment Config, a service and a route. The route for this template is very important. It represents the external interface to the ApiOmat.

Transfer and configuration

This section shows how the template is transferred to OpenShift. In addition, a general configuration of the OpenShift is made.

The first step is to install the OpenShift CLI. After that, you should connect to the OpenShift instance.

oc login ${OPENSHIFT_HOST} --username ${OPENSHIFT_USERNAME} --password ${OPENSHIFT_PASSWORD}

You now create a new project or use an existing one.

oc new-project ${OPENSHIFT_PROJECT} --description="${OPENSHIFT_PROJECT}" --display-name="${OPENSHIFT_PROJECT}"

Our Docker Images are located in a private repository on Dockerhub. Therefore, we have to store the credentials.

oc secrets new-dockercfg dockerhub --docker-server="${REGISTRY_ENDPOINT}" --docker-username="${DOCKER_USERNAME}" --docker-password="${DOCKER_PASSWORD}" --docker-email="${DOCKER_MAIL}"
oc secrets add serviceaccount/default secrets/dockerhub --for=pull
oc secrets add serviceaccount/builder secrets/dockerhub

Now send the templates to Openshift.

oc create -f ../templates/openshift_mongo.yaml
oc create -f ../templates/openshift_yambas.yaml
oc create -f ../templates/openshift_dashboard.yaml

Once all templates have been submitted, they can be executed.

oc new-app apiomat-mongo -p MONGODB_VOLUME_CAPACITY=${MONGODB_VOLUME_CAPACITY} -p MONGODB_SERVICE_NAME=${MONGODB_SERVICE_NAME} -p MONGO_IMAGE=${MONGO_IMAGE}
oc new-app apiomat-yambas -p OPENSHIFT_PROJECT=${OPENSHIFT_PROJECT} -p OPENSHIFT_INSTANCE_SUBDOMAIN=${OPENSHIFT_INSTANCE_SUBDOMAIN} \
-p MONGODB_SERVICE_NAME=${MONGODB_SERVICE_NAME} \
-p YAMBAS_SERVICE_NAME=${YAMBAS_SERVICE_NAME} \
-p YAMBAS_LICENSE_KEY="${LICENSE_KEY}" \
-p YAMBAS_IMAGE=${YAMBAS_IMAGE}
oc new-app apiomat-dashboard -p OPENSHIFT_PROJECT=${OPENSHIFT_PROJECT} -p OPENSHIFT_INSTANCE_SUBDOMAIN=${OPENSHIFT_INSTANCE_SUBDOMAIN} \
-p YAMBAS_SERVICE_NAME=${YAMBAS_SERVICE_NAME} \
-p DASHBOARD_SERVICE_NAME=${DASHBOARD_SERVICE_NAME} \
-p DASHBOARD_IMAGE=${DASHBOARD_IMAGE}

With "-p" the parameters in the template are filled in

When the app is created, the deployment config will be executed and the pod is created. The services then include the pods and the routes are released.