Skip to content

Commit

Permalink
Add Support for ClickHouse Custom Config (#1299)
Browse files Browse the repository at this point in the history
Signed-off-by: SK Ali Arman <arman@appscode.com>
  • Loading branch information
sheikh-arman authored Sep 24, 2024
1 parent 8657958 commit 027fb90
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
14 changes: 8 additions & 6 deletions apis/kubedb/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ const (
ClickHouseDefaultStorageSize = "2Gi"

ClickHouseClusterConfigVolName = "cluster-config"
ClickHouseClusterConfigDir = "/etc/clickhouse-server/conf.d"
ClickHouseCommonConfigDir = "/etc/clickhouse-server/conf.d"

ClickHouseClusterTempConfigVolName = "temp-cluster-config"

Expand All @@ -1364,17 +1364,19 @@ const (
ClickHouseHealthCheckerDatabase = "kubedb_system"
ClickHouseHealthCheckerTable = "kubedb_write_check"

ClickHouseServerConfigFile = "server-config.yaml"
ClickHouseKeeperFileConfig = "keeper_config.yaml"
ClickHouseServerConfigFile = "server-config.yaml"
ClickHouseKeeperFileConfig = "keeper_config.yaml"
ClickHouseVolumeCustomConfig = "custom-config"

// keeper
ClickHouseKeeperContainerName = "clickhouse-keeper"
ClickHouseKeeeprConfigFileName = "keeper_config.xml"
ClickHOuseKeeeprConfigFileVolumeName = "keeper-config"
ClickHouseKeeperInitContainerName = "clickhouse-keeper-init"

ClickHouseKeeperConfig = "etc-clickhouse-keeper"
ClickHouseKeeperConfigPath = "/etc/clickhouse-keeper"
ClickHouseKeeperConfig = "etc-clickhouse-keeper"
ClickHouseInternalServerListFile = "server_list.yaml"
ClickHouseKeeperServerIdNo = "serverid"
ClickHouseKeeperServerID = "KEEPERID"
)

// =========================== Cassandra Constants ============================
Expand Down
4 changes: 2 additions & 2 deletions apis/kubedb/v1alpha2/clickhouse_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (c *ClickHouse) GetInternalAuthTokenName() string {
}

func (c *ClickHouse) PVCName(alias string) string {
return meta_util.NameWithSuffix(c.Name, alias)
return alias
}

func (c *ClickHouse) PetSetName() string {
Expand Down Expand Up @@ -299,7 +299,6 @@ func (c *ClickHouse) SetDefaults() {
clusters[index] = cluster
}
c.Spec.ClusterTopology.Cluster = clusters

if c.Spec.ClusterTopology.ClickHouseKeeper != nil && !c.Spec.ClusterTopology.ClickHouseKeeper.ExternallyManaged && c.Spec.ClusterTopology.ClickHouseKeeper.Spec != nil {
if c.Spec.ClusterTopology.ClickHouseKeeper.Spec.Replicas == nil {
c.Spec.ClusterTopology.ClickHouseKeeper.Spec.Replicas = pointer.Int32P(1)
Expand All @@ -318,6 +317,7 @@ func (c *ClickHouse) SetDefaults() {
apis.SetDefaultResourceLimits(&dbContainer.Resources, kubedb.DefaultResources)
}
}

} else {
if c.Spec.Replicas == nil {
c.Spec.Replicas = pointer.Int32P(1)
Expand Down
9 changes: 9 additions & 0 deletions apis/kubedb/v1alpha2/clickhouse_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ type ClickHouseSpec struct {
// +optional
AuthSecret *SecretReference `json:"authSecret,omitempty"`

// ConfigSecret is an optional field to provide custom configuration file for database (i.e config.properties).
// If specified, this file will be used as configuration file otherwise default configuration file will be used.
// +optional
ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"`

// PodTemplate is an optional configuration for pods used to expose database
// +optional
PodTemplate *ofst.PodTemplateSpec `json:"podTemplate,omitempty"`
Expand All @@ -85,6 +90,10 @@ type ClickHouseSpec struct {
// +optional
ServiceTemplates []NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"`

// Indicates that the database is halted and all offshoot Kubernetes resources except PVCs are deleted.
// +optional
Halted bool `json:"halted,omitempty"`

// DeletionPolicy controls the delete operation for database
// +optional
DeletionPolicy TerminationPolicy `json:"deletionPolicy,omitempty"`
Expand Down
15 changes: 14 additions & 1 deletion apis/kubedb/v1alpha2/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apis/kubedb/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions crds/kubedb.com_clickhouses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6404,6 +6404,13 @@ spec:
type: object
type: array
type: object
configSecret:
properties:
name:
default: ""
type: string
type: object
x-kubernetes-map-type: atomic
deletionPolicy:
enum:
- Halt
Expand All @@ -6413,6 +6420,8 @@ spec:
type: string
disableSecurity:
type: boolean
halted:
type: boolean
healthChecker:
default:
failureThreshold: 3
Expand Down

0 comments on commit 027fb90

Please sign in to comment.