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.

 Create The Stones system

Now it's time to create The Stones system. To create this system, we will do the following:

  1. Create a MariaDB database instance.
  2. Build and populate the database.
  3. Create The Stones data access layer.
  4. Create The Stones web application.

Create a MariaDB instance

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

oc new-app --template=mariadb-persistent --param DATABASE_SERVICE_NAME=rsalbums --param MYSQL_USER=rsalbums --param MYSQL_PASSWORD=rsalbums --param MYSQL_DATABASE=rsalbums --param MYSQL_ROOT_PASSWORD=rsalbums --labels=app.kubernetes.io/part-of=thestones,systemname=thestones,tier=database,database=mariadb,thestones=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 ‘rsalbums’ 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:\rsalbums> .\build_and_populate.ps1
True
Copying files to pod…
Creating tables…
Populating tables…
Proof query…

Create The Stones data access layer

Run the following commands to create the data access app:

oc new-app --image=quay.io/rhdevelopers/rsgetalbumslist:latest --name=rsgetalbumslist --labels=app.kubernetes.io/part-of=thestones,systemname=thestones,tier=dataaccess,language=python3,thestones=dataaccess,sandbox=labels

Create The Stones web app

Run the following commands to create the web app:

oc new-app openshift/nginx:1.20-ubi8~https://github.com/redhat-developer-demos/thestones --labels=app.kubernetes.io/part-of=thestones,systemname=thestones,tier=frontend,language=html,thestones=frontend,sandbox=labels

oc expose service/thestones

Congratulations. The Stones system is up and running. Next up? The Countries system.

Previous resource
Create the Customer Viewer system
Next resource
Create the Countries system

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.