feat: IoT demo final — 6 services (Kafka+Redis+MongoDB+2Flask+NodeJS), removed broken CH/Superset/AKHQ

This commit is contained in:
“Naeel”
2026-07-21 18:32:35 +04:00
parent 55d4109eee
commit 0adb379a54
6 changed files with 129 additions and 117 deletions
+15 -10
View File
@@ -1,5 +1,5 @@
# =============================================================================
# Flask Consumer — читает Kafka, пишет в ClickHouse
# Flask Consumer — читает Kafka, пишет в Redis + MongoDB
# =============================================================================
locals {
consumer_kafka_secrets = jsondecode(nubes_kafka.main.vault_secrets["users"])
@@ -8,9 +8,14 @@ locals {
consumer_kafka_ca_crt = try(nonsensitive(local.consumer_kafka_secrets["ca"]["ca.crt"]), "")
consumer_kafka_user_crt = try(nonsensitive(local.consumer_kafka_secrets["iot-app"]["user.crt"]), "")
consumer_kafka_user_key = try(nonsensitive(local.consumer_kafka_secrets["iot-app"]["user.key"]), "")
consumer_ch_secrets = try(jsondecode(nubes_clickhouse.main.vault_secrets["users"]), tomap({}))
consumer_ch_host = try(nubes_clickhouse.main.state_out_flat["internalMaster"], "")
consumer_ch_password = try(nonsensitive(lookup(local.consumer_ch_secrets, "iot_writer", tomap({})).password), "")
consumer_redis_host = try(nubes_redis.main.state_out_flat["internalConnect.master"], "")
consumer_redis_secrets = try(jsondecode(nubes_redis.main.vault_secrets["users"]), tomap({}))
consumer_redis_password = try(nonsensitive(lookup(local.consumer_redis_secrets, "default", tomap({})).password), "")
consumer_mongo_host = try(nubes_mongodb.main.state_out_flat["internalConnect"], "")
consumer_mongo_secrets = try(jsondecode(nubes_mongodb.main.vault_secrets["users"]), tomap({}))
consumer_mongo_password = try(nonsensitive(lookup(local.consumer_mongo_secrets, "admin", tomap({})).password), "")
}
resource "nubes_flask" "consumer" {
@@ -48,12 +53,12 @@ resource "nubes_flask" "consumer" {
KAFKA_USER_CRT = local.consumer_kafka_user_crt
KAFKA_USER_KEY = local.consumer_kafka_user_key
KAFKA_GROUP_ID = "iot-consumer-group"
CH_HOST = local.consumer_ch_host
CH_PORT = local.ch_http_port
CH_USER = local.ch_username
CH_PASSWORD = local.consumer_ch_password
CH_DATABASE = local.ch_db_name
REDIS_HOST = local.consumer_redis_host
REDIS_PORT = "6379"
REDIS_PASSWORD = local.consumer_redis_password
MONGO_URI = "mongodb://admin:${local.consumer_mongo_password}@${local.consumer_mongo_host}:27017/iot?authSource=admin"
MONGO_DB = "iot"
})
depends_on = [nubes_kafka.main, nubes_clickhouse.main]
depends_on = [nubes_kafka.main, nubes_redis.main, nubes_mongodb.main]
}