MySQL container liveness and readiness probes work but cause a lot of error logs in Kubernetes

254 Views Asked by At

In my deployment I tried using

      readinessProbe:
        tcpSocket:
          port: 3306
        initialDelaySeconds: 30
        periodSeconds: 10
      livenessProbe:
        tcpSocket:
          port: 3306

and also

      readinessProbe:
        exec:
          command: ["mysqladmin", "ping", "-h", "localhost"]
          ...
      livenessProbe:
        exec:
          command: ["mysqladmin", "ping", "-h", "localhost"]
          ...

both work as the cluster recognizes the states correctly, but the logs are flooded with

  • case 1: "Got an error reading communication packets"
  • case 2: "Access denied for user 'root'@'localhost' (using password: NO)"

How can I out of the box, without an extra script, make a readiness probe without log errors. E.g. can I use the credentials as env variables somehow in the probes?

1

There are 1 best solutions below

0
Fariya Rahmat On

Case 1: "Got an error reading communication packets"

This error is due to the fact that you want to transfer a lot of data in one request, and thus a similar error may occur. To solve this problem, you need to increase the max_allowed_packet variable.

The max_allowed_packet variable is responsible for the maximum data size you can transfer in one request.

The default value of the variable max_allowed_packet is 16 megabytes, so let's make sure of this, let's use queries:

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';

Values are specified in bytes.

You can change the values of max_allowed_packet through the configuration file.

$. vim /etc/my.cnf.d/server.cnf

Restart the database.

$. service mysqld restart;

Above information is derived from this link on Mysql error - Got an error reading communication packets.

Case 2: "Access denied for user 'root'@'localhost' (using password: NO)"

The error log happens due to insufficient access and MySQL database privileges. As a result, the system releases a typical warning that confirms the MySQL error log and affects the root user, although some inputs, values, and elements are correct.

Hence try resetting your root password.