Skip to content

Commit

Permalink
Add ClickHouse Keeper Api (#1278)
Browse files Browse the repository at this point in the history
* Add ClickHouse Keeper Api

Signed-off-by: SK Ali Arman <arman@appscode.com>

* rebase

Signed-off-by: SK Ali Arman <arman@appscode.com>

* update petset replica count for internally managed ch-keeper

Signed-off-by: SK Ali Arman <arman@appscode.com>

* validate clickhouse keeper

Signed-off-by: SK Ali Arman <arman@appscode.com>

* refactor

Signed-off-by: SK Ali Arman <arman@appscode.com>

* refactor

Signed-off-by: SK Ali Arman <arman@appscode.com>

* update webhook for keeper

Signed-off-by: SK Ali Arman <arman@appscode.com>

* update constrants

Signed-off-by: SK Ali Arman <arman@appscode.com>

* add clickhouse default resource

Signed-off-by: SK Ali Arman <arman@appscode.com>

* merge with master

Signed-off-by: SK Ali Arman <arman@appscode.com>

* Change configPath and keeper path

Signed-off-by: SK Ali Arman <arman@appscode.com>

* resolve comments

Signed-off-by: SK Ali Arman <arman@appscode.com>

---------

Signed-off-by: SK Ali Arman <arman@appscode.com>
  • Loading branch information
sheikh-arman authored Sep 24, 2024
1 parent 9349421 commit 2c9d395
Show file tree
Hide file tree
Showing 11 changed files with 3,588 additions and 37 deletions.
8 changes: 8 additions & 0 deletions apis/catalog/v1alpha1/clickhouse_version_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type ClickHouseVersionSpec struct {
// Database Image
InitContainer ClickHouseInitContainer `json:"initContainer"`

// ClickHouse Keeper Image
ClickHouseKeeper ClickHouseKeeperContainer `json:"clickHouseKeeper"`

// SecurityContext is for the additional config for the DB container
// +optional
SecurityContext SecurityContext `json:"securityContext"`
Expand All @@ -81,6 +84,11 @@ type ClickHouseInitContainer struct {
Image string `json:"image"`
}

// ClickHouseKeeperContainer is the ClickHouse keeper Container image
type ClickHouseKeeperContainer struct {
Image string `json:"image"`
}

// ClickHouseVersionStatus defines the observed state of ClickHouseVersion
type ClickHouseVersionStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down
33 changes: 31 additions & 2 deletions apis/catalog/v1alpha1/openapi_generated.go

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

17 changes: 17 additions & 0 deletions apis/catalog/v1alpha1/zz_generated.deepcopy.go

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

55 changes: 42 additions & 13 deletions apis/kubedb/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,36 +1326,55 @@ const (
ClickHouseNativeTCP = 9000
ClickHouseNativeTLS = 9440
ClickhousePromethues = 9363
ClickHouseRaftPort = 9234

ClickHouseVolumeData = "data"
ClickHouseDataDir = "/var/lib/clickhouse"
ClickHouseConfigVolName = "clickhouse-config"
ClickHouseConfigDir = "/etc/clickhouse-server/config.d"
ClickHouseDefaultStorageSize = "2Gi"
ComponentCoOrdinator = "co-ordinator"

ClickHouseVolumeData = "data"
ClickHouseDataDir = "/var/lib/clickhouse"
ClickHouseKeeperDataDir = "/var/lib/clickhouse_keeper"
ClickHouseConfigVolumeName = "clickhouse-config"
ClickHouseKeeperConfigVolumeName = "clickhouse-keeper-config"
ClickHouseInternalKeeperConfigVolumeName = "clickhouse-internal-keeper-config"
ClickHouseConfigDir = "/etc/clickhouse-server/config.d"
ClickHouseKeeperConfigDir = "/etc/clickhouse-keeper"
ClickHouseDefaultStorageSize = "2Gi"

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

ClickHouseTempClusterConfigVolName = "temp-cluster-config"
ClickHouseClusterTempConfigVolName = "temp-cluster-config"

ClickHouseContainerName = "clickhouse"

ClickHouseContainerName = "clickhouse"
ClickHouseInitContainerName = "clickhouse-init"

ClickHouseClusterConfigFile = "cluster-config.yaml"
ClickHouseTempConfigDir = "/ch-tmp/config"
ClickHouseTempDir = "/ch-tmp"
ClickHouseClusterConfigFile = "cluster-config.yaml"
ClickHouseTempConfigDir = "/ch-tmp"
ClickHouseInternalKeeperTempConfigDir = "/keeper"
ClickHouseTempDir = "/ch-tmp"
ClickHouseKeeperTempDir = "/ch-tmp"

ClickHouseUserConfigDir = "/etc/clickhouse-server/user.d"
ClickHouseMacrosFileName = "macros.yaml"

ClickHouseStandalone = "standalone"
ClickHouseCluster = "cluster"

ClickHouseHealthCheckerDatabase = "kubedb_system_db"
ClickHouseHealthCheckerTable = "kubedb_system_table"
ClickHouseHealthCheckerDatabase = "kubedb_system"
ClickHouseHealthCheckerTable = "kubedb_write_check"

ClickHouseServerConfigFile = "server-config.yaml"
ClickHouseKeeperFileConfig = "keeper-config.yaml"
ClickHouseKeeperFileConfig = "keeper_config.yaml"

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

ClickHouseKeeperConfig = "etc-clickhouse-keeper"
ClickHouseKeeperConfigPath = "/etc/clickhouse-keeper"
)

// =========================== Cassandra Constants ============================
Expand Down Expand Up @@ -1452,6 +1471,16 @@ var (
core.ResourceMemory: resource.MustParse("1024Mi"),
},
}
// ref: https://clickhouse.com/docs/en/guides/sizing-and-hardware-recommendations#what-should-cpu-utilization-be
ClickHouseDefaultResources = core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceCPU: resource.MustParse("1"),
core.ResourceMemory: resource.MustParse("4Gi"),
},
Limits: core.ResourceList{
core.ResourceMemory: resource.MustParse("4Gi"),
},
}
// CoordinatorDefaultResources must be used for raft backed coordinators to avoid unintended leader switches
CoordinatorDefaultResources = core.ResourceRequirements{
Requests: core.ResourceList{
Expand Down
Loading

0 comments on commit 2c9d395

Please sign in to comment.