Skip to content

MySQL Deployment

Architecture Overview

Make sure you have deployed a Kafka cluster first.

After the Kafka cluster is up and running, you can deploy MySQL by running the following commands:

cd ~/Projects/retail-lakehouse/mysql
bash /install.sh
Result
service/mysql created
deployment.apps/mysql created

The install.sh script in the mysql directory is as follows:

install.sh
#!/bin/bash

set -e

cd ~/Projects/retail-lakehouse/mysql
kubectl apply -f mysql.yaml -n kafka-cdc
sleep 5
kubectl wait --for=condition=Ready pod -l app=mysql -n kafka-cdc --timeout=1200s

You can check the mysql.yaml file in the mysql directory:

mysql.yaml
apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: kafka-cdc
spec:
  ports:
  - port: 3306
  selector:
    app: mysql
  clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - image: quay.io/debezium/example-mysql:3.2
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: debezium
        - name: MYSQL_USER
          value: mysqluser
        - name: MYSQL_PASSWORD
          value: mysqlpw
        ports:
        - containerPort: 3306
          name: mysql

To verify that MySQL is running, you can use the following command:

kubectl get all -n kafka-cdc
Result
NAME                                                    READY   STATUS    RESTARTS   AGE
pod/kafka-cluster-dual-role-0                           1/1     Running   0          15m
pod/kafka-cluster-dual-role-1                           1/1     Running   0          15m
pod/kafka-cluster-dual-role-2                           1/1     Running   0          15m
pod/kafka-cluster-entity-operator-5b998f6cbf-c8hdf      2/2     Running   0          15m
pod/mysql-6b84fd947d-9g9lt                              1/1     Running   0          10m

NAME                                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                                        AGE
service/kafka-cluster-kafka-bootstrap      ClusterIP   10.105.50.103   <none>        9091/TCP,9092/TCP,9093/TCP                     15m
service/kafka-cluster-kafka-brokers        ClusterIP   None            <none>        9090/TCP,9091/TCP,8443/TCP,9092/TCP,9093/TCP   15m
service/mysql                              ClusterIP   None            <none>        3306/TCP                                       10m

NAME                                               READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/kafka-cluster-entity-operator      1/1     1            1           15m
deployment.apps/mysql                              1/1     1            1           10m

NAME                                                          DESIRED   CURRENT   READY   AGE
replicaset.apps/kafka-cluster-entity-operator-5b998f6cbf      1         1         1       15m
replicaset.apps/mysql-6b84fd947d                              1         1         1       10m

Perfect! You have successfully deployed MySQL. Next, you can proceed to Deploy the Debezium MySQL Source Connector.