Dumping Databases with Kubernetes from Google Cloud
We have the eventyay version 1 currently running on Google Cloud, inside gcloud, I did not find documentation on this from open event, so what must be done is, we must first understand how this system is set up. This is probably easier there is already some overall knowledge of how kubernetes or gcloud actually works, but of course it takes time if there isn’t great knowledge on this topic.
This is the google cloud interface
There are many buttons many things that can be done, so while exploring with them..
There is a console button!
When clicked on this button, this appears
You get a fully integrated terminal emulator with access to a virtual linux environment where your project is, and this is actually super because you get full control of your project and what you can do. It is no longer needed to learn how to navigate through the google cloud GUI and configure everything, because you already have your own shell!
So the first things to care about is know what commands are available that help us for our purpose there are 2 important commands, and those are, “kubectl” and “gcloud” shell commands.
Right now gcloud commands won’t be particularly useful, what we need to know right now is we need to know the pods that are being run, right now. (Pods are little virtual machines, like the containers in Docker)
Awesome, we can find a list of the pods that we have available to view, I assume that web-1299653859-mq59r is the pod where open event is stored
We can confirm this by doing kubectl get services, we then get the ports in which the services are open, we see that web is port 8080 so, that’s probably were open-event is
Through kubectl exec -it web-1299653859-mq59r — /bin/bash we can get inside the container! Great so now that we’re on the open event container, we try to look up how to connect to the database, the environment variables just show the ports and the ip address but the configuration file where the password actually is it doesn’t seem it can be found in plain view.. What to do?
Getting inside postgres container directly
After some time digging around the container, I give up trying to look for the username and password and just get the idea to go to the container directly.
So there you go. A list of the databases running on postgres.
We now use pg_dump to dump the database.
kubectl exec -it postgres — su postgres -c “pg_dump opev”
We pipe the output to a file.
Then we can download it from here, and that’s how to get the dump from the database.