Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import mysql data to kubernetes pod

Does anyone know how to import the data inside my dump.sql file to a kubernetes pod either;

Directly,same way as you dealing with docker containers:

docker exec -i container_name mysql -uroot --password=secret database < Dump.sql

Or using the data stored in an existing docker container volume and pass it to the pod .

like image 640
montatich Avatar asked Oct 20 '16 23:10

montatich


People also ask

How do I connect to MySQL in Kubernetes?

To connect to a MySQL instance from outside of your Kubernetes cluster, you must configure the Kubernetes service for the instance to be of type LoadBalancer . To access the MySQL server from an external IP address: Create a database user to use for the external connection.

Can you host database in Kubernetes?

Kubernetes-managed Databases: This is a hybrid between running a database all by yourself and using a managed database service provider. This is because you can run Kubernetes on-premises, in the cloud, or use a managed service.

Can you use localhost in Kubernetes?

Kubernetes Networking Containers inside a pod share the same network space, which means that, within the pod, containers can communicate with each other by using the localhost address. A Kubernetes cluster might be split across different nodes. A node is a physical machine where resources run.


1 Answers

Just if other people are searching for this :

kubectl -n namespace exec -i my_sql_pod_name -- mysql -u user -ppassword < my_local_dump.sql
like image 165
Camk_lcbr Avatar answered Sep 18 '22 19:09

Camk_lcbr