Saturday, July 23, 2022
How to connect phpMyAdmin to MariaDB under Red Hat OpenShift
It is a container platform built for an open hybrid cloud.
Get your trial account from https://www.redhat.com/en/technologies/cloud-computing/openshift if you haven't do so.
Like me, I'm getting myself a developer sandbox with a trial length of 30 days just to understand how to play around with it.
First step is to add a database:
Pick MariaDB (Ephemeral), it is a database without persistent storage & data stored will be lost upon pod destruction. Good enough for testing:
For phpMyAdmin we will be using docker image from https://hub.docker.com/r/startxfr/openshift-phpmyadmin/
Copy the docker image name below:
startxfr/openshift-phpmyadmin
Now, add "Container Images" for phpMyAdmin
sh-4.4$ env|grep MARIAMARIADB_SERVICE_HOST=172.30.1.41MARIADB_PORT=tcp://172.30.1.41:3306MARIADB_PORT_3306_TCP_ADDR=172.30.1.41MARIADB_PORT_3306_TCP_PROTO=tcpMARIADB_SERVICE_PORT_MARIADB=3306MARIADB_PORT_3306_TCP=tcp://172.30.1.41:3306MARIADB_SERVICE_PORT=3306MARIADB_PORT_3306_TCP_PORT=3306sh-4.4$
Verify the ConfigMap. This is where the database username & password being shared to the ConfigMap. From below we can see that they are being shared to mariadb, database-user & database-password.
Look into the "config.inc.php" file on how it is getting the database user & password from the environment variables.
Scroll down until to get see below section
if(getenv('MARIADB_SERVICE_USER') != '') {$i++;$cfg['Servers'][$i]['extension'] = 'mysqli';$cfg['Servers'][$i]['auth_type'] = 'config';$cfg['Servers'][$i]['host'] = getenv('MARIADB_SERVICE_HOST');$cfg['Servers'][$i]['port'] = getenv('MARIADB_SERVICE_PORT');$cfg['Servers'][$i]['user'] = getenv('MARIADB_SERVICE_USER');$cfg['Servers'][$i]['password'] = getenv('MARIADB_SERVICE_PWD');$cfg['Servers'][$i]['compress'] = false;$cfg['Servers'][$i]['AllowNoPassword'] = false;}
So we now know that phpMyAdmin is getting database username & password from MARIADB_SERVICE_USER for database username & MARIADB_SERVICE_PWD as database password.
Add both MARIADB_SERVICE_USER and MARIADB_SERVICE_PWD to phpMyAdmin environment variables by linking them to ConfigMap.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment