<p>I have a PostgreSQL standalone server running on Kubernetes. I noticed I got the following messages in the log:</p>
<pre><code>incomplete startup packet
</code></pre>
<p>now I read some articles on the web and StackOverflow and it seems it could be related to a client that tries to connect to the service to check its status. For this reason, I wrote a liveness and readiness check like this:</p>
<pre><code>readinessProbe:
  exec:
    command:
      - /postgresql/readiness.sh
  initialDelaySeconds: 45
  timeoutSeconds: 5
  periodSeconds: 10
livenessProbe:
  exec:
    command:
      - /postgresql/liveness.sh
  initialDelaySeconds: 45
  timeoutSeconds: 5
  periodSeconds: 10
</code></pre>
<p>where the scripts <code>/postgresql/liveness.sh</code> is something like this:</p>
<pre><code>#!/bin/sh
if [ $(ps -ef | grep -v grep | grep postgres | wc -l) -lt 11 ]; then
    exit 1
else
    exit 0
fi
</code></pre>
<p>and <code>/postgresql/readiness.sh</code> is like this:</p>
<pre><code>#!/bin/sh
su - user -c &quot;/var/user/packages/postgres-11.9/bin/psql -p 2544 -d postgres -c \&quot;SELECT 1\&quot;&quot; &gt; /dev/null 2&gt;&amp;1
</code></pre>
<p>The problem is that I still see the message in logs and I don't know how to check if the two probes are working.
Any suggestion?</p>

Salvatore D'angelo
<p>I found the problem. If you deploy PostgreSQL on Kubernetes and expose it as a service on a Cloud platform, you need to use a load balancer.
This load balancer checks the healthiness of your application send health packets to the PostgreSQL port and since it is not a valid PostgreSQL command, the application reply with the message above.</p>
<p>IBM Cloud doesn't provide any solution to this and I think the message can be ignored. To make it less annoying just set the interval check to the right value (in my case 60s instead of 5s). The higher the value the less annoying it will be, however, it will be less reactive to failures.</p>
<p>In addition, to avoid uncontrolled Kubernetes probe provide always:</p>
<ul>
<li>readiness probe</li>
<li>liveness probe</li>
<li>start probe</li>
</ul>
<p>In my question, you can see how to define it for PostgreSQL. The only one not mentioned is start probe you can define in this way:</p>
<pre><code>startProbe:
  exec:
    command:
      - /postgresql/liveness.sh
  initialDelaySeconds: 45
  timeoutSeconds: 5
  periodSeconds: 10
</code></pre>
<p>for startProbe is OK to use the same liveness script since the application can be considered started when all processes are up and running. However, a live and started process doesn't mean it is able to accept the connection, and here is where the readiness probe comes into action.</p>
