2

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.d
volumes:
- name: init-volume
  configMap:
    defaultMode: 420
    name: init-volume

The command I use to create the configMap

kubectl create configMap init-volume --from-file=init.sql

I get the error

Error from server (RequestEntityTooLarge): Request entity too large: limit is 3145728

How can I increase this limit/or any other alternate to initialise my database?

Vishakha Lall
  • 1,178
  • 12
  • 33
  • How do you access the kubernetes api server? is there a (reverse)proxy involved? – Thomas May 29 '20 at 10:44
  • 1
    https://stackoverflow.com/questions/53012798/kubernetes-configmap-size-limitation – hariK May 29 '20 at 11:25
  • 1
    Does this answer your question? [Kubernetes object size limitations](https://stackoverflow.com/questions/60468110/kubernetes-object-size-limitations) – Mark Watney May 29 '20 at 11:41

1 Answers1

3

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
mdaniel
  • 31,240
  • 5
  • 55
  • 58