Is there an issue with the task : Deploy Nginx and Phpfpm on Kubernetes?

Hi all,

Two days before, I have been assigned the task : Deploy Nginx and Phpfpm on Kubernetes. But I think that the image asked to deploy has an issue, each time I tried to deploy the pod I got this error :

To give you an idea about what I’ve done, I have just referred to the below link :slight_smile: https://matthewpalmer.net/kubernetes-app-developer/articles/php-fpm-nginx-kubernetes.html

@Inderpreet @kodekloud-support3 @rahul456 could you have a look, please

@b.kamal, can you please share you yml file ?

Hi @rahul456, thank you your reply. My script looks like this :

kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
data:
nginx.conf: |
events {
}
http {
server {
listen 8096 default_server;
listen [::]:8096 default_server;

    # Set nginx to serve files from the shared volume!
    root /var/www/html;
    index index.php index.html index.hml;
    server_name _;
    location / {
      try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
      include fastcgi_params;
      fastcgi_param REQUEST_METHOD $request_method;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_pass 127.0.0.1:9000;
    }
  }
}

kind: Pod
apiVersion: v1
metadata:
name: nginx-phpfpm
spec:
volumes:
- name: shared-files
emptyDir: {}
- name: nginx-config-volume
configMap:
name: nginx-config

containers:
- image: php:7.2-fpm
name: php-fpm-container
volumeMounts:
- name: shared-files
mountPath: /var/www/html
lifecycle:
postStart:
exec:
command: ["/bin/sh", “-c”, “cp -r /app/. /var/www/html”]

- image: nginx:latest
  name: nginx-container
  volumeMounts:
    - name: shared-files
      mountPath: /var/www/html
    - name: nginx-config-volume
      mountPath: /etc/nginx/nginx.conf
      subPath: nginx.conf

@b.kamal, as per question, you need not to run any command in yml template.

Ok, understood, thank you for your precious support