Create a Red Hat Enterprise Linux template based on a predefined image that contains a MariaDB server instance. You then use the custom template to create a VM that contains a database with preconfigured data.
Outcomes
Create a template with the mariadb-server image by defining the attributes.
Create a VM from the customized template and access it to confirm that the MariaDB service is up and running.
Delete the VM and the template.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that the cluster API is reachable.
It also creates the template-create namespace and ensures that all resources are available for this exercise.
[student@workstation ~]$ lab start template-create
Instructions
As the admin user, clone a template to the template-create namespace and name it template-create.
Configure the eviction strategy as Live Migration.
Configure the template to use a mariadb-server image that is hosted on a website.
Configure the rootdisk to use the ocs-external-storagecluster-ceph-rbd storage class.
The template must use the Server workload type.
Configure the cloud-init service to create the developer user with developer as the password.
Open a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com.
Click and log in as the admin user with redhatocp as the password.
Navigate to → .
Select the All Projects project from the list and search for rhel8-server-small.
Click the vertical ellipsis icon and select .
In the form, change the to template-create.
Change the to .
Leave the other form fields with their default values.
Click .
Navigate to → .
Select the template-create project from the list and select the template-create template.
Select the tab and click the pencil icon under .
Confirm that the checkbox for Live Migration is selected, and then click .
Select the tab and confirm that the default interface is on the Pod Networking network and that it uses the Masquerade type.
Select the tab and detach the rootdisk disk.
Click the vertical ellipsis icon next to the rootdisk line, and then click .
Click to confirm.
Create a new rootdisk.
Click .
Complete the form by using the following information and then click .
| Parameters | Value |
|---|---|
| enabled | |
rootdisk
| |
URL (creates PVC)
| |
| http://utility.lab.example.com:8080/openshift4/images/mariadb-server.qcow2 | |
| 30 GiB | |
virtio
| |
ocs-external-storagecluster-ceph-rbd
|
Review the storage settings to confirm that the rootdisk volume storage size is 30 GiB and that it uses the ocs-external-storagecluster-ceph-rbd storage class.
Use the YAML editor to set the name of the rootdisk data volume to the name of the VM that the template creates.
Navigate to the tab and locate the spec.dataVolumeTemplates.metadata.name and spec.template.volumes.datavolume.name objects.
Update the object values to use the ${NAME} template variable, and then click .
apiVersion: template.openshift.io/v1 kind: Template ...output omitted... spec: dataVolumeTemplates: - metadata: name:'${NAME}'...output omitted... template: volumes: - name: rootdisk dataVolume: name:'${NAME}'...output omitted...
Configure Cloud-init to create the developer user with developer as the password.
Select the tab and click next to Cloud-init.
In the and fields, enter developer and then click .
Create a VM from the template-create template.
Navigate to → . On the right panel of filter options, under , select the project and select the newly created template .
Change the to template-create-vm and click .
Wait for the template-create-vm VM to provision and display the Running status.
Access the template-create-vm VM.
Navigate to → .
Click the template-create-vm link to access the tab for the VM.
Navigate to the tab. Wait for the console to display the login prompt.
Use the console to log in as the developer user with developer as the password.
template-create-vm login:developerPassword:developer[developer@template-create-vm ~]$
Confirm that the preconfigured database, sakila, is available.
Use the mysql command to log in as the devuser with developer as the password.
[developer@template-create-vm ~]$mysql sakila -u devuser -pEnter password:developerWelcome to the MariaDB monitor. Command end with ; or \g. ...output omitted... MariaDB [sakila]>
Exit the sakila database and the template-create-vm VM.
MariaDB [sakila]>EXIT;Bye [developer@template-create-vm ~]$exit
Delete the template-create-vm VM and the template-create template.
Navigate to → .
Click the vertical ellipsis icon to the right of the template-create-vm VM and select .
Click in the confirmation window.
Navigate to → .
Click the vertical ellipsis icon to the right of the template-create template row, and click .
Click in the confirmation window.