diff --git a/UPGRADE.md b/UPGRADE.md index 9d8be56..00f7143 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -10,6 +10,25 @@ 2. Run `composer update shopsys/deployment` 3. Check files in mentioned pull requests and if you have any of them extended in your project, apply changes manually +## Upgrade from v5.0.0 to v5.1.0 + +- health check for webserver now uses PHP-FPM `ping` endpoint instead of nginx `stub_status` ([#71](https://github.com/shopsys/deployment/pull/71)) +- update the `/health` location block in `project-nginx.conf` in your project's `app/orchestration/kubernetes/configmap/nginx.yaml` file to pass the request to PHP-FPM: + ```diff + location /health { + - stub_status on; + access_log off; + + + + include fastcgi_params; + + fastcgi_read_timeout 3s; + + fastcgi_param SCRIPT_FILENAME /ping; + + fastcgi_param SCRIPT_NAME /ping; + + fastcgi_param REQUEST_METHOD GET; + + + + fastcgi_pass php-upstream; + } + ``` + ## Upgrade from v4.6.1 to v5.0.0 - remove files that are already part of project-base by default ([#66](https://github.com/shopsys/deployment/pull/66)) diff --git a/kubernetes/configmap/production-php-fpm.yaml b/kubernetes/configmap/production-php-fpm.yaml index 22e11fd..89eb840 100644 --- a/kubernetes/configmap/production-php-fpm.yaml +++ b/kubernetes/configmap/production-php-fpm.yaml @@ -15,6 +15,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 diff --git a/kubernetes/deployments/webserver-php-fpm.yaml b/kubernetes/deployments/webserver-php-fpm.yaml index cc42bc2..c8c5cc0 100644 --- a/kubernetes/deployments/webserver-php-fpm.yaml +++ b/kubernetes/deployments/webserver-php-fpm.yaml @@ -94,10 +94,19 @@ spec: command: ["/var/www/html/phing", "-S", "warmup"] preStop: exec: - command: - - sh - - '-c' - - sleep 10 && kill -SIGQUIT 1 + command: ["/bin/sh","-lc","sleep 10; kill -QUIT 1 || true"] + livenessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 2 + readinessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 volumeMounts: - name: source-codes mountPath: /var/www/html @@ -125,20 +134,24 @@ spec: ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health livenessProbe: - initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 httpGet: path: /health - port: 80 + port: health + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 3 + failureThreshold: 6 readinessProbe: httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 3 volumeMounts: - name: nginx-default-config mountPath: /etc/nginx/nginx.conf diff --git a/tests/fixtures/orchestration/kubernetes/configmap/nginx.yaml b/tests/fixtures/orchestration/kubernetes/configmap/nginx.yaml index 4eaa9bc..919a536 100644 --- a/tests/fixtures/orchestration/kubernetes/configmap/nginx.yaml +++ b/tests/fixtures/orchestration/kubernetes/configmap/nginx.yaml @@ -73,8 +73,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } diff --git a/tests/scenarios/basic-production/expected/webserver.yaml b/tests/scenarios/basic-production/expected/webserver.yaml index 20ae8e1..c8a38ee 100644 --- a/tests/scenarios/basic-production/expected/webserver.yaml +++ b/tests/scenarios/basic-production/expected/webserver.yaml @@ -88,8 +88,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -333,6 +340,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -572,10 +581,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -607,23 +628,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/development-single-domain/expected/webserver.yaml b/tests/scenarios/development-single-domain/expected/webserver.yaml index 296414f..dd1b707 100644 --- a/tests/scenarios/development-single-domain/expected/webserver.yaml +++ b/tests/scenarios/development-single-domain/expected/webserver.yaml @@ -86,8 +86,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -331,6 +338,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -566,10 +575,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -601,23 +622,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/escaping-env/expected/webserver.yaml b/tests/scenarios/escaping-env/expected/webserver.yaml index dde511d..2242efc 100644 --- a/tests/scenarios/escaping-env/expected/webserver.yaml +++ b/tests/scenarios/escaping-env/expected/webserver.yaml @@ -88,8 +88,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -333,6 +340,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -576,10 +585,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -611,23 +632,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi diff --git a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml index 2878fd2..b553365 100644 --- a/tests/scenarios/production-with-cloudflare/expected/webserver.yaml +++ b/tests/scenarios/production-with-cloudflare/expected/webserver.yaml @@ -88,8 +88,15 @@ data: root /var/www/html/web; location /health { - stub_status on; access_log off; + + include fastcgi_params; + fastcgi_read_timeout 3s; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_param SCRIPT_NAME /ping; + fastcgi_param REQUEST_METHOD GET; + + fastcgi_pass php-upstream; } } @@ -333,6 +340,8 @@ data: [www] listen = 127.0.0.1:9000 + ping.path = /ping + ping.response = pong pm = dynamic pm.max_children = 20 @@ -572,10 +581,22 @@ spec: preStop: exec: command: - - sh - - -c - - sleep 10 && kill -SIGQUIT 1 + - /bin/sh + - -lc + - sleep 10; kill -QUIT 1 || true + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + tcpSocket: + port: 9000 + timeoutSeconds: 2 name: php-fpm + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + tcpSocket: + port: 9000 + timeoutSeconds: 2 resources: limits: memory: 2Gi @@ -607,23 +628,27 @@ spec: - -c - sleep 5 && /usr/sbin/nginx -s quit livenessProbe: + failureThreshold: 6 httpGet: path: /health - port: 80 + port: health initialDelaySeconds: 30 - periodSeconds: 5 - timeoutSeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 name: webserver ports: - containerPort: 8080 name: http + - containerPort: 80 + name: health readinessProbe: + failureThreshold: 3 httpGet: path: /health - port: 80 - initialDelaySeconds: 5 + port: health + initialDelaySeconds: 2 periodSeconds: 5 - timeoutSeconds: 5 + timeoutSeconds: 2 resources: limits: memory: 300Mi