我在Kubernetes上有一个MySQL数据库。我想做的是运行一些SQL脚本来建立数据库。我试图在/docker-entrypoint-initdb.d
上安装主机目录,但是当我尝试查看该目录的内容时,它似乎为空。我的部署文件如下:
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
答案 0 :(得分:1)
没关系,我通过创建configMap并将其安装为卷来解决它。
我将其留在此处以供将来参考