title: php-fpm process receiving SIGKILL signal in Kubernetes
body: <p>I have created the ubuntu docker image with Nginx, PHP and php-fpm configured in it. It is working fine when I am running it on Docker instance.</p>
  
  <p>But when I run the same image in kubernetes, the php-fpm process receive the SIGKILL (9) signal and we are getting 502 Gateway errors.</p>
  
  <p>I guess it is kubernetes which send the SIGKILL signal to kubernetes pods. I am not using any readiness and liveliness probes in kubernetes templates.</p>
  
  <p>Appreciate any help. Thanks in advance.</p>
  
  <p>Find the docker file and php-fpm log below for details,</p>
  
  <h2>Dockerfile</h2>
  
  <pre><code>FROM ubuntu
  
  #install utilities tools
  RUN apt-get update \
      &amp;&amp; apt-get install -y vim unzip curl python-software-properties software-properties-common locales supervisor
  
  # Update software list, install php-nginx &amp; clear cache
  RUN locale-gen en_US.UTF-8 &amp;&amp; \
      export LANG=en_US.UTF-8 &amp;&amp; \
      add-apt-repository -y ppa:ondrej/php &amp;&amp; \
      apt-get update &amp;&amp; \
      apt-get upgrade -y &amp;&amp; \
      apt-get install -y --force-yes nginx \
      php5.6 php5.6-zip php5.6-fpm php5.6-cli php5.6-mysql php5.6-mcrypt php5.6-xml\
      php5.6-curl php5.6-gd &amp;&amp; \
      apt-get clean &amp;&amp; \
      rm -rf /var/lib/apt/lists/* \
             /tmp/* \
             /var/tmp/*
  
  # Configure nginx
  RUN echo "daemon off;" &gt;&gt; /etc/nginx/nginx.conf
  RUN sed -i "s/sendfile on/sendfile off/" /etc/nginx/nginx.conf
  RUN mkdir -p /var/www/html
  
  # Configure PHP
  RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/5.6/fpm/php.ini &amp;&amp; \
      sed -i -e "s/;date.timezone =.*/date.timezone = America\/Argentina\/Buenos_Aires/" /etc/php/5.6/fpm/php.ini &amp;&amp; \
      sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" /etc/php/5.6/fpm/php.ini &amp;&amp; \
      sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php/5.6/fpm/php.ini &amp;&amp; \
      sed -i -e "s/variables_order = \"GPCS\"/variables_order = \"EGPCS\"/g" /etc/php/5.6/fpm/php.ini
  
  ##Updated for PHP 5.6
  RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/5.6/fpm/php-fpm.conf &amp;&amp; \
      sed -i -e "s/pid =.*/pid = \/var\/run\/php-fpm.pid/" /etc/php/5.6/fpm/php-fpm.conf &amp;&amp; \
      sed -i -e "s/listen =.*sock/listen = 127.0.0.1:9000/" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/;clear_env = no/clear_env = no/" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/pm.max_children = 5/pm.max_children = 4/g" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/pm.start_servers = 2/pm.start_servers = 3/g" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" /etc/php/5.6/fpm/pool.d/www.conf &amp;&amp; \
      sed -i -e "s/;pm.max_requests = 500/pm.max_requests = 200/g" /etc/php/5.6/fpm/pool.d/www.conf
  
  RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/5.6/cli/php.ini &amp;&amp; \
      sed -i -e "s/;date.timezone =.*/date.timezone = America\/Argentina\/Buenos_Aires/" /etc/php/5.6/cli/php.ini &amp;&amp; \
      sed -i -e "s/upload_max_filesize\s*=\s*2M/upload_max_filesize = 100M/g" /etc/php/5.6/cli/php.ini &amp;&amp; \
      sed -i -e "s/post_max_size\s*=\s*8M/post_max_size = 100M/g" /etc/php/5.6/cli/php.ini &amp;&amp; \
      sed -i -e "s/variables_order = \"GPCS\"/variables_order = \"EGPCS\"/g" /etc/php/5.6/cli/php.ini
  
  COPY opsconfig/default_server_config /etc/nginx/sites-available/default
  COPY opsconfig/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
  
  RUN phpenmod -v 5.6 mcrypt &amp;&amp; \
      phpenmod -v 5.6 xdebug &amp;&amp; \
      phpenmod -v 5.6 zip
  
  #install composer
  RUN curl -O https://getcomposer.org/composer.phar &amp;&amp; \
      mv composer.phar /usr/local/bin/composer &amp;&amp; \
      chmod +x /usr/local/bin/composer
  
  # Workdir
  WORKDIR /var/www/html
  COPY src/ /var/www/html/    
  
  RUN chown -R www-data:www-data /var/www/html
  
  CMD ["/usr/bin/supervisord"]
  </code></pre>
  
  <h2>supervisor.conf</h2>
  
  <pre><code>[supervisord]
  nodaemon=true
  
  [program:php-fpm]
  command=/usr/sbin/php-fpm5.6 --nodaemonize
  
  [program:nginx]
  command=/usr/sbin/nginx
  autostart=true
  autorestart=true
  priority=10
  stdout_events_enabled=true
  stderr_events_enabled=true
  stdout_logfile=/dev/stdout
  stdout_logfile_maxbytes=0
  stderr_logfile=/dev/stderr
  </code></pre>
  
  <h2>php-fpm.log</h2>
  
  <pre><code>[10-Oct-2017 16:52:02] NOTICE: fpm is running, pid 56
  [10-Oct-2017 16:52:02] NOTICE: ready to handle connections
  [10-Oct-2017 16:52:02] NOTICE: systemd monitor interval set to 10000ms
  [10-Oct-2017 16:52:30] WARNING: [pool www] child 57 exited on signal 9 (SIGKILL) after 28.399445 seconds from start
  [10-Oct-2017 16:52:30] NOTICE: [pool www] child 61 started
  [10-Oct-2017 16:52:38] WARNING: [pool www] child 59 exited on signal 9 (SIGKILL) after 36.796172 seconds from start
  [10-Oct-2017 16:52:38] NOTICE: [pool www] child 62 started
  [10-Oct-2017 16:53:15] WARNING: [pool www] child 58 exited on signal 9 (SIGKILL) after 73.299127 seconds from start
  [10-Oct-2017 16:53:15] NOTICE: [pool www] child 63 started
  [10-Oct-2017 17:45:02] WARNING: [pool www] child 62 exited on signal 9 (SIGKILL) after 3143.801344 seconds from start
  [10-Oct-2017 17:45:02] NOTICE: [pool www] child 64 started
  </code></pre>
  
  <h2>Nginx Log</h2>
  
  <pre><code>2017/10/10 16:53:15 [error] 11#11: *162 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.244.2.49, server: _, request: "GET /admin/index.php?route=common/dashboard&amp;token=V4iXjKHenn2ZOIldfn4pmIHcTIHiFoxk HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "shop9.homesourcesystems.net", referrer: "https://domain_name/admin/"
  2017/10/10 17:45:02 [error] 11#11: *166 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.244.2.49, server: _, request: "GET /admin/index.php?route=common/dashboard&amp;token=sFiMAItAgX22BarBfcNNVuyin50ZauIa HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "shop9.homesourcesystems.net", referrer: "https://domain_name/admin/"
  </code></pre>
  
  <h2>Pod Definition</h2>
  
  <pre><code>Name:           bumptious-beetle-3107682338-qlvcf
  Namespace:      testns
  Node:           k8s-agent-1/10.240.0.4
  Start Time:     Wed, 11 Oct 2017 09:26:21 +0000
  Labels:         app=testapp
                  pod-template-hash=3107682338
                  release=bumptious-beetle
  Annotations:    checksum/config=466a2fbe40164c0f5a10a06e26417c92a47422720e96c4fb51562eb8388d282f
                  kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"testns","name":"bumptious-beetle-3107682338","uid":"3e2745b7-ae66...
  Status:         Running
  IP:             10.244.0.205
  Controllers:    ReplicaSet/bumptious-beetle-3107682338
  Containers:
    hstestns:
      Container ID:       docker://31477927d3d0ac1b3f2fe662601d1d65d2a6d1fb442e580f9c1836e921a85f75
      Image:              phpnginx:1.9
      Image ID:           docker-pullable://phpnginx@sha256:7dfb96e283f0802e72249aeb252d3e6290dec00591c442da80bfa4727cef7ca5
      Port:               80/TCP
      State:              Running
        Started:          Wed, 11 Oct 2017 09:26:42 +0000
      Ready:              True
      Restart Count:      0
      Limits:
        cpu:      100m
        memory:   50Mi
      Requests:
        cpu:      10m
        memory:   40Mi
      Environment Variables from:
        bumptious-beetle     ConfigMap       Optional: false
      Environment:                        &lt;none&gt;
      Mounts:
        /var/run/secrets/kubernetes.io/serviceaccount from default-token-ptkqw (ro)
  Conditions:
    Type          Status
    Initialized   True
    Ready         True
    PodScheduled  True
  Volumes:
    default-token-ptkqw:
      Type:       Secret (a volume populated by a Secret)
      SecretName: default-token-ptkqw
      Optional:   false
  QoS Class:      Burstable
  Node-Selectors: &lt;none&gt;
  Tolerations:    &lt;none&gt;
  Events:
    FirstSeen     LastSeen        Count   From                            SubObjectPath                   Type            Reason          Message
    ---------     --------        -----   ----                            -------------                   --------        ------          -------
    13m           13m             1       default-scheduler                                               Normal          Scheduled       Successfully assigned bumptious-beetle-3107682338-qlvcf to k8s-agent-1
    13m           13m             1       kubelet, k8s-agent-1   spec.containers{hsecommerce}    Normal          Pulling         pulling image "phpnginx:1.9"
    13m           13m             1       kubelet, k8s-agent-1   spec.containers{hsecommerce}    Normal          Pulled          Successfully pulled image "phpnginx:1.9"
    13m           13m             1       kubelet, k8s-agent-1   spec.containers{hsecommerce}    Normal          Created         Created container with id 31477927d3d0ac1b3f2fe662601d1d65d2a6d1fb442e580f9c1836e921a85f75
    13m           13m             1       kubelet, k8s-agent-1   spec.containers{hsecommerce}    Normal          Started         Started container with id 31477927d3d0ac1b3f2fe662601d1d65d2a6d1fb442e580f9c1836e921a85f75
  </code></pre>
  
  <p>Regards,
  Rahul</p>