skip to Main Content

I have a very simple docker-compose app with nginx and php-fpm services.

I would like to create a Helm chart that would deploy this exact same thing as a unit (a POD I guess?) but I would like to be able to scale the php-fpm service.

How can I achieve that?

My idea is to have these containers in a single deployment so I don’t have a lot of deployments scattered.

i.e

App1:
   - Container 1 (php-fpm autoscaled or manually scaled)
   - Container 2 (nginx)
   - Container 3 (Redis)
   - Container 4 (something else that this app needs)

App2
   - Container 1
   - Container 2
   - Container 3 etc...

I could do different deployments but then it would be like

app1_php-fpm
app1_nginx
app1_redis
app2_container1
app2_container2
app2_container3

Instead of a single pod.

2

Answers


  1. The "one-container-per-Pod" model is the most common Kubernetes use
    case; in this case, you can think of a Pod as a wrapper around a
    single container; Kubernetes manages Pods rather than managing the
    containers directly.

    Nginx, Redis should run as separate services, so that they can scale independent of your application in a decoupled manner.

    Nginx can reverse proxy multiple applications so you don’t need to have a separate Nginx instance for every app.

    https://kubernetes.io/docs/concepts/workloads/pods/#using-pods

    Login or Signup to reply.
  2. It’s best practice to keep the single container inside the pod however we can run the multiple containers also.

    Keep the Redis & Nginx containers as separate deployment and you can add the HPA on that they can scale up and down based on load.

    By keeping the deployment separate would also help in doing any maintenance if required or deployment without downtime.

    However, if you don’t have an option to keep Nginx aside you can keep that also with fpm container as it’s also a light weight container.

    For example here I have one fpm and Nginx containers running inside single POD : https://github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/master/wordpress-deployment.yaml

    if possible divide all the applications as a single deployment so that it will be very easy to manage the deployments and maintenance and scaling also.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search