Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Neaj Morshad <[email protected]>
  • Loading branch information
Neaj-Morshad-101 committed May 30, 2024
1 parent 6822e60 commit 8634fe5
Show file tree
Hide file tree
Showing 23 changed files with 1,449 additions and 3,575 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
k8s.io/klog/v2 v2.120.1
kmodules.xyz/client-go v0.29.14
kmodules.xyz/custom-resources v0.29.1
kubedb.dev/apimachinery v0.45.2-0.20240529075634-bc0c0bab0034
kubedb.dev/apimachinery v0.45.2-0.20240530120824-5e6b27ed36e9
sigs.k8s.io/controller-runtime v0.17.4
xorm.io/xorm v1.3.6
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9
kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI=
kmodules.xyz/offshoot-api v0.29.2 h1:akXmvkNqFz1n9p1STVs9iP7ODYET0S7BhcYCMXEjK4A=
kmodules.xyz/offshoot-api v0.29.2/go.mod h1:Wv7Xo8wbvznI+8bhaylRFHFjkt30xRDOUOnqV8kOAxM=
kubedb.dev/apimachinery v0.45.2-0.20240529075634-bc0c0bab0034 h1:L3oGMZP6MscogD2z7LX9NIjuwd4vfAd8BOZ4OguaXg0=
kubedb.dev/apimachinery v0.45.2-0.20240529075634-bc0c0bab0034/go.mod h1:LBoGqbBHFeIRLv1KtkkmVxjK/g9CmQETVpwszFp9Ly0=
kubedb.dev/apimachinery v0.45.2-0.20240530120824-5e6b27ed36e9 h1:uidPG7sU5MT1sgKSgcyhK6H6Slyj+Y1gIqJRavST1UY=
kubedb.dev/apimachinery v0.45.2-0.20240530120824-5e6b27ed36e9/go.mod h1:LBoGqbBHFeIRLv1KtkkmVxjK/g9CmQETVpwszFp9Ly0=
kubeops.dev/petset v0.0.5 h1:VVXi39JhjondlbHyZ98z0MLp6VCmiCMinL59K48Y2zA=
kubeops.dev/petset v0.0.5/go.mod h1:ijtKT1HlAht2vBEZj5LW7C00XEs3B0d1VdCQgd5V4cA=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const (

KubeDBOrganization = "kubedb"

LabelRole = kubedb.GroupName + "/role"
LabelRole = kubedb.GroupName + "/role"
LabelPetSet = kubedb.GroupName + "/petset"

ReplicationModeDetectorContainerName = "replication-mode-detector"
DatabasePodPrimary = "primary"
Expand Down Expand Up @@ -124,10 +125,13 @@ const (
ElasticsearchMinHeapSize = 128 * 1024 * 1024

// =========================== Memcached Constants ============================
MemcachedConfigKey = "memcached.conf" // MemcachedConfigKey is going to create for the customize redis configuration
MemcachedDatabasePortName = "db"
MemcachedPrimaryServicePortName = "primary"
MemcachedDatabasePort = 11211
MemcachedShardKey = MemcachedKey + "/shard"
MemcachedContainerName = ResourceSingularMemcached
MemcachedConfigVolumePath = "/etc/memcached/"
// =========================== MongoDB Constants ============================

MongoDBDatabasePortName = "db"
Expand Down Expand Up @@ -339,6 +343,7 @@ const (
DatabasePodLeaf = "Leaf"
PetSetTypeAggregator = "aggregator"
PetSetTypeLeaf = "leaf"
PetSetTypeStandalone = "standalone"

SinglestoreDatabaseHealth = "singlestore_health"
SinglestoreTableHealth = "singlestore_health_table"
Expand All @@ -350,7 +355,7 @@ const (
SinglestoreVolumeNameUserInitScript = "initial-script"
SinglestoreVolumeMountPathUserInitScript = "/docker-entrypoint-initdb.d"
SinglestoreVolumeNameCustomConfig = "custom-config"
SinglestoreVolumeMountPathCustomConfig = "/config"
SinglestoreVolumeMountPathCustomConfig = "/etc/memsql/conf.d"
SinglestoreVolmeNameInitScript = "init-scripts"
SinglestoreVolumeMountPathInitScript = "/scripts"
SinglestoreVolumeNameData = "data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
"github.com/Masterminds/semver/v3"
promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"gomodules.xyz/pointer"
core "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -176,12 +178,44 @@ func (d *Druid) PetSetName(nodeRole DruidNodeRoleType) string {
return meta_util.NameWithSuffix(d.OffShootName(), d.DruidNodeRoleString(nodeRole))
}

func (d *Druid) PodLabels(extraLebels ...map[string]string) map[string]string {
return d.offShootLabels(meta_util.OverwriteKeys(d.OffShootSelectors(), extraLebels...), d.Spec.PodTemplate.Labels)
func (d *Druid) PodLabels(nodeType DruidNodeRoleType, extraLabels ...map[string]string) map[string]string {
nodeSpec, dataNodeSpec := d.GetNodeSpec(nodeType)
var labels map[string]string
if nodeSpec != nil {
labels = nodeSpec.PodTemplate.Labels
} else {
labels = dataNodeSpec.PodTemplate.Labels
}
return d.offShootLabels(meta_util.OverwriteKeys(d.OffShootSelectors(), extraLabels...), labels)
}

func (d *Druid) PodControllerLabels(extraLabels ...map[string]string) map[string]string {
return d.offShootLabels(meta_util.OverwriteKeys(d.OffShootSelectors(), extraLabels...), d.Spec.PodTemplate.Controller.Labels)
func (d *Druid) PodControllerLabels(nodeType DruidNodeRoleType, extraLabels ...map[string]string) map[string]string {
nodeSpec, dataNodeSpec := d.GetNodeSpec(nodeType)
var labels map[string]string
if nodeSpec != nil {
labels = nodeSpec.PodTemplate.Controller.Labels
} else {
labels = dataNodeSpec.PodTemplate.Controller.Labels
}
return d.offShootLabels(meta_util.OverwriteKeys(d.OffShootSelectors(), extraLabels...), labels)
}

func (d *Druid) GetNodeSpec(nodeType DruidNodeRoleType) (*DruidNode, *DruidDataNode) {
if nodeType == DruidNodeRoleCoordinators {
return d.Spec.Topology.Coordinators, nil
} else if nodeType == DruidNodeRoleOverlords {
return d.Spec.Topology.Overlords, nil
} else if nodeType == DruidNodeRoleMiddleManagers {
return nil, d.Spec.Topology.MiddleManagers
} else if nodeType == DruidNodeRoleHistoricals {
return nil, d.Spec.Topology.Historicals
} else if nodeType == DruidNodeRoleBrokers {
return d.Spec.Topology.Brokers, nil
} else if nodeType == DruidNodeRoleRouters {
return d.Spec.Topology.Routers, nil
}

panic("Node role name does not match any known types")
}

func (d *Druid) ServiceAccountName() string {
Expand Down Expand Up @@ -339,10 +373,6 @@ func (d *Druid) SetDefaults() {
d.Spec.TerminationPolicy = TerminationPolicyDelete
}

if d.Spec.StorageType == "" {
d.Spec.StorageType = StorageTypeDurable
}

if d.Spec.DisableSecurity == nil {
d.Spec.DisableSecurity = pointer.BoolP(false)
}
Expand Down Expand Up @@ -371,6 +401,9 @@ func (d *Druid) SetDefaults() {
}

if d.Spec.Topology != nil {
if d.Spec.Topology.Coordinators == nil {
d.Spec.Topology.Coordinators = &DruidNode{}
}
if d.Spec.Topology.Coordinators != nil {
if d.Spec.Topology.Coordinators.Replicas == nil {
d.Spec.Topology.Coordinators.Replicas = pointer.Int32P(1)
Expand All @@ -383,6 +416,7 @@ func (d *Druid) SetDefaults() {
d.setDefaultContainerResourceLimits(&d.Spec.Topology.Coordinators.PodTemplate, DruidNodeRoleCoordinators)
}
}

if d.Spec.Topology.Overlords != nil {
if d.Spec.Topology.Overlords.Replicas == nil {
d.Spec.Topology.Overlords.Replicas = pointer.Int32P(1)
Expand All @@ -395,10 +429,20 @@ func (d *Druid) SetDefaults() {
d.setDefaultContainerResourceLimits(&d.Spec.Topology.Overlords.PodTemplate, DruidNodeRoleOverlords)
}
}

if d.Spec.Topology.MiddleManagers == nil {
d.Spec.Topology.MiddleManagers = &DruidDataNode{}
}
if d.Spec.Topology.MiddleManagers != nil {
if d.Spec.Topology.MiddleManagers.Replicas == nil {
d.Spec.Topology.MiddleManagers.Replicas = pointer.Int32P(1)
}
if d.Spec.Topology.MiddleManagers.StorageType == "" {
d.Spec.Topology.MiddleManagers.StorageType = StorageTypeDurable
}
if d.Spec.Topology.MiddleManagers.Storage == nil && d.Spec.Topology.MiddleManagers.StorageType == StorageTypeDurable {
d.Spec.Topology.MiddleManagers.Storage = d.getDefaultPVC()
}
if version.Major() > 25 {
if d.Spec.Topology.MiddleManagers.PodTemplate.Spec.SecurityContext == nil {
d.Spec.Topology.MiddleManagers.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser}
Expand All @@ -407,10 +451,20 @@ func (d *Druid) SetDefaults() {
d.setDefaultContainerResourceLimits(&d.Spec.Topology.MiddleManagers.PodTemplate, DruidNodeRoleMiddleManagers)
}
}

if d.Spec.Topology.Historicals == nil {
d.Spec.Topology.Historicals = &DruidDataNode{}
}
if d.Spec.Topology.Historicals != nil {
if d.Spec.Topology.Historicals.Replicas == nil {
d.Spec.Topology.Historicals.Replicas = pointer.Int32P(1)
}
if d.Spec.Topology.Historicals.StorageType == "" {
d.Spec.Topology.Historicals.StorageType = StorageTypeDurable
}
if d.Spec.Topology.Historicals.Storage == nil && d.Spec.Topology.Historicals.StorageType == StorageTypeDurable {
d.Spec.Topology.Historicals.Storage = d.getDefaultPVC()
}
if version.Major() > 25 {
if d.Spec.Topology.Historicals.PodTemplate.Spec.SecurityContext == nil {
d.Spec.Topology.Historicals.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{FSGroup: druidVersion.Spec.SecurityContext.RunAsUser}
Expand All @@ -419,6 +473,10 @@ func (d *Druid) SetDefaults() {
d.setDefaultContainerResourceLimits(&d.Spec.Topology.Historicals.PodTemplate, DruidNodeRoleHistoricals)
}
}

if d.Spec.Topology.Brokers == nil {
d.Spec.Topology.Brokers = &DruidNode{}
}
if d.Spec.Topology.Brokers != nil {
if d.Spec.Topology.Brokers.Replicas == nil {
d.Spec.Topology.Brokers.Replicas = pointer.Int32P(1)
Expand All @@ -432,6 +490,7 @@ func (d *Druid) SetDefaults() {

}
}

if d.Spec.Topology.Routers != nil {
if d.Spec.Topology.Routers.Replicas == nil {
d.Spec.Topology.Routers.Replicas = pointer.Int32P(1)
Expand Down Expand Up @@ -461,6 +520,16 @@ func (d *Druid) SetDefaults() {
}
}

func (d *Druid) getDefaultPVC() *core.PersistentVolumeClaimSpec {
return &core.PersistentVolumeClaimSpec{
Resources: core.VolumeResourceRequirements{
Requests: core.ResourceList{
core.ResourceStorage: resource.MustParse("1Gi"),
},
},
}
}

func (d *Druid) setDefaultContainerSecurityContext(druidVersion *catalog.DruidVersion, podTemplate *ofst.PodTemplateSpec) {
container := coreutil.GetContainerByName(podTemplate.Spec.Containers, DruidContainerName)
if container == nil {
Expand Down
37 changes: 21 additions & 16 deletions vendor/kubedb.dev/apimachinery/apis/kubedb/v1alpha2/druid_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ type DruidSpec struct {
// +optional
Topology *DruidClusterTopology `json:"topology,omitempty"`

// StorageType can be durable (default) or ephemeral.
StorageType StorageType `json:"storageType,omitempty"`

// disable security. It disables authentication security of user.
// If unset, default is false
// +optional
Expand Down Expand Up @@ -95,10 +92,6 @@ type DruidSpec struct {
// +optional
ZookeeperRef *ZookeeperRef `json:"zookeeperRef,omitempty"`

// PodTemplate is an optional configuration
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`

// ServiceTemplates is an optional configuration for services used to expose database
// +optional
ServiceTemplates []NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"`
Expand All @@ -122,32 +115,29 @@ type DruidSpec struct {
}

type DruidClusterTopology struct {
Coordinators *DruidNode `json:"coordinators"`
Coordinators *DruidNode `json:"coordinators,omitempty"`
// +optional
Overlords *DruidNode `json:"overlords,omitempty"`

MiddleManagers *DruidNode `json:"middleManagers"`
MiddleManagers *DruidDataNode `json:"middleManagers,omitempty"`

Historicals *DruidNode `json:"historicals"`
Historicals *DruidDataNode `json:"historicals,omitempty"`

Brokers *DruidNode `json:"brokers"`
Brokers *DruidNode `json:"brokers,omitempty"`
// +optional
Routers *DruidNode `json:"routers,omitempty"`
}

type DruidNode struct {
// Replicas represents number of replica for the specific type of node
// Replicas represents number of replicas for the specific type of node
// +kubebuilder:default=1
// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Suffix to append with node name
// +optional
Suffix string `json:"suffix,omitempty"`

// Storage to specify how storage shall be used.
// +optional
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`

// PodTemplate is an optional configuration for pods used to expose database
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`
Expand All @@ -168,6 +158,21 @@ type DruidNode struct {
PodPlacementPolicy *core.LocalObjectReference `json:"podPlacementPolicy,omitempty"`
}

type DruidDataNode struct {
// DruidDataNode has all the characteristics of DruidNode
DruidNode `json:",inline"`

// StorageType specifies if the storage
// of this node is durable (default) or ephemeral.
StorageType StorageType `json:"storageType,omitempty"`

// Storage to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`

// EphemeralStorage spec to specify the configuration of ephemeral storage type.
EphemeralStorage *core.EmptyDirVolumeSource `json:"ephemeralStorage,omitempty"`
}

type MetadataStorage struct {
// Name of the appbinding of zookeeper
// +optional
Expand Down
Loading

0 comments on commit 8634fe5

Please sign in to comment.