Skip to content

Commit

Permalink
Add MariaDB constants (#651)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Nov 11, 2020
1 parent 592d5b4 commit cb21bb0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
12 changes: 12 additions & 0 deletions apis/kubedb/v1alpha2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
PostgresKey = ResourceSingularPostgres + "." + kubedb.GroupName
ElasticsearchKey = ResourceSingularElasticsearch + "." + kubedb.GroupName
MySQLKey = ResourceSingularMySQL + "." + kubedb.GroupName
MariaDBKey = ResourceSingularMariaDB + "." + kubedb.GroupName
PerconaXtraDBKey = ResourceSingularPerconaXtraDB + "." + kubedb.GroupName
MongoDBKey = ResourceSingularMongoDB + "." + kubedb.GroupName
RedisKey = ResourceSingularRedis + "." + kubedb.GroupName
Expand Down Expand Up @@ -149,6 +150,17 @@ const (
PerconaXtraDBCustomConfigMountPath = "/etc/percona-server.conf.d/"
PerconaXtraDBClusterCustomConfigMountPath = "/etc/percona-xtradb-cluster.conf.d/"

// =========================== MariaDB Constants ============================
MariaDBClusterRecommendedVersion = "5.7"
MariaDBMaxClusterNameLength = 32
MariaDBStandaloneReplicas = 1
MariaDBDefaultClusterSize = 3
MariaDBDataMountPath = "/var/lib/mysql"
MariaDBDataLostFoundPath = MariaDBDataMountPath + "lost+found"
MariaDBInitDBMountPath = "/docker-entrypoint-initdb.d"
MariaDBCustomConfigMountPath = "/etc/percona-server.conf.d/"
MariaDBClusterCustomConfigMountPath = "/etc/percona-xtradb-cluster.conf.d/"

// =========================== PostgreSQL Constants ============================
PostgresDatabasePortName = "db"
PostgresPrimaryServicePortName = "primary"
Expand Down
23 changes: 21 additions & 2 deletions apis/kubedb/v1alpha2/mariadb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,26 @@ func (m MariaDB) ServiceName() string {
return m.OffshootName()
}

func (m MariaDB) IsCluster() bool {
return pointer.Int32(m.Spec.Replicas) > 1
}

func (m MariaDB) GoverningServiceName() string {
return meta_util.NameWithSuffix(m.ServiceName(), "pods")
}

func (m MariaDB) PeerName(idx int) string {
return fmt.Sprintf("%s-%d.%s.%s", m.OffshootName(), idx, m.GoverningServiceName(), m.Namespace)
}

func (m MariaDB) GetAuthSecretName() string {
return m.Spec.AuthSecret.Name
}

func (m MariaDB) ClusterName() string {
return m.OffshootName()
}

type mariadbApp struct {
*MariaDB
}
Expand Down Expand Up @@ -140,23 +156,26 @@ func (m *MariaDB) SetDefaults() {
if m == nil {
return
}

if m.Spec.Replicas == nil {
m.Spec.Replicas = pointer.Int32P(1)
}

// perform defaulting

if m.Spec.StorageType == "" {
m.Spec.StorageType = StorageTypeDurable
}
if m.Spec.TerminationPolicy == "" {
m.Spec.TerminationPolicy = TerminationPolicyDelete
}

m.Spec.setDefaultProbes()
m.Spec.Monitor.SetDefaults()
setDefaultResourceLimits(&m.Spec.PodTemplate.Spec.Resources)
}

func (m *MariaDBSpec) setDefaultProbes() {
}

func (m *MariaDBSpec) GetPersistentSecrets() []string {
if m == nil {
return nil
Expand Down

0 comments on commit cb21bb0

Please sign in to comment.