Using Red Hat OpenShift labels

When the microservices architecture began replacing monolithic architecture, it brought more complexity and, therefore, required more effort to manage. Namespaces and labels are tools that simplify the management process. This activity, created by Don Schenck, demonstrates the power of labels.

Now let's create the countries system.

Create the Countries system

Create the Countries system using the following steps:

  1. Create a MariaDB database instance.
  2. Build and populate the database.
  3. Create the Countries data access layer.
  4. Create Country Viewer web app.

Create a MariaDB database instance

Run the following command to create an ephemeral instance of a MariaDB database:

oc new-app --template=mariadb-persistent --param DATABASE_SERVICE_NAME=countries --param MYSQL_USER=countries --param MYSQL_PASSWORD=countries --param MYSQL_DATABASE=countries --param MYSQL_ROOT_PASSWORD=countries --labels=app.kubernetes.io/part-of=countries,systemname=countries,tier=database,database=mariadb,countries=database,sandbox=labels,dbtype=persistent

Because this instance is persistent, all tables and data will not be destroyed when the pod is scaled to zero, the opposite of an ephemeral instance.

Build and populate the database

Move into your countriesdb directory and run the following command:

If using a Bash shell:

./build_and_populate.sh

If using Powershell:

./build_and_populate.ps1

You should expect output much like this:

C:\rsalbumsdb> .\build_and_populate.ps1
True
Copying files to pod
Creating tables
Populating tables
Proof query

Create the Countries data access layer

oc new-app https://github.com/redhat-developer-demos/getcountrieslist --labels=app.kubernetes.io/part-of=countries,systemname=countries,tier=dataaccess,language=go,countries=dataaccess,sandbox=labels

Create the Countries Viewer web application

oc new-app --image=quay.io/rhdevelopers/countryui:latest --name=countryui --labels=app.kubernetes.io/part-of=countries,systemname=countries,tier=frontend,language=rails,countries=frontend,sandbox=labels

oc expose service/countryui

Congratulations. You have created the Countries system. It's time to move to the last lesson in this path: 4 Systems and 13 parts

Previous resource
Create The Stones system
Next resource
4 systems with 13 parts

Info alert: Using Red Hat OpenShift labels

When the microservices architecture began replacing monolithic architecture, it brought more complexity and, therefore, required more effort to manage. Namespaces and labels are tools that simplify the management process. 

This activity, created by Don Schenck, demonstrates the power of labels.