Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy to google-cloud using docker compose?

I have made an api using asp.net core 3.0, I'm also using docker to run my api locally (this because someone in my team is using linux and had some problems). Now I'm trying to deploy my api in the cloud (GCP) using GKE. I followed google documentation on how to do this using the gcloud cli and kubectl and all that. This all worked except that the server crashes instantly and I see in the log files that the MSSQL server is not being found because there is none in my Dockerfile obviously. Instead we set up our sql server in the docker-compose.yaml file. Is there any way to deploy using the compose file or do I have to do this manually somehow? Mind that i'm still a beginner in the containerization world.

link to a gist of our dockerfile and compose file

Thanks in advance

like image 821
Oussama Es-salhi Avatar asked Dec 14 '22 09:12

Oussama Es-salhi


1 Answers

When you deploy to Kubernetes you'll have to deploy the application and the database (in your case SQL Server).

You can deploy the database by also following the Google docs for kubectl (best would be to write one YAML file containing the Deployments and Services for your app and database).

Alternatively you can re-use your docker-compose.yaml to deploy both to Kubernetes using Kompose. Kompose translates the Docker Compose YAML manifests to Kubernetes and applies them to your cluster. Kompose has some limitations (no full support of Docker Compose).

And here an advice: running databases in containers in the cloud is no easy thing. You'll have to think about persistent storage, backup, high availability, etc. It is a lot easier to use databases provided by the cloud you run on.

like image 73
derkoe Avatar answered Dec 15 '22 22:12

derkoe