Running multiple applications on Kubernetes. How to create the structure?

feketegy

This is more of a theoretical question. How do you guys create the structure of a Kubernetes deployments/services/pods that runs multiple applications?

Let's say I want to run 3 Wordpress websites on my servers. For this I need: Nginx, MySQL, PHP-FPM and the Wordpress code base.

  1. Is it better to spin off separate pods/services for Nginx, MySQL, PHP-FPM that will serve all 3 Wordpress websites and create 3 Wordpress pods/services for the 3 websites?

  2. OR is it better to create a separate pods/service for each one of the websites, therefore the grouping would be:

    • Pod1: Nginx, MySQL, PHP-FPM, Wordpress
    • Pod2: Nginx, MySQL, PHP-FPM, Wordpress
    • Pod3: Nginx, MySQL, PHP-FPM, Wordpress

With option 2 I would need somehow to route the specific website traffic to the specific service/pod

frankgreco

Kubernetes is extremely flexible as you are discovering and allows you to architect you application in numerous ways. As a general rule of thumb, only run one process per container per pod. However, there definitely valid use cases for running multiple containers in a pod. I think for your use case, you can use both approaches.

Let me attempt to break down each of your components:

MySQL
I would definitely run this in it's own pod. I would wrap it in a StatefulSet and front it with its own Service

Nginx + Wordpress
In my opinion, whether you run these two processes in one pod or two depends on how you are using tls, if at all. As we know, Wordpress is very vulnerable to attacks. Hence, perhaps you have rules in your Nginx config to limit access to certain paths, methods, etc. If you run Nginx and Wordpress in the same pod, then you can expose only the Nginx port and the only way traffic will get to the Wordpress container is if it goes through Nginx. If you run these containers as separate pods, then from a security standpoint, you'll need some other way to make sure that inbound traffic to your Wordpress pod only comes from your Nginx pod. You can accomplish this with the NetworkPolicy resource or you can just use mutual TLS between these two pods.

In summary, in a microservice architecture, you want your process to be as decoupled as possible so that they can be managed and deployed separately. Hence, a single process per container per Pod is attractive. However, there are instances that require you to run more than one container per Pod. In my example I used security as such motivation.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to debug Kotlin applications running in Kubernetes pods in IntelliJ?

Running multiple identical applications

How to structure of a Symfony 2 application to support multiple applications?

How to share a service across multiple applications and check if it already running?

Azure kubernetes - Istio & multiple kubernetes applications?

How to create multiple admin users for kubernetes cluster?

How to create multiple instances of Mediawiki in a Kubernetes Cluster

How to create Kubernetes cluster with multiple nodes on Windows

Running multiple Java Applications on startup

Kubernetes performance impact or overhead on running applications

How do I connect minikube(kubernetes) nodes running Flask applications to a common database in a mysql docker container?

How to structure large AngularJS applications

Create deep link for multiple applications

Azure kubernetes - Prometheus to handle multiple applications

Testing in tomcat when it is running multiple applications

Running multiple applications in one docker container

About running multiple applications on the same port

How to create kubernetes secret with multiple values for one key?

how to create tree structure in neo4j with multiple relationships?

How to create multiple autocomplete in an input field based on a sentence structure?

How to combine multiple string vectors to create data structure in R?

How could I use docker to give clients access to multiple applications running on 1 server?

Does kubernetes rolling update may impact applications running in pods or not?

How to structure/group Kubernetes Deployments?

How to create multiple functions for running totals from a text file in c?

How to deploy Kafka Stream applications on Kubernetes?

How to set dns for applications deployed on kubernetes?

How to connect MySQL running on Kubernetes

How to structure angularJS models for large and maintainable applications?