Answer the question
In order to leave comments, you need to log in
It looks like the nginx config in k8s is not applied, what's the problem?
As part of the test, I raised the mini-cube, threw in nginx + php-fpm + mysql and an application on slim'e. At first everything worked, then I decided to put things in order, dragged everything into folders. And when I go to the test domain, I now see a 503 error. I tried to connect to the pod, it seems that the nginx config didn’t pull up, despite the presence of the config.yaml file, and it seems that volume, volumeMount are correctly specified ...
Now I’ve been sitting for 2 hours trying to figure out what was wrong and why it worked before. There are absolutely no promotions. And the logs are empty, or I'm looking in the wrong place at all.
https://github.com/ivekov/minikubeNginxPhpMysql
There is a suspicion that the problem is in these files:
/opt/docker/nginxPhpFpm/configs/backend/crud/config.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
data:
nginx.conf: |
events {
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
# Set nginx to serve files from the shared volume!
root /var/www/html/public;
server_name _;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
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;
}
}
}
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-php-app
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
volumes:
# Create the shared files volume to be used in both pods
- name: app-files
hostPath:
path: /opt/docker/nginxPhpFpm/app/backend
type: Directory
- name: nginx-config-volume
configMap:
name: nginx-config
containers:
- name: backend
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: app-files
mountPath: /var/www/html
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
env:
- name: DB_HOST
value: mysql
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
- name: php-fpm
image: ivekov/php-fpm
volumeMounts:
- name: app-files
mountPath: /var/www/html
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "cp -r /app/. /var/www/html"]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question