What command is needed to start restoring the mariadb database when declaring the kubenetes manifest

2/24/2022

Dockerfile

FROM mariadb
COPY all-databases.sql /base/all-databases.sql

Manifest

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mariadb
spec:
  serviceName: mariadb
  selector:
    matchLabels:
      app: mariadb
  template:
    metadata:
      labels:
        app: mariadb
    spec:
      containers:
      - name: mariadb
        image: pawwwel/mariadb01:v5
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: password
        volumeMounts:
        - name: pvclocal
          mountPath: /var/lib/mysql
        command: ["mysql", "-uroot", "-ppassword", "<",  "/base/all-databases.sql"]
  volumeClaimTemplates:
  - metadata:
      name: pvclocal
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: local-storage
      resources:
        requests:
          storage: 1Gi

The presence of such a command leads to an error in the pod.

command: ["mysql", "-uroot", "-ppassword", "<",  "/base/all-databases.sql"]

Without it, an empty database is created. Tell me how to automate the recovery of the database from a backup in kubernetes.

-- Pasha Zem
kubernetes
manifest
mariadb

0 Answers