The simplest MariaDB K8s deployment

Here the k8s yaml file with the service (rdbms.yaml), config map and deployment that allows me to run a MariaDB server in my docker-desktop k8s.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app-rdbms
  labels:
    app: my-app
    component: database
data:
  MARIADB_RANDOM_ROOT_PASSWORD: "yes"
  MARIADB_DATABASE: my-app
  MARIADB_USER: my-app
  MARIADB_PASSWORD: admin123

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app-rdbms-config
data:
  my.cnf: |
    [mariadb]
    lower_case_table_names=1

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-rdbms
  labels:
    app: my-app
    component: database
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
      component: database
  template:
    metadata:
      labels:
        app: my-app
        component: database
    spec:
      containers:
        - name: my-app-rdbms
          image: mariadb:10.6
          volumeMounts:
            - mountPath: /etc/mysql/conf.d/
              name: config
              readOnly: true
          ports:
            - containerPort: 3306
          envFrom:
            - configMapRef:
                name: my-app-rdbms
      volumes:
        - name: config
          configMap:
            name: my-app-rdbms-config
---

apiVersion: v1
kind: Service
metadata:
  name: my-app-rdbms
  labels:
    app: my-app
    component: database
spec:
  ports:
    - port: 3306
  selector:
    app: my-app
    component: database

Once this is created deploy it with:

kubectl apply -f rdbms.yaml