Configuring the MySQL-database

To install a MySQL database with the gerrit-master chart, set mysql.enabledto true in the values.yaml. This will then install the mysql chart onto the Kubernetes cluster as a dependency.

Create certificates for SSL-encrypted communication

For SSL-encrypted communication, a set of certificates is needed. Use the following commands to create them after adjusting the subject strings:

openssl genrsa -out ./ca.key.pem 4096

openssl req \
    -key ./ca.key.pem \
    -new \
    -x509 \
    -days 7300 \
    -sha256 \
    -out ./ca.cert.pem \
    -subj "/C=DE/O=Gerrit/CN=gerrit-db-master" \
    -nodes

openssl genrsa -out ./master.key.pem 4096

openssl req \
    -key ./master.key.pem \
    -new \
    -sha256 \
    -out ./master.csr.pem \
    -subj "/C=DE/O=Gerrit/CN=gerrit-db-master" \
    -nodes

openssl x509 \
    -req \
    -CA ./ca.cert.pem \
    -CAkey ./ca.key.pem \
    -CAcreateserial \
    -in ./master.csr.pem \
    -out ./master.cert.pem

Configuration

mysql-chart

The configuration of the database is done in the values.yamlof the gerrit-master chart under the mysql-key. The complete list of options for the mysql-chart can be viewed in the chart‘s documentation. The options referenced in the gerrit-master chart’s values.yaml are listed here:

ParameterDescriptionDefault
mysql.enabledWhether to install the MySQL databasetrue
mysql.imageWhich container image containing MySQL to usemysql
mysql.imageTagTag of container image (usually the database version)5.5.61
mysql.mysqlRootPasswordPassword of the database root userbig_secret
mysql.mysqlUserDatabase user (The technical user used by Gerrit)gerrit
mysql.mysqlPasswordPassword of the database usersecret
mysql.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated30
mysql.livenessProbe.periodSecondsHow often to perform the probe10
mysql.livenessProbe.timeoutSecondsWhen the probe times out5
mysql.livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
mysql.livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
mysql.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated5
mysql.readinessProbe.periodSecondsHow often to perform the probe10
mysql.readinessProbe.timeoutSecondsWhen the probe times out1
mysql.readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
mysql.readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
mysql.persistence.enabledCreate a volume to store datatrue
mysql.persistence.sizeSize of persistent volume claim8Gi
mysql.persistence.storageClassType of persistent volume claimdefault
mysql.persistence.accessModeReadWriteOnce or ReadOnlyReadWriteOnce
mysql.resourcesConfigure the amount of resources the pod requests/is allowedrequests.cpu: 250m
requests.memory: 1Gi
limits.cpu: 250m
limits.memory: 1Gi
mysql.configurationFilesAdd configuration files for MySQLmysql.cnf (check the mysql.cnf-section for configuration options)
mysql.initializationFilesAdd scripts that are executed, when the database is started the first timeinitialize_reviewdb.sql (Should not be changed)
mysql.service.typeType of the Service used to expose the databaseNodePort
mysql.service.portThe port used to expose the database3306
ssl.enabledSetup and use SSL for MySQL connectionsfalse
ssl.secretName of the secret containing the SSL certificatesmaster-ssl-certs
ssl.certificates[0].nameName of the secret containing the SSL certificatesmaster-ssl-certs
ssl.certificates[0].caCA certificate (if using replication use the CA created peviously)-----BEGIN CERTIFICATE-----
ssl.certificates[0].certServer certificate (public key) (if using replication use the certificate created peviously)-----BEGIN CERTIFICATE-----
ssl.certificates[0].keyServer key (private key) (if using replication use the key created peviously)-----BEGIN RSA PRIVATE KEY-----

mysql.cnf

The configuration file for the MySQL-server is provided under the key mysql.configurationsFiles.mysql.cnf. The provided values provide necessary configuration to receive replicated databases from the master database.

Some options should be adapted to the respective setup:

ParameterDescriptionDefault
log_binName of transaction logs (used for database replication)mysql-bin
binlog_formatFormat of the binlogs (Has to be the same as on master)row
server-idID unique in the MySQL setup42

In addition, if using SSL for MySQL-requests the following options have to be made available by uncommenting them. The values must not be changed, when using the chart:

ssl-ca=/ssl/ca.pem
ssl-cert=/ssl/server-cert.pem
ssl-key=/ssl/server-key.pem