SOS
I have Laravel web app which is running on Kubernetes But some request taking long time and getting error `net::ERR_FAILED 504 (Gateway Time-out) ????
I tested same web app on VM-ubuntu (not in K8s/not in docker) there is no such issue, all requests responsing very fast and no error 504
API's itself working very fast when we check via curl
So far
I tried to scale up pod of webapp to 20 - no result
I tried get to webapp via IP (NodePort) - no result
I tried to run on new K8s cluster - no result But still same error:
Is this Laravel issue or Kubernetes conf??
Can you please give an idea
Dockerfile
FROM debian:latest
RUN mkdir -p /usr/src/app/
WORKDIR /usr/src/app/
RUN apt update
RUN apt-get install -y wget sudo
RUN apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
RUN wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
RUN apt update
RUN apt-get install -y php8.1 php8.1-fpm php8.1-mbstring php8.1-zip php8.1-xml php8.1-mysql php8.1-curl \
php8.1-gd php8.1-redis php8.1-soap nginx supervisor nano zip unzip mc
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
#RUN mkdir /run/php
RUN mv composer.phar /usr/local/bin/composer
COPY ./server/docker-configs/nginxconf/netcore.conf /etc/nginx/conf.d/netcore.conf
COPY . /usr/src/app/
COPY ./server/docker-configs/supervisord.conf /etc/supervisor/conf.d/nginx_php.conf
#COPY .env.example .env
EXPOSE 8080
RUN sed -i 's/post_max_size = 8M/post_max_size = 50M/' /etc/php/8.1/fpm/php.ini
RUN sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/' /etc/php/8.1/fpm/php.ini
RUN sed -i 's/memory_limit = 128M/memory_limit = 2048M/' /etc/php/8.1/fpm/php.ini
RUN sed -i 's/;clear_env = no/clear_env = no/' /etc/php/8.1/fpm/pool.d/www.conf
#RUN chown www-data:www-data -R /usr/src/app/storage/
RUN php --ini
RUN cd /usr/src/app/ && composer install
RUN composer install
CMD ["sh", "/usr/src/app/server/docker-configs/init.sh"]
#FRONTEND
RUN apt-get install -y npm curl
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt install -y nodejs
#COPY .env.example .env
RUN cd /usr/src/app/frontend/ && cp .env.example .env && npm install && npm run build
deploy.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: call-center-netcore-configmap
namespace: develop
data:
use-http2: "false"
APP_NAME: "call-center.xyzcomp.com"
APP_ENV: "production"
APP_DEBUG: "true"
APP_URL: "https://call-center.xyzcomp.com"
LOG_CHANNEL: "stack"
LOG_DEPRECATIONS_CHANNEL: "null"
LOG_LEVEL: "debug"
DB_CONNECTION: "mysql"
DB_HOST: "cluster1-haproxy.pxc.svc.k8s.xyzcompany.net"
DB_PORT: "3306"
DB_DATABASE: "netcore-call-center"
BROADCAST_DRIVER: "log"
CACHE_DRIVER: "file"
FILESYSTEM_DRIVER: "local"
QUEUE_CONNECTION: "sync"
SESSION_DRIVER: "database"
SESSION_LIFETIME: "120"
MEMCACHED_HOST: "127.0.0.1"
REDIS_HOST: "127.0.0.1"
REDIS_PASSWORD: "null"
REDIS_PORT: "6379"
MAIL_MAILER: "smtp"
MAIL_HOST: "mailhog"
MAIL_PORT: "1025"
MAIL_USERNAME: "null"
MAIL_PASSWORD: "null"
MAIL_ENCRYPTION: "null"
MAIL_FROM_ADDRESS: "null"
MAIL_FROM_NAME: "${APP_NAME}"
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""
AWS_DEFAULT_REGION: "us-east-1"
AWS_BUCKET: ""
AWS_USE_PATH_STYLE_ENDPOINT: "false"
PUSHER_APP_ID: ""
PUSHER_APP_KEY: ""
PUSHER_APP_SECRET: ""
PUSHER_APP_CLUSTER: "mt1"
VITE_PUSHER_APP_KEY: "${PUSHER_APP_KEY}"
VITE_PUSHER_HOST: "${PUSHER_HOST}"
VITE_PUSHER_PORT: "${PUSHER_PORT}"
VITE_PUSHER_SCHEME: "${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER: "${PUSHER_APP_CLUSTER}"
MIX_PUSHER_APP_KEY: "${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER: "${PUSHER_APP_CLUSTER}"
NETCORE_API_URL: "https://api.xyzcomp.com"
NETCORE_NOTIFICATION_URL: "https://notification.xyzcomp.com"
NETCORE_NOMENCLATURE_URL: "https://nomenclature.xyzcomp.com"
NETCORE_API_TOKEN: ""
NETCORE_NOMENCLATURE_API_TOKEN: ""
NETCORE_NOTIFICATION_API_TOKEN: ""
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: call-center-netcore-deploy
namespace: develop
labels:
app: call-center-netcore
spec:
replicas: 5
selector:
matchLabels:
app: call-center-netcore
template:
metadata:
labels:
app: call-center-netcore
spec:
containers:
- name: call-center-netcore
image: docker-c2.xyzcompany.net/call-center-netcore/call-center-netcore-kz:v0.BUILDVERSION
ports:
- containerPort: 8080
envFrom:
- secretRef:
name: call-center-netcore-secrets
- configMapRef:
name: call-center-netcore-configmap
volumeMounts:
- name: pvc-call-center-netcore-kz
mountPath: /usr/src/app/storage/
#imagePullSecrets:
#- name: regcred
imagePullSecrets:
- name: drokh-jenkins
volumes:
- name: pvc-call-center-netcore-kz
persistentVolumeClaim:
claimName: call-center-netcore-kz-claim
---
apiVersion: v1
kind: Service
metadata:
name: call-center-netcore-service
namespace: develop
spec:
selector:
app: call-center-netcore
ports:
- protocol: TCP
port: 8080
targetPort: 8080
type: NodePort
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: call-center-netcore-ingress
namespace: develop
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/proxy-body-size: "5m"
nginx.ingress.kubernetes.io/proxy-send-timeout: "360"
nginx.ingress.kubernetes.io/proxy-read-timeout: "360"
spec:
rules:
- host: "call-center.xyzcomp.com"
http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: call-center-netcore-service
port:
number: 8080
- host: "www.call-center.xyzcomp.com"
http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: call-center-netcore-service
port:
number: 8080
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: call-center-cron
namespace: develop
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
imagePullSecrets:
- name: drokh-jenkins
containers:
- name: call-center-cronjob
image: docker-c2.xyzcompany.net/call-center-netcore/call-center-netcore-kz:v0.BUILDVERSION
imagePullPolicy: IfNotPresent
envFrom:
- secretRef:
name: call-center-netcore-secrets
- configMapRef:
name: call-center-netcore-configmap
command:
- php
args:
- artisan
- schedule:run
restartPolicy: OnFailure
VM ubuntu Nginx config
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
root /var/www/call-center.xyzcomp.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.html index.php;
charset utf-8;
client_max_body_size 100M;
access_log /var/log/nginx/sc_access.log;
error_log /var/log/nginx/sc_error.log;
location / {
root /var/www/call-center.xyzcomp.com/frontend/dist/;
try_files $uri $uri/ /index.html;
}
location /api {
root /var/www/call-center.xyzcomp.com/public;
try_files $uri $uri/ /index.php?$args;
}
location /storage {
root /var/www/call-center.xyzcomp.com/public;
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
root /var/www/call-center.xyzcomp.com/public;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Project files
folder frontend


