How to deploy to google-cloud using docker compose?

1/15/2020

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

-- Oussama Es-salhi
asp.net-core-3.0
docker
google-cloud-platform
kubernetes

1 Answer

1/15/2020

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.

-- koe
Source: StackOverflow