5

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"
Saya Kasta
  • 160
  • 1
  • 9
  • its is all explained here https://stackoverflow.com/a/50877213/5193536 – nbk Aug 26 '19 at 11:17
  • 3
    Possible duplicate of [How to initialize mysql container when created on Kubernetes?](https://stackoverflow.com/questions/45681780/how-to-initialize-mysql-container-when-created-on-kubernetes) – David Maze Aug 26 '19 at 11:48

2 Answers2

2

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
  • 305
  • 2
  • 15
0

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

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73
P Ekambaram
  • 15,499
  • 7
  • 34
  • 59