I use configMap to feed the init.sql script to initialise my Mysql container in the Kubernetes pod. While that works for most cases I am struggling to convert a larger init.sql file which is 12.2 MB. I use the following in deployment.yaml to mount the configMap.
volumeMounts:
- name: init-volume
mountPath: /docker-entrypoint-initdb.dvolumes:
- name: init-volume
configMap:
defaultMode: 420
name: init-volumeThe command I use to create the configMap
kubectl create configMap init-volume --from-file=init.sqlI get the error
Error from server (RequestEntityTooLarge): Request entity too large: limit is 3145728How can I increase this limit/or any other alternate to initialise my database?
How can I increase this limit/or any other alternate to initialise my database?
The .d nomenclature in that path means it will load all files found therein, so the solution is to chop up the init.sql into smaller chunks, name them so that they apply in the right order when viewed with /bin/ls -1, and stick each one into a configmap:
i=1
for fn in *.sql; do
kubectl create configmap init-sql-$i --from-file="$fn"
i=$(( i + 1 ))
done
then volume mount them into the directory
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