Skip to content

Commit

Permalink
Update KubeDB api (#550)
Browse files Browse the repository at this point in the history
Signed-off-by: 1gtm <[email protected]>
  • Loading branch information
1gtm authored Nov 12, 2020
1 parent df75044 commit 7152cf5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
kmodules.xyz/custom-resources v0.0.0-20201105075444-3c6af51b4f79
kmodules.xyz/monitoring-agent-api v0.0.0-20201105074044-be7a1044891a
kmodules.xyz/objectstore-api v0.0.0-20201105133858-cbb2af88d50a
kubedb.dev/apimachinery v0.15.0
kubedb.dev/apimachinery v0.15.1-0.20201111204019-44d1f43bc6dd
stash.appscode.dev/apimachinery v0.11.6
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1394,8 +1394,8 @@ kmodules.xyz/openshift v0.0.0-20201105073146-0da509a7d39f/go.mod h1:vFwB/f5rVH5Q
kmodules.xyz/prober v0.0.0-20201105074402-a243b3a27fd8 h1:UJb5lHQVFKbmlgmRLq5IWJGtz3JqYYbyVG+dNdjC9Cc=
kmodules.xyz/prober v0.0.0-20201105074402-a243b3a27fd8/go.mod h1:2eN8X5Wq7/AAgE5AWMAX8T0lE51HZiYEldG2RQuouX4=
kmodules.xyz/webhook-runtime v0.0.0-20201105073856-2dc7382b88c6/go.mod h1:xLgewoOzwR5ZrVOHQ2SR0P4E7tgCyBWbYlUawEXgeF4=
kubedb.dev/apimachinery v0.15.0 h1:xgGEXoAZEZnyDzl9lnyJwg5jneUBIXfNMKq92Mv9LZw=
kubedb.dev/apimachinery v0.15.0/go.mod h1:4H3J+V7lZy8dLgz0+z/Nzd13cEgZHnwbMaH729rxl/M=
kubedb.dev/apimachinery v0.15.1-0.20201111204019-44d1f43bc6dd h1:Nnm0UEdGAeiSCO0HSJyDfGT3CuHRpiukNTyyf0Fl7pI=
kubedb.dev/apimachinery v0.15.1-0.20201111204019-44d1f43bc6dd/go.mod h1:4H3J+V7lZy8dLgz0+z/Nzd13cEgZHnwbMaH729rxl/M=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
Expand Down
12 changes: 12 additions & 0 deletions vendor/kubedb.dev/apimachinery/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
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
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ kmodules.xyz/objectstore-api/api/v1
kmodules.xyz/offshoot-api/api/v1
# kmodules.xyz/prober v0.0.0-20201105074402-a243b3a27fd8
kmodules.xyz/prober/api/v1
# kubedb.dev/apimachinery v0.15.0
# kubedb.dev/apimachinery v0.15.1-0.20201111204019-44d1f43bc6dd
kubedb.dev/apimachinery/apis
kubedb.dev/apimachinery/apis/autoscaling
kubedb.dev/apimachinery/apis/autoscaling/v1alpha1
Expand Down

0 comments on commit 7152cf5

Please sign in to comment.