Add a data disk to a MariaDB VM over iSCSI to accommodate a new database. Use a dedicated data disk from your SAN with iSCSI.
Outcomes
Create a Persistent Volume to declare an iSCSI target.
Create a Persistent Volume Claim and attach it as a VM disk.
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.
The command also creates the storage-external namespace and starts a virtual machine named mariadb-server in that namespace.
[student@workstation ~]$ lab start storage-external
Instructions
As the admin user, locate and then navigate to the OpenShift web console.
Confirm that the mariadb-server VM is running.
From the command line, log in to your Red Hat OpenShift cluster as the admin user.
[student@workstation ~]$oc login -u admin -p redhat \https://api.ocp4.example.com:6443Login Successful ...output omitted...
Identify the URL for the OpenShift web console.
[student@workstation ~]$ oc whoami --show-console
https://console-openshift-console.apps.ocp4.example.comOpen a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com.
Select and log in as the admin user with redhat as the password.
Navigate to → .
Confirm that the mariadb-server VM is running.
Create the PV resource that declares the iSCSI target to connect.
From the command line on the workstation machine, review the /home/student/DO316/labs/storage-external/pv.yaml resource file that the lab command prepared.
[student@workstation ~]$cat ~/DO316/labs/storage-external/pv.yamlapiVersion: v1 kind: PersistentVolume metadata: name: iscsi-pv spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce volumeMode: Block claimRef:name: mariadb-binlog namespace: storage-external iscsi:
targetPortal: 192.168.51.40:3260 iqn: iqn.2021-10.com.example:server.disk1 lun: 0 initiatorName: iqn.2021-10.com.example:client-server.disk1
Use the oc command to create the resource:
[student@workstation ~]$ oc apply -f ~/DO316/labs/storage-external/pv.yaml
persistentvolume/iscsi-pv createdIf you prefer the OpenShift web console, then navigate to → .
Click and then copy and paste the ~/DO316/labs/storage-external/pv.yaml resource file into the YAML editor.
Click .
Run the oc get pv command to verify your work.
[student@workstation ~]$ oc get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS ...
iscsi-pv 1Gi RWO Retain Available ...
...output omitted...Create the mariadb-binlog PVC and confirm that Kubernetes binds it to the PV.
From the command line, review the /home/student/DO316/labs/storage-external/pvc.yaml resource file that the lab command prepared.
[student@workstation ~]$ cat ~/DO316/labs/storage-external/pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mariadb-binlog
namespace: storage-external
spec:
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
volumeMode: BlockNotice that the name, namespace, storage, accessModes, and volumeMode parameters match the parameters of the PV resource.
Use the oc command to create the resource:
[student@workstation ~]$ oc apply -f ~/DO316/labs/storage-external/pvc.yaml
persistentvolumeclaim/mariadb-binlog createdIf you prefer the OpenShift web console, then navigate to → and select the storage-external project.
Click → and then complete the form by using the following information:
| Field | Value |
|---|---|
| Keep the default provided class | |
mariadb-binlog
| |
Single user (RWO)
| |
| 1 GiB | |
Block
|
Click .
Run the oc get pvc command to confirm that Kubernetes binds your PVC to the iscsi-pv PV.
[student@workstation ~]$oc get pvc -n storage-externalNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE mariadb-binlogBound iscsi-pv1Gi RWO nfs-storage 10m ...output omitted...
The command must report the status as Bound and the volume as iscsi-pv.
If you do not get that status, then delete the PVC and the PV and start again.
Ensure that you create the PVC in the storage-external project with the correct name and parameters.
Use the oc command to delete the resources:
[student@workstation ~]$oc delete pvc mariadb-binlog -n storage-externalpersistentvolumeclaim "mariadb-binlog" deleted [student@workstation ~]$oc delete pv iscsi-pvpersistentvolume "iscsi-pv" deleted
Attach the mariadb-binlog PVC as a disk to the mariadb-server VM by using a virtio interface.
Use the OpenShift web console to stop the VM so that you can use the virtio interface to attach the new disk.
Remember that the only available interface is scsi when the VM is running.
Navigate to → , select the mariadb-server VM, and then click → .
Wait for the machine to stop.
Navigate to the tab and then click . Complete the form by using the following information:
If the field is set to scsi and virtio is not available, then click and start over.
The web interface takes a few seconds to detect that the VM is stopped.
Click to create and attach the disk to the VM.
| Field | Value |
|---|---|
binlogdisk
| |
Use an existing PVC
| |
mariadb-binlog
| |
Disk
| |
VirtIO
|
Click → and then wait for the machine to start.
Log in to the VM console and confirm that a new 1 GiB device is available.
Navigate to the tab and then log in as the root user with redhat as the password.
Run the lsblk command to list the block devices.
Notice the 1 GiB vdc block device.
[root@mariadb-server ~]#lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part / vdb 252:16 0 1M 0 diskvdc252:32 01G0 disk
Log out of the VM console.
[root@mariadb-server ~]# logout