Skip to content

MySQL

MySQL is an open-source relational database management system (RDBMS) available under the terms of the GNU General Public License.

To deploy MysQL in Kubernetes (or Red Hat OpenShift), we are going to use a Helm chart provided by Bitnami. Bitnami makes it easy to get open source software up and running on any platform, including laptop, Kubernetes and major cloud providers.

Prerequisites

  • Kubernetes cluster accessible with kubectl CLI
  • Install Helm

Supporting Docs

Install MySQL

Get the bitnami Helm repository:

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update bitnami

Install the chart (provide a valid ${NAMESPACE}):

helm install mysql bitnami/mysql -n ${NAMESPACE}

Optional: if running on OpenShift, grant privileged SCC to the mysql service account in ${NAMESPACE} namespace:

oc adm policy add-scc-to-user privileged -z mysql -n ${NAMESPACE}

Access MySQL instance

Retrieve root password from the created mysql by running the following command:

kubectl get secret mysql -o yaml | yq .data.mysql-root-password | base64 -d

Use port forwarding to access MySQL using kubectl port-forward command:

kubectl port-forward mysql-0 3306:3306

On a second terminal, you can then access your MySQL instance by running the following command (type your root password retrieved in above steps):

mysql -h 127.0.0.1 -p