How to pass .sql file in Kubernetes?

8/26/2019

We want to deploy laravel project in k8s. For database we have a data.sql file. When we create docker image for this project, data.sql was easy to pass in volume like:

volumes:

  - ./data.sql:/docker-entrypoint-initdb.d/data.sql

but in k8s i'm not able to make connection between the database and .sql file So do let me know, how to pass .sql file in kubernetes volume?

in .sql file we have a large amount of data, when we use configmap it gives an error

"command terminated with exit code 137"
-- saaya kasta
docker
kubectl
kubernetes
mysql

2 Answers

8/26/2019

Use ConfigMap to store the sql file. You should mount the ConfigMap as a volume in the pod.

-- P Ekambaram
Source: StackOverflow

8/26/2019

Considering the limit of 1MB for configmaps I would initiate a sidecar that pulls this sql file in an empty dir to the main container for the DB. Naturally the git method is deprecated but this should help:

-- Raja
Source: StackOverflow