<p>So I've been playing with kubernetes for the last few days and diving into all the tech. But I've reached a point that I cannot surpass, hopefully, someone will be able to help me.</p>

<p>My objective: Have a Laravel app running on Nginx + PHP-fpm in kubernetes (each service in its own pod in order to be able to scale independently)</p>

<p>My current problem: When I hit my endpoint I get a <code>200</code> result regardless of the code being runned on the background. At this point, I'm not sure anymore if I am miss understanding how nginx+php-fpm+laravel work.</p>

<p>My understanding is that any request would do something along this: Browser->nginx->php-fpm->nginx->browser.</p>

<p>With Nginx purely passing the request along and not actually doing anything with the request itself.</p>

<p>I leave the relevant files in case someone can assist me.</p>

<p>Any help would be more than welcome</p>

<h2>deployment.yaml</h2>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: php-fpm
  namespace: dash
  labels:
    app: php-fpm
spec:
  selector:
    matchLabels:
      app: php-fpm
  replicas: 1
  template:
    metadata:
      labels:
        app: php-fpm
    spec:
      containers:
      - name: php-fpm
        image: azurecr.io/php
        ports:
        - containerPort: 9000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: dash
labels:
  app: nginx
  spec:
    selector:
      matchLabels:
        app: nginx
    replicas: 1
    template:
      metadata:
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: azurecr.io/nginx
          ports:
          - containerPort: 80
</code></pre>

<h2>services.yaml</h2>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: php-service
  namespace: dash
spec:
  selector:
    app: php-fpm
  ports:
  - name: php-fpm-port
    protocol: TCP
    port: 9000
---
kind: Service
apiVersion: v1
metadata:
  name: nginx-service
  namespace: dash
spec:
  selector:
    app: nginx
  ports:
  - name: "80-nginx"
    port: 80
    targetPort: 80
  - name: "443-nginx"
    port: 443
    targetPort: 443
</code></pre>

<h2>nginx.conf</h2>

<pre><code>server {
    # Set the port to listen on and the server name
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name api.dashboard;

   location / {
       fastcgi_pass php-service.dash:9000;
       fastcgi_buffers 16 16k;
       fastcgi_buffer_size 32k;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       #fixes timeouts
       fastcgi_read_timeout 600;
       include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
   }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/laravel_error.log;
    access_log /var/log/nginx/laravel_access.log;
}
</code></pre>

<h2>php-fpm.conf</h2>

<pre><code>user = www-data
group = www-data
listen = 0.0.0.0:9000
</code></pre>

UP.
<p>After some more testing and investigation my problem was comming from a missunderstanding. I did assumed that nginx would not need to have the code since it would not be processing it but it is indeed needed for the Laravel app to actually run as it should.</p>

<p>The way to fix the problem is copying the code files in the nginx pods aswell.</p>
