I have php application with public
folder, that contains as index.php
that handles php requests as static files.
I would like to deliver static files via nginx container directly, and use php-fpm only for delivering dynamic requests.
How that can be achieved? As i understand, there are two ways:
persistentVolumeClaim
, but that also requires some kind of magic for synchronization (initContainers
).What is the best practice?
Let's begin by saying that there are 2 pods which are Nginx Pod and Php pod. Now There are two things need to be associated with these pods.
I would prefer to use Persistent Volume claim for static files and ConfigMap for the configuration file.
Solutions to your issue.
Php pod will have following k8s resources
Nginx pod will have following k8s resources
Now Deployment Resouces will have a relationship with other resources such as Persistent volume claim and configmap etc.
As I understand by InitContainer, It helps Pod to have a consistent Network Namespace as well as organise file system for the main container it provides all the necessary resources to the main container such as service account, pvc, configmap.
For example, If the main container restart then init container make sure that IP address does not change.However, if you create pod again it means you are creating initcontainer again then Pod will have new IP address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With