Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to test a file exists from a Kubernetes probe?

I have a sidecar container in a MySQL Pod which will use the MySQL socket file in order to access the database.

I would like to be sure MySQL has successfully started and therefore have created the socket file before than this sidecar container starts.

I tried to add a readiness probe with an exec.command being test -S /var/run/mysqld/mysqld.sock but it fails with:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Readiness probe failed: OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "test -S /var/run/mysqld/mysqld.sock": stat test -S /var/run/mysqld/mysqld.sock: no such file or directory: unknown

When I open a terminal session in the sidecar container, I can ls the socket file and it’s there.

So it looks like my test -S <path> command doesn’t work as expected in the context of the probe.

How can I write my probe so that as soon as the socket file is available my sidecar container starts?

>Solution :

Try:

...
readinessProbe:
  exec:
    command:
    - sh
    - -c
    - test -S /var/run/mysqld/mysqld.sock
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading