Skip to content

Commit

Permalink
Add orchestrator specific configuration (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-y authored Oct 3, 2023
1 parent c3d4d67 commit 0d12f9f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 22 deletions.
31 changes: 23 additions & 8 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@ module "cloud_run" {
container_port = "8020"

container_env = {
"__SUPERBLOCKS_AGENT_SERVER_URL" = "https://app.superblocks.com",
"__SUPERBLOCKS_WORKER_LOCAL_ENABLED" = "true",
"SUPERBLOCKS_WORKER_TLS_INSECURE" = "true",
"SUPERBLOCKS_AGENT_KEY" = var.superblocks_agent_key,
"SUPERBLOCKS_CONTROLLER_DISCOVERY_ENABLED" = "false",
"SUPERBLOCKS_AGENT_HOST_URL" = "https://example-complete.koalitytools.com",
"SUPERBLOCKS_AGENT_ENVIRONMENT" = "*",
"SUPERBLOCKS_AGENT_PORT" = "8020"
"SUPERBLOCKS_ORCHESTRATOR_LOG_LEVEL" = "${var.superblocks_log_level}"
"SUPERBLOCKS_ORCHESTRATOR_HTTP_PORT" = "${local.superblocks_http_port}"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_PORT" = "8081"
"SUPERBLOCKS_ORCHESTRATOR_METRICS_PORT" = "9090"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_BIND" = "0.0.0.0"
"SUPERBLOCKS_ORCHESTRATOR_HTTP_BIND" = "0.0.0.0"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_MSG_RES_MAX" = "${var.superblocks_grpc_msg_res_max}"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_MSG_REQ_MAX" = "${var.superblocks_grpc_msg_req_max}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_URL" = "${var.superblocks_server_url}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_TIMEOUT" = "${var.superblocks_timeout}"
"SUPERBLOCKS_ORCHESTRATOR_OTEL_COLLECTOR_HTTP_URL" = "https://traces.intake.superblocks.com:443/v1/traces"
"SUPERBLOCKS_ORCHESTRATOR_EMITTER_REMOTE_INTAKE" = "https://logs.intake.superblocks.com"
"SUPERBLOCKS_ORCHESTRATOR_INTAKE_METADATA_URL" = "https://metadata.intake.superblocks.com"
"SUPERBLOCKS_ORCHESTRATOR_TRANSPORT_MODE" = "grpc"
"SUPERBLOCKS_ORCHESTRATOR_STORE_MODE" = "grpc"
"SUPERBLOCKS_AGENT_KEY" = "${var.superblocks_agent_key}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_KEY" = "${var.superblocks_agent_key}"
"SUPERBLOCKS_ORCHESTRATOR_FILE_SERVER_URL" = "http://127.0.0.1:${local.superblocks_http_port}/v2/files"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_HOST_URL" = "https://${var.subdomain}.${var.domain}"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_ENVIRONMENT" = "${var.superblocks_agent_environment}"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_TAGS" = "${local.superblocks_agent_tags}"
"SUPERBLOCKS_ORCHESTRATOR_DATA_DOMAIN" = "${var.superblocks_agent_data_domain}"
"SUPERBLOCKS_ORCHESTRATOR_HANDLE_CORS" = "${var.superblocks_agent_handle_cors}"
}

container_requests_cpu = "512m"
Expand Down
12 changes: 12 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
locals {
# if superblocks_agent_tags is not default, then
# use superblocks_agent_tags as is
# else if superblocks_agent_tags is default, then
# if superblocks_agent_environment is *,
# use profile:* (default)
# else
# use profile:${superblocks_agent_environment}
superblocks_agent_tags = var.superblocks_agent_tags != "profile:*" ? var.superblocks_agent_tags : var.superblocks_agent_environment == "*" ? "profile:*" : "profile:${var.superblocks_agent_environment}"

superblocks_http_port = var.superblocks_agent_port
}
33 changes: 23 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,29 @@ module "cloud_run" {
container_port = var.superblocks_agent_port
container_image = var.superblocks_agent_image
container_env = {
"__SUPERBLOCKS_AGENT_SERVER_URL" = var.superblocks_server_url
"__SUPERBLOCKS_WORKER_LOCAL_ENABLED" = "true"
"SUPERBLOCKS_WORKER_TLS_INSECURE" = "true"
"SUPERBLOCKS_AGENT_KEY" = var.superblocks_agent_key
"SUPERBLOCKS_CONTROLLER_DISCOVERY_ENABLED" = "false"
"SUPERBLOCKS_AGENT_HOST_URL" = "https://${var.subdomain}.${var.domain}"
"SUPERBLOCKS_AGENT_ENVIRONMENT" = var.superblocks_agent_environment
"SUPERBLOCKS_AGENT_PORT" = var.superblocks_agent_port
"NODE_OPTIONS" = "--max_old_space_size=${local.node_heap}"
"SUPERBLOCKS_AGENT_DATA_DOMAIN" = "${var.superblocks_agent_data_domain}"
"SUPERBLOCKS_ORCHESTRATOR_LOG_LEVEL" = "${var.superblocks_log_level}"
"SUPERBLOCKS_ORCHESTRATOR_HTTP_PORT" = "${var.superblocks_agent_port}"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_PORT" = "8081"
"SUPERBLOCKS_ORCHESTRATOR_METRICS_PORT" = "9090"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_BIND" = "0.0.0.0"
"SUPERBLOCKS_ORCHESTRATOR_HTTP_BIND" = "0.0.0.0"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_MSG_RES_MAX" = "${var.superblocks_grpc_msg_res_max}"
"SUPERBLOCKS_ORCHESTRATOR_GRPC_MSG_REQ_MAX" = "${var.superblocks_grpc_msg_req_max}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_URL" = "${var.superblocks_server_url}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_TIMEOUT" = "${var.superblocks_timeout}"
"SUPERBLOCKS_ORCHESTRATOR_OTEL_COLLECTOR_HTTP_URL" = "https://traces.intake.superblocks.com:443/v1/traces"
"SUPERBLOCKS_ORCHESTRATOR_EMITTER_REMOTE_INTAKE" = "https://logs.intake.superblocks.com"
"SUPERBLOCKS_ORCHESTRATOR_INTAKE_METADATA_URL" = "https://metadata.intake.superblocks.com"
"SUPERBLOCKS_ORCHESTRATOR_TRANSPORT_MODE" = "grpc"
"SUPERBLOCKS_ORCHESTRATOR_STORE_MODE" = "grpc"
"SUPERBLOCKS_AGENT_KEY" = "${var.superblocks_agent_key}"
"SUPERBLOCKS_ORCHESTRATOR_SUPERBLOCKS_KEY" = "${var.superblocks_agent_key}"
"SUPERBLOCKS_ORCHESTRATOR_FILE_SERVER_URL" = "http://127.0.0.1:${local.superblocks_http_port}/v2/files"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_HOST_URL" = "https://${var.subdomain}.${var.domain}"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_ENVIRONMENT" = "${var.superblocks_agent_environment}"
"SUPERBLOCKS_ORCHESTRATOR_AGENT_TAGS" = "${var.superblocks_agent_tags}"
"SUPERBLOCKS_ORCHESTRATOR_DATA_DOMAIN" = "${var.superblocks_agent_data_domain}"
"SUPERBLOCKS_ORCHESTRATOR_HANDLE_CORS" = "${var.superblocks_agent_handle_cors}"
}
container_cpu_throttling = var.container_cpu_throttling
container_requests_cpu = var.container_requests_cpu
Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-run/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ variable "container_image" {

variable "container_port" {
type = number
default = "8020"
default = "8080"
}

variable "container_env" {
Expand Down
53 changes: 50 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,31 @@ variable "superblocks_agent_environment" {
type = string
default = "*"
description = <<EOF
DEPRECATED! Use superblocks_agent_tags instead.
Use this varible to differentiate Superblocks Agent running environment.
Valid values are "*", "staging" and "production"
EOF
}

variable "superblocks_agent_tags" {
type = string
default = "profile:*"
description = <<EOF
Use this variable to specify which profile-specific workloads can be executed on this agent.
It accepts a comma (and colon) separated string representing key-value pairs, and currently only the "profile" key is used.
Some examples:
- To support all API executions: "profile:*"
- To support staging and production: "profile:staging,profile:production"
- To support only staging: "profile:staging"
- To support only production: "profile:production"
- To support a custom profile: "profile:custom_profile_key"
EOF
}

variable "superblocks_agent_port" {
type = number
default = "8020"
default = "8080"
description = "The port number used by Superblocks Agent container instance"
}

Expand All @@ -59,15 +76,45 @@ variable "name_prefix" {
}

variable "superblocks_agent_data_domain" {
type = string
default = "app.superblocks.com"
type = string
default = "app.superblocks.com"
validation {
condition = contains(["app.superblocks.com", "eu.superblocks.com"], var.superblocks_agent_data_domain)
error_message = "The data domain is invalid. Please use 'app.superblocks.com' or 'eu.superblocks.com'."
}
description = "The domain name for the specific Superblocks region that hosts your data."
}

variable "superblocks_grpc_msg_res_max" {
type = string
default = "100000000"
description = "The maximum message size in bytes allowed to be sent by the gRPC server. This is used to prevent malicious clients from sending large messages to cause memory exhaustion."
}

variable "superblocks_grpc_msg_req_max" {
type = string
default = "30000000"
description = "The maximum message size in bytes allowed to be received by the gRPC server. This is used to prevent malicious clients from sending large messages to cause memory exhaustion."
}

variable "superblocks_timeout" {
type = string
default = "10000000000"
description = "The maximum amount of time in milliseconds before a request is aborted. This applies for http requests against the Superblocks server and does not apply to the execution time limit of a workload."
}

variable "superblocks_log_level" {
type = string
default = "info"
description = "Logging level for the superblocks agent"
}

variable "superblocks_agent_handle_cors" {
type = bool
default = true
description = "Whether to handle CORS requests"
}

#################################################################
# Cloud Run
#################################################################
Expand Down

0 comments on commit 0d12f9f

Please sign in to comment.