Home  >  Q&A  >  body text

Initializing a container to run on MySQL using Kubernetes

I am running mysql as an init container of a kubernetes deployment.

For various reasons, I need to start mysql/restore a backup of mysql in the init container -> save it into a pvc, then the main pod will be a mysql pod with the data attached.

This is because I need to take a snapshot of the disk, and I will have CI monitor the snapshot before the pod is ready/running.

�%

P粉315680565P粉315680565206 days ago357

reply all(1)I'll reply

  • P粉683665106

    P粉6836651062024-03-27 11:39:41

    You can start mysql sleeping in the background before mysqld. Does this work for you?

    start_mysql {
        sleep 30
        mysql -u root -ppassword < /data/backups/backup.sql
        mysql -u root -ppassword < /sql-files/sql-files.sql
    }
    
    start_mysql &
    ./entrypoint.sh

    reply
    0
  • Cancelreply