LEMP Kubernetes

1/30/2017

Let's say we don't want to over complicate the example and we've decided to use external storage for database. Also, code, config files etc are part of docker images.

My question is, based on experience, good practices and ease of use. What's the strategy you guys are using for deploying nginx, php-fpm stack?

Three options come to my mind:

  • Create a Dockerfile in which you have the two processes and then just create a pod with the container running on it. This would break the principle of one process per container.

  • Create one pod with two containers which contains one process each. I found some opinions online that says things like:

The main motivation for the pod concept is supporting co-located, co-managed helper containers next to the application container. These include things like: logging or monitoring agents, backup tooling, data change watchers, event publishers, proxies, etc.

  • Create different pods, one with a container running nginx and one with a container running php-fpm. That can over complicate things, may be?

It would be nice if you guys can say something on this based on you experience and discuss which makes more sense for different reasons.

Thank you all of you!!

-- bormansquirrel
docker
kubernetes
nginx
php

1 Answer

1/30/2017

The multi-container pod which has the full service in it, works easiest, and is most inline with the design principles, but has as downside that scaling is for the full pod. This can be troublesome in cases where nginx for example uses very little CPU compared to the php process:

  • The nginx still requires a significant amount of CPU to give a quick response, but does use very little of that assigned CPU over time.

So if your process is extremely unbalanced in resource use the option of using a split approach as you sketched in the multiple processes/programs in a single container option in your question, is handier with autoscaling or resource management in general.

The multi process container is however one to avoid since it is against the design principles (less flexiable, library issues might still occur), but can sometimes be unavoidable. For example you need to log rotate files and the process in the container has to be aware of that, then running a cron and another process in that container is pretty much required. So only go for the multi process container if your application and/or resource management requires it, else stay away from it :)

-- Norbert van Nobelen
Source: StackOverflow