Skip to content

MariaDB Database Module

This module contains a MariaDB instance, located in the mariadb key.

The following snippets lists all available configuration options alongside their default values:

(import 'cloudflight-libsonnet/databases/mariadb.libsonnet')
+ {
  _config+: {
        mariadb: {
          name: 'mariadb',
          storage: '5Gi',
          user: error 'cfg.user must be defined',
          password: error 'cfg.password must be defined',
          database: self.user,
          image: 'registry.redhat.io/rhel9/mariadb-105:1-105',
          datadirAction: 'upgrade-warn',  // use 'upgrade-auto' to enable auto-upgrade when going to newer MariaDB version
          exporterImage: 'docker.io/prom/mysqld-exporter:v0.15.1',
          exporterPassword: std.md5(self.password),
          resources:: {
            limits: {
              cpu: '500m',
              memory: '1Gi',
            },
            requests: {
              cpu: '200m',
              memory: '1Gi',
            },
          },
        },

  }
}

Exposed values

The following values are exposed, but not exported:

Name Contents
mariadb.passwordSecretKeyRef A kubernetes secretKeyRef, referencing the user password

Starting multiple instances

Another way to use this module, is by calling the newMariaDB function. This allows you to create multiple instances without polluting the global scope.

{
  _config+:: {
    dbOne: {
      name: 'dbOne',
      user: 'foo',
      password: 'bar',
    },
    dbTwo: {
      name: 'dbTwo',
      user: 'foo',
      password: 'bar',
    }
  }
  dbOne: (import 'cloudflight-libsonnet/databases/mariadb.libsonnet').newMariaDB($._config.dbOne),
  dbTwo: (import 'cloudflight-libsonnet/databases/mariadb.libsonnet').newMariaDB($._config.dbTwo),
}