Deploying a data driven web app on Kubernetes

11/12/2018

Currently, I am running a data-driven web app all in one Docker Image, with nginx, app server, and Postgres, all bundled together. It's just running on a VM with Docker.

I need to migrate this whole stack, all-in-one thing to Kubernetes and looking for a standard recommended cloud-native way of deployment.

  • I know I will need to run nginx as separate deployment or pod, and the app server as separate pod/deployment.

  • I need to make a choice for the database whether should I use the external database service, running outside Kubernetes, or run my own Postgres on Kubernetes as a stateful set.

  • If I use the external service, then I will need to worry when I upgrade the app and make sure there are no version mismatches, and maybe the external service is less flexible as I have no control over that. What would be the recommended way of using the database, either self-deployed over Kubernetes or using the external one?

  • About nginx, should I just use my own nginx running as separate deployment or I should use the Ingress Controller? What could be the advantage of using ingress as compared to nginx, though nginx as a deployment can be auto-scaled while the ingress controller can't?

The whole point of my question here, at each step I want to avoid any anti-pattern of Deploying the stack to Kubernetes so that I don't have to struggle much later.

-- Ijaz Ahmad Khan
docker
kubernetes
nginx

1 Answer

11/13/2018

If I use the external service, then I will need to worry when I upgrade the app and make sure there are no version mismatches, and maybe the external service is less flexible as I have no control over that. What would be the recommended way of using the database, either self-deployed over Kubernetes or using the external one?

This is strictly an opinion based on the question. If you are not concerned about costs that much, I would use an external database, possibly a cloud provider database like Amazon RDS or Cloud SQL from GCP. IMO, you would be offloading the database management externally and would be easier to debug in the event something went wrong. Another aspect is that you can take advantage of something with a better performance/scalability like Amazon Aurora.

If you are concerned about costs then go with the in Kubernetes solution which will make you utilize the same set of machines for your database and your nginx, and application pods.

About nginx, should I just use my own nginx running as separate deployment or I should use the Ingress Controller? What could be the advantage of using ingress as compared to nginx, though nginx as a deployment can be auto-scaled while the ingress controller can't?

You can actually autoscale an nginx ingress controller, which runs nginx in the same container and managed by a deployment, you'll have to setup autoscale based on some metric like CPU on the nginx ingress controller pods.

-- Rico
Source: StackOverflow