Reputation: 2097
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 /docker-entrypoint-initdb.d
, but when I try to see the contents of that directory it appears empty. My deployment file is the following:
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
Upvotes: 0
Views: 300
Reputation: 2097
Nevermind, I solved it by creating a configMap and mounting it as a volume.
I'm leaving this here for future reference
Upvotes: 1