Skip to content

kler/php-on-kubernetes

 
 

Repository files navigation

PHP on Kubernetes

There's no single way to run and operate an application on Kubernetes. As a general purpose and flexible containers orchestrator, different people ends up with different solutions and it's usually a trade-off between features, complexity, performances, which you balance based on your needs.

This repository doesn't aim to provide a one-fits-all solution, but offering options with pros and cons from which you can pick the one that works better to your use case and business.

Application Logs

For a comparison between the following approaches, please see the blog post:
PHP on Kubernetes: application logging via unix pipe

Option 1: log to php://stdout or php://stderr and enable catch_workers_output in php-fpm

  • Pro: easy.
  • Con: application logs are wrapped by php-fpm and it makes parsing more complicated.
  • Con: application logs are truncated to 1024 bytes and splitted into multiple messages. Long logs are not unusual if you use structured logging and you log contextual information on errors (ie. stack trace).
  • Con: application logs are mixed with php-fpm logs into the same stream.

See a working example at app-log-php-fpm-via-catch-workers-output/.

Option 2: log to unix pipe and tail it in a sidecar container

See a working example at app-log-php-fpm-via-unix-pipe/.

  • Pro: application logs are not wrapped by php-fpm.
  • Pro: application logs are not limited by length (no splitting / truncating).
  • Pro: application logs and php-fpm error logs are not mixed together in the same stream.

About

Lessons learned running PHP on Kubernetes in production

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 55.2%
  • Shell 44.8%