Making logs available to Stackdriver from a Custom Kubernetes docker container running Apache and PHP-FPM

10/18/2018

We are running a small test cluster of Custom Kubernetes pods on Google cloud, that internally are running Apache and PHP-FPM.

The Cluster has the following key config:

  • Master version: 1.10.6-gke.2
  • Kubernetes alpha features: Disabled
  • Total size: 3
  • StackDriver Logging: Enabled
  • StackDriver Monitoring: Enabled

Once the cluster comes up a kubectl get pods --all-namespaces is showing the fluentd and heapster services running along side our services as I would expect.

kube-system   event-exporter-v0.2.1-5f5b89fcc8-r89d5                           2/2       Running   0          13d
kube-system   fluentd-gcp-scaler-7c5db745fc-gbrqx                              1/1       Running   0          21d
kube-system   fluentd-gcp-v3.1.0-76mr4                                         2/2       Running   0          13d
kube-system   fluentd-gcp-v3.1.0-kl4xp                                         2/2       Running   0          13d
kube-system   fluentd-gcp-v3.1.0-vxsq5                                         2/2       Running   0          13d
kube-system   heapster-v1.5.3-95c7549b8-fdlmm                                  3/3       Running   0          13d
kube-system   kube-dns-788979dc8f-c9v2d                                        4/4       Running   0          99d
kube-system   kube-dns-788979dc8f-rqp7d                                        4/4       Running   0          99d
kube-system   kube-dns-autoscaler-79b4b844b9-zjtwk                             1/1       Running   0          99d

We can get the logging from our application code (that runs inside our pods) to show up in Stackdriver Logging, but we want to aggregate the logging for Apache (/var/log/httpd/access_log and error_log) and PHP-FPM in Stackdriver as well.

This page from Google's Docs implies that this should be enabled by default. https://cloud.google.com/kubernetes-engine/docs/how-to/logging

Note: Stackdriver Logging is enabled by default when you create a new cluster using the gcloud command-line tool or Google Cloud Platform Console.

However that is obviously not the case for us. We have tried a few different approaches to get this to work (listed below), but without success.

Including:

It didn't appear that this step should be required as the documentation implies that you only need to do this on a VM instance, but we tried it anyway on our k8s pods. As part of this step we made sure that Apache has mod_status enabled (/server-status) and PHP-FPM has /fpm-status enabled, and then installed the module Apache plugin following the docs.

This seems like it should be a simple thing to do, but we have obviously missed something. Any help would be most appreciated.

Cheers, Julian Cone

-- Jules Cone
apache
docker
fpm
kubernetes
stackdriver

0 Answers