IBM Z and LinuxONE - IBM Z - Group home

OpenShift Service Mesh on IBM System Z/LinuxONE Part II: Build Bookinfo from Source

  

OpenShift Service Mesh on IBM System Z/LinuxONE Part II: Build Bookinfo from Source
This is Part II of a series of articles on how to install and test OpenShift Service Mesh on IBM System Z/LinuxONE. Part I: Installation covered how to install OSSM.

The official documentaton says that it’s not possible to install and run bookinfo on OSSM on Z or P systems. Here in Part II we make it possible by showing you how to build the bookinfo images from source, and altering the bookinfo deployment yaml files to reference those images.

The Bookinfo Example Microservices Suite
First of all, it must be noted that the Bookinfo example is not a supported Red Hat or IBM product. It is simply an open-source example of how a suite of microservices can be deployed in Service Mesh and illustrates how to use many of its useful features.

The bookinfo example images are available pre-built for the amd64 (x86) architecture, but not for s390x (IBM System Z/LinuxONE), so we will illustrate here how to build your own, and push them to the registry and namespace of your choice.

The bookinfo examples are used extensively in the ‘Learn OpenShift’ tutorials. Having your own set of bookinfo images to follow those tutorials on Z can be very instructive and give you a great sense of confidence that all OSSM features work as advertised on Z, and that you know how to use and secure them in your own enterprise production OpenShift Service Mesh environment.

Prerequisites
To build a set of bookinfo test images to validate your installation, and see how Red Hat OSSM works in practice, you will need the packages git and podman-docker installed on an IBM System Z to build the bookinfo test images. podman-docker provides the Red Hat user-space program podman which is aliased as the docker program you might be more familiar with.

(NB: An alternative to building these images natively on IBM System Z/LinuxONE hardware is to use the new cross-build facilities available in podman.)

Building the Bookinfo Test images for s390x architecture
The first thing we need to do is build the mysql base image that the bookinfo services will use:

$ git clone https://github.com/linux-on-ibm-z/dockerfile-examples.git
$ cd dockerfile-examples/MySQL/8.x
$ podman build . -t mysql-s390x:8.0
$ podman images | grep mysql
localhost/mysql-s390x 8.0 eea3731eb142 3 hours ago 555 MB
Now we can git the maistra-test-tool sources, checkout the maistra-2.0-z branch, navigate to the bookinfo source tree and build the bookinfo example test images to validate our OSSM operators:

$ git clone git@github.com:maistra/maistra-test-tool.git
$ cd maistra-test-tool
$ git checkout maistra-2.0-z
$ cd tests/samples/bookinfo/src
$ ./build-services.sh <your-version> <your-registry/your-namespace>
If the version of OSSM you installed in Part I was 2.0.3, for example, you would use 2.0.3 for the <your-version>. If you plan on pushing this to your own repository on quay.io, for example, the <your-registry/namespace> you would use is quay.io/<your-username-on-quay>.

Since I’m pushing these up to quay.io/zaccelerator the prefix tags each example image:

$ podman images examples-bookinfo | \
grep zaccelerator | grep 2.0.3 | \
awk '{printf "%s:%s\n", $1,$2}'
quay.io/zaccelerator/examples-bookinfo-reviews-v1:2.0.3
quay.io/zaccelerator/examples-bookinfo-reviews-v2:2.0.3
quay.io/zaccelerator/examples-bookinfo-reviews-v3:2.0.3
quay.io/zaccelerator/examples-bookinfo-mongodb:2.0.3
quay.io/zaccelerator/examples-bookinfo-mysqldb:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v-unhealthy:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v-delayed:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v-faulty:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v2:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v1:2.0.3
quay.io/zaccelerator/examples-bookinfo-ratings-v-unavailable:2.0.3
quay.io/zaccelerator/examples-bookinfo-details-v2:2.0.3
quay.io/zaccelerator/examples-bookinfo-details-v1:2.0.3
quay.io/zaccelerator/examples-bookinfo-productpage-v-flooding:2.0.3
quay.io/zaccelerator/examples-bookinfo-productpage-v1:2.0.3
and I can use that same image list to push them up to the repository:

for i in `podman images examples-bookinfo |\
grep zaccelerator | grep 2.0.3 |\
awk '{printf "%s:%s\n", $1,$2}'`
do
podman push $i
done
Now let’s take a look at these images in the repository, just to convince ourselves they are really there:

This is what it looks like in quay.io. It will look a little different if you are using a different registry.
And tagged correctly:

This is what it looks like in quay.io. It will look a little different if you are using a different registry.
It’s a good idea to check the repositories you pushed your images to for having the exact tags you intended, because we’re going to be referencing those by this specific version tag in the declarative bookinfo example yaml files in the next section.

Modifying Bookinfo deployment scripts to reference your images
First we need to update the references in the bookinfo sample yamls to refer to your own built-for-Z bookinfo test images.

$ cd maistra-test-tool/tests/samples/bookinfo/platform/kube
$ for i in *.yaml
> do
> sed -i 's,quay.io/maistra,<your-registry>/<your-namespace>,' $i
> sed -i 's/2.0.0-ibm-z/<your-version>/' $i
> done
Where <your-registry>is the name of the registry you pushed your images up to, <your-namespace> is, for example, your username on that registry or perhaps the name of an organization you created there, just for keeping all these example-bookinfo images together there. <your-version> is the version tag you built and pushed them with.

For example, I used quay.io for my registry, and pushed my example-bookinfo images up to the zaccelerator namespace in it, and tagged the images with version 2.0.3. So I ran:

for i in *.yaml
> do
> sed -i 's,quay.io/maistra,quay.io/zaccelerator,' $i
> sed -i 's/2.0.0-ibm-z/2.0.3/' $i
> done
Two ways to check that your image tags referenced in the .yaml files match the tags on your images are grep 'image:' *.yaml


and git diff:

git diff gives you some context as well as assuring you that you did not inadvertently change something else
These will be useful commands to return to if your OpenShift deployments have trouble pulling the images for some reason; but you will have already checked in advance at least that your deployment yamls are set up to pull the bookinfo images that you built and pushed up to the registry of your choice.

Portable property, Pip!
— Charles Dickens, A Tale of Two Cities

Stay tuned for Part III: Much Ado about Bookinfo to see how to deploy these images in your brand-new Red Hat OpenShift Service Mesh installation!

Many thanks to Tony Gargya and Mark Herman for editing advice!