来自服务器的错误(RequestEntityTooLarge):请求实体太大:创建configMap时限制为3145728

时间:2020-05-29 10:36:20

标签: mysql kubernetes containers

我使用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

如何增加此限制/或其他任何替代方法来初始化数据库?

1 个答案:

答案 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