-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add terraform modules Managed-clickhouse [Yandex Cloud]
- Loading branch information
1 parent
2c03c5f
commit 6535b5d
Showing
9 changed files
with
866 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Managed-clickhouse | ||
|
||
## Introduction | ||
|
||
This is a set of terraform modules for the Yandex Cloud provider for building a Managed clickhouse and creating any different clickhouse resources | ||
|
||
## Modules | ||
|
||
| Modules | Settings | Resources | Description | | ||
| --- | --- | --- | --- | | ||
| `managed-clickhouse` |[managed-clickhouse](managed-clickhouse/README.md)| - yandex_mdb_clickhouse_cluster<br> - random_password | Managed-clickhouse settings | |
284 changes: 284 additions & 0 deletions
284
YandexCloud/Managed-clickhouse/managed-clickhouse/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
378 changes: 378 additions & 0 deletions
378
YandexCloud/Managed-clickhouse/managed-clickhouse/cluster.tf
Large diffs are not rendered by default.
Oops, something went wrong.
155 changes: 155 additions & 0 deletions
155
YandexCloud/Managed-clickhouse/managed-clickhouse/docs/example/example.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
provider "yandex" { | ||
service_account_key_file = "key.json" | ||
cloud_id = YOUR_CLOUD_ID | ||
folder_id = YOUR_FOLDER_ID | ||
zone = "ru-central1-a" | ||
} | ||
|
||
terraform { | ||
backend "s3" { | ||
bucket = "name-your-bucket" | ||
key = "managed-clickhouse.tfstate" | ||
region = "ru-central1" | ||
endpoint = "https://storage.yandexcloud.net" | ||
shared_credentials_file = "storage-cred" | ||
|
||
skip_region_validation = true | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
} | ||
} | ||
|
||
data "terraform_remote_state" "vpc" { | ||
backend = "s3" | ||
config = { | ||
bucket = "name-your-bucket" | ||
key = "vpc.tfstate" | ||
region = "ru-central1" | ||
endpoint = "https://storage.yandexcloud.net" | ||
shared_credentials_file = "storage-cred" | ||
|
||
skip_region_validation = true | ||
skip_credentials_validation = true | ||
skip_metadata_api_check = true | ||
} | ||
} | ||
|
||
module "managed-clickhouse" { | ||
source = "github.com/nixys/nxs-marketplace-terraform/YandexCloud/Managed-clickhouse/managed-clickhouse" | ||
|
||
clusters = { | ||
name-your-clickhouse-cluster-1 = { | ||
network_id = data.terraform_remote_state.vpc.outputs.network_ids["name-your-network-1"] | ||
description = "Created by Terraform" | ||
deletion_protection = false | ||
maintenance_window_type = "WEEKLY" | ||
maintenance_window_day = "MON" | ||
maintenance_window_hour = 21 | ||
environment = "PRODUCTION" | ||
clickhouse_version = 23.8 | ||
resource_preset_id = "m2.micro" | ||
disk_type_id = "network-ssd" | ||
disk_size = "100" | ||
admin_password = "" | ||
service_account_id = "aje2dldasdasа5ubdd0k42" | ||
acess_data_lens = true | ||
cloud_storage_enable = true | ||
|
||
######### | ||
### config | ||
######### | ||
config_background_pool_size = 0 | ||
config_background_schedule_pool_size = 0 | ||
config_keep_alive_timeout = 3 | ||
config_log_level = "INFORMATION" | ||
config_mark_cache_size = 4294967296 | ||
config_max_concurrent_queries = 500 | ||
config_max_connections = 4096 | ||
config_metric_log_retention_time = 2592000000 | ||
config_part_log_retention_time = 2592000000 | ||
config_query_log_retention_time = 2592000000 | ||
config_query_thread_log_retention_time = 2592000000 | ||
config_text_log_enabled = false | ||
config_text_log_retention_time = 2592000000 | ||
config_timezone = "Europe/Moscow" | ||
config_trace_log_retention_time = 2592000000 | ||
config_uncompressed_cache_size = 0 | ||
######### | ||
### End Config | ||
######### | ||
|
||
compression = [ | ||
{ | ||
level = 0 | ||
method = "LZ4" | ||
min_part_size = 1024 | ||
min_part_size_ratio = 0.5 | ||
} | ||
] | ||
|
||
shard = [ | ||
{ | ||
name = "shard1" | ||
weight = 100 | ||
resources = [{ | ||
resource_preset_id = "m2.micro" | ||
disk_type_id = "network-ssd" | ||
disk_size = "100" | ||
}] | ||
}, | ||
{ | ||
name = "shard3" | ||
weight = 100 | ||
resources = [{ | ||
resource_preset_id = "m3-c2-m16" | ||
disk_type_id = "network-ssd" | ||
disk_size = "100" | ||
}] | ||
} | ||
] | ||
|
||
shard_group = [ | ||
{ | ||
name = "shardGroup1" | ||
description = "Created by Terraform" | ||
shard_names = ["shard3", ] | ||
} | ||
] | ||
|
||
clickhouse_hosts = [ | ||
{ | ||
type = "CLICKHOUSE" | ||
subnet_id = data.terraform_remote_state.vpc.outputs.subnet_ids["name-your-subnet-1"] | ||
zone = "ru-central1-a" | ||
shard_name = "shard1" | ||
}, | ||
{ | ||
type = "CLICKHOUSE" | ||
subnet_id = data.terraform_remote_state.vpc.outputs.subnet_ids["name-your-subnet-2"] | ||
zone = "ru-central1-b" | ||
shard_name = "shard3" | ||
} | ||
] | ||
|
||
database = [ | ||
{ | ||
name = "name-your-database-1" | ||
} | ||
] | ||
|
||
user = [ | ||
{ | ||
name = "name-your-user-1" | ||
permission = [{ | ||
database_name = "name-your-database-1" | ||
}] | ||
} | ||
] | ||
|
||
labels = { | ||
cluster = "name-your-clickhouse-cluster-1" | ||
} | ||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
YandexCloud/Managed-clickhouse/managed-clickhouse/docs/example/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= v1.0.0" | ||
|
||
required_providers { | ||
yandex = { | ||
source = "yandex-cloud/yandex" | ||
version = ">= 0.107.0" | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
YandexCloud/Managed-clickhouse/managed-clickhouse/password.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "random_password" "user_pass" { | ||
for_each = toset(flatten([ for k in var.clusters : [ for user in k.user : user.name ] ])) | ||
|
||
length = 16 | ||
special = true | ||
} | ||
|
||
resource "random_password" "admin_pass" { | ||
|
||
length = 16 | ||
special = true | ||
} |
5 changes: 5 additions & 0 deletions
5
YandexCloud/Managed-clickhouse/managed-clickhouse/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "clusters" { | ||
description = "Create Clickhouse cluster" | ||
type = any | ||
default = {} | ||
} |
10 changes: 10 additions & 0 deletions
10
YandexCloud/Managed-clickhouse/managed-clickhouse/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= v1.0.0" | ||
|
||
required_providers { | ||
yandex = { | ||
source = "yandex-cloud/yandex" | ||
version = ">= 0.107.0" | ||
} | ||
} | ||
} |