apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mariadb
spec:
  selector:
    matchLabels:
      app: mariadb
  serviceName: mariadb
  replicas: 1
  template:
    metadata:
      labels:
        app: mariadb
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: mariadb
          image: docker.io/mariadb:10.11.2
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: xJ2YdqrbPXla
            - name: MYSQL_DATABASE
              value: traccar
            - name: MYSQL_USER
              value: traccar
            - name: MYSQL_PASSWORD
              value: J0ICsL5JTPLt
          ports:
            - containerPort: 3306
              name: mariadb
          volumeMounts:
            - name: mariadb
              mountPath: /var/lib/mysql
  volumeClaimTemplates:
    - metadata:
        name: mariadb
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
  name: mariadb
  labels:
    app: mariadb
spec:
  ports:
    - port: 3306
      name: mariadb
  clusterIP: None
  selector:
    app: mariadb
