我使用configMap
来填充init.sql
脚本,以在Kubernetes窗格中初始化Mysql容器。虽然在大多数情况下都可以使用,但我仍在努力转换一个较大的init.sql
文件,该文件为12.2 MB。
我在deployment.yaml
中使用以下命令来挂载configMap。
volumeMounts:
- name: init-volume
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: init-volume
configMap:
defaultMode: 420
name: init-volume
我用来创建configMap的命令
kubectl create configMap init-volume --from-file=init.sql
我收到错误
Error from server (RequestEntityTooLarge): Request entity too large: limit is 3145728
如何增加此限制/或其他任何替代方法来初始化数据库?
答案 0 :(得分:2)
如何增加此限制/或其他任何替代方法来初始化数据库?
该路径中的.d
命名意味着它将加载其中找到的所有文件,因此解决方案是将init.sql
切成小块,命名为当使用/bin/ls -1
查看时,它们以正确的顺序应用,并将每一个粘贴到configmap中:
i=1
for fn in *.sql; do
kubectl create configmap init-sql-$i --from-file="$fn"
i=$(( i + 1 ))
done
然后将它们装入目录
volumeMounts:
- name: init-file-1
mountPath: /docker-entrypoint-initdb.d/file-1.sql
- name: init-file-2
mountPath: /docker-entrypoint-initdb.d/file-2.sql
# and so forth