<p>I have a MySQL database on Kubernetes. What I want to do is to run some SQL scripts to set up the database. I have tried to mount a host drectory on <code>/docker-entrypoint-initdb.d</code>, but when I try to see the contents of that directory it appears empty. My deployment file is the following:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: db
  labels:
    app: db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      containers:
        - name: mysql
          image: mysql:5.7.31
          ports:
            - containerPort: 3306
          volumeMounts:
            - mountPath: /docker-entrypoint-initdb.d/
              name: initdb
            - mountPath: /var/lib/mysql
              subPath: mysql
              name: db-data
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: ROOT_PASSWORD
      volumes:
        - name: db-data
          persistentVolumeClaim:
            claimName: db-data-disk-claim
        - name: initdb
          hostPath:
            path: /home/fer/web/db/sqlscripts
            type: Directory
</code></pre>

fergaral
<p>Nevermind, I solved it by creating a configMap and mounting it as a volume.</p>
<p>I'm leaving this here for future reference</p>
