diff --git a/deploy/asapo_services/scripts/asapo-nginx.nmd.tpl b/deploy/asapo_services/scripts/asapo-nginx.nmd.tpl index d22febe4565a30c2946da29bef3c67e69a5a8d5b..af11bbadbe8e5415a5401c47adf4ba37fb9145ef 100644 --- a/deploy/asapo_services/scripts/asapo-nginx.nmd.tpl +++ b/deploy/asapo_services/scripts/asapo-nginx.nmd.tpl @@ -37,6 +37,7 @@ job "asapo-nginx" { consul_dns_port = "${consul_dns_port}" prometheus_port = "${prometheus_port}" alertmanager_port = "${alertmanager_port}" + monitoring_ui_port = "${monitoring_ui_port}" } config { diff --git a/deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl b/deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl index 991f0cb04beb2cf55f3c3879096ad8eace4d1009..d3d733916e9a4b345b699f6fd5451c17728da8ab 100644 --- a/deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl +++ b/deploy/asapo_services/scripts/asapo-perfmetrics.nmd.tpl @@ -14,6 +14,9 @@ job "asapo-perfmetrics" { delay = "15s" mode = "delay" } + network { + port "monitoring_server" {} + } task "influxdb" { driver = "docker" @@ -64,8 +67,6 @@ job "asapo-perfmetrics" { } #influxdb - - task "grafana" { driver = "docker" user = "${asapo_user}" @@ -140,9 +141,6 @@ job "asapo-perfmetrics" { resources { memory = "${monitoring_server_total_memory_size}" - network { - port "monitoring_server" {} - } } service { @@ -165,6 +163,101 @@ job "asapo-perfmetrics" { } } # monitoring server + task "monitoring-proxy" { + driver = "docker" + user = "${asapo_user}" + + config { + ulimit { + memlock = "-1:-1" + } + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + privileged = true + image = "envoyproxy/envoy:v1.21.0" + volumes = ["local/envoy.yaml:/etc/envoy/envoy.yaml"] + command = "/usr/local/bin/envoy" + args=["-c","/etc/envoy/envoy.yaml","-l","trace"] + } + + resources { + memory = "${monitoring_proxy_total_memory_size}" + network { + port "monitoring_proxy_admin" {} + port "monitoring_proxy" { + static = "${monitoring_proxy_port}" + } + } + } + + service { + name = "asapo-monitoring-proxy" + port = "monitoring_proxy" + check { + name = "asapo-monitoring-proxy-alive" + port = "monitoring_proxy_admin" + type = "http" + path = "/" + interval = "10s" + timeout = "2s" + initial_status = "passing" + } + } + + template { + source = "${scripts_dir}/monitoring_proxy.yaml.tpl" + destination = "local/envoy.yaml" + change_mode = "restart" + } + } # monitoring proxy + + task "monitoring-ui" { + driver = "docker" + user = "${asapo_user}" + + config { + ulimit { + memlock = "-1:-1" + } + network_mode = "host" + security_opt = ["no-new-privileges"] + userns_mode = "host" + privileged = true + image = "${docker_repository}/asapo-monitoring-ui${image_suffix}" + force_pull = ${force_pull_images} + volumes = ["local/nginx.conf:/etc/nginx/nginx.conf"] + } + + resources { + memory = "${monitoring_ui_total_memory_size}" + network { + port "monitoring_ui" { + static = "${monitoring_ui_port}" + } + } + } + + service { + name = "asapo-monitoring-ui" + port = "monitoring_ui" + check { + name = "asapo-monitoring-ui-alive" + port = "monitoring_ui" + type = "http" + path = "/" + interval = "10s" + timeout = "2s" + initial_status = "passing" + } + } + + template { + source = "${scripts_dir}/monitoring_ui_nginx.conf.tpl" + destination = "local/nginx.conf" + change_mode = "restart" + } + } # monitoring ui } diff --git a/deploy/asapo_services/scripts/asapo.auto.tfvars.in b/deploy/asapo_services/scripts/asapo.auto.tfvars.in index 64f10eaafb223b5e86f1b495bc5dfea6911063c0..a063683c26d2faedca971efc567cc83e1ca4cb5f 100644 --- a/deploy/asapo_services/scripts/asapo.auto.tfvars.in +++ b/deploy/asapo_services/scripts/asapo.auto.tfvars.in @@ -43,6 +43,8 @@ discovery_total_memory_size = 256 prometheus_total_memory_size = 256 alertmanager_total_memory_size = 256 monitoring_server_total_memory_size = 256 +monitoring_proxy_total_memory_size = 256 +monitoring_ui_total_memory_size = 256 ldap_uri = "ldap://localhost:389" @@ -57,6 +59,8 @@ kibana_port = 5601 discovery_port = 5006 authorizer_port = 5007 +monitoring_proxy_port = 5008 +monitoring_ui_port = 5009 consul_dns_port = 8600 prometheus_port = 9090 diff --git a/deploy/asapo_services/scripts/monitoring_proxy.yaml.tpl b/deploy/asapo_services/scripts/monitoring_proxy.yaml.tpl new file mode 100644 index 0000000000000000000000000000000000000000..ba6fc9c0740c2513fbd942b431e0815dc05e81cd --- /dev/null +++ b/deploy/asapo_services/scripts/monitoring_proxy.yaml.tpl @@ -0,0 +1,55 @@ +admin: + access_log_path: /tmp/admin_access.log + address: + socket_address: { address: 0.0.0.0, port_value: {{ env "NOMAD_PORT_monitoring_proxy_admin" }} } + +static_resources: + listeners: + - name: listener_0 + address: + socket_address: { address: 0.0.0.0, port_value: {{ env "NOMAD_PORT_monitoring_proxy" }} } + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: auto + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: ["*"] + routes: + - match: { prefix: "/" } + route: + cluster: echo_service + timeout: 0s + max_stream_duration: + grpc_timeout_header_max: 0s + cors: + allow_origin_string_match: + - prefix: "*" + allow_methods: GET, PUT, DELETE, POST, OPTIONS + allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout + max_age: "1728000" + expose_headers: custom-header-1,grpc-status,grpc-message + http_filters: + - name: envoy.filters.http.grpc_web + - name: envoy.filters.http.cors + - name: envoy.filters.http.router + clusters: + - name: echo_service + connect_timeout: 0.25s + type: logical_dns + http2_protocol_options: {} + lb_policy: round_robin + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: {{ env "NOMAD_PORT_monitoring_server" }} diff --git a/deploy/asapo_services/scripts/monitoring_ui_nginx.conf.tpl b/deploy/asapo_services/scripts/monitoring_ui_nginx.conf.tpl new file mode 100644 index 0000000000000000000000000000000000000000..f911482cd25d8eaf03c8933e9731c7783b907f04 --- /dev/null +++ b/deploy/asapo_services/scripts/monitoring_ui_nginx.conf.tpl @@ -0,0 +1,53 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +error_log "/tmp/nginx_error.log"; +pid "/tmp/nginx.pid"; + + +http { + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + client_body_temp_path "/tmp/client_body" 1 2; + client_max_body_size 10M; + proxy_temp_path "/tmp/proxy" 1 2; + fastcgi_temp_path "/tmp/fastcgi" 1 2; + scgi_temp_path "/tmp/scgi" 1 2; + uwsgi_temp_path "/tmp/uwsgi" 1 2; + + + server { + listen {{ env "NOMAD_PORT_monitoring_ui" }} default_server; + server_name _; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + #include /etc/nginx/default.d/*.conf; + + index index.html; + + etag on; + + location /js/ { + add_header Cache-Control max-age=31536000; + } + + location / { + try_files $uri $uri/ /index.html; + } + location /index.html { + add_header Cache-Control no-cache; + } + + } +} \ No newline at end of file diff --git a/deploy/asapo_services/scripts/nginx.conf.tpl b/deploy/asapo_services/scripts/nginx.conf.tpl index 5e697955799ad4e58187b9eb7514d7749762b6d5..f6e76f830ab418d0ce3967b755dd167b20626a7d 100644 --- a/deploy/asapo_services/scripts/nginx.conf.tpl +++ b/deploy/asapo_services/scripts/nginx.conf.tpl @@ -31,6 +31,7 @@ http { listen {{ env "NOMAD_PORT_nginx" }}; set $discovery_endpoint asapo-discovery.service.asapo; set $authorizer_endpoint asapo-authorizer.service.asapo; + set $monitoring_ui_endpoint asapo-monitoring-ui.service.asapo; set $fluentd_endpoint fluentd.service.asapo; set $kibana_endpoint kibana.service.asapo; set $grafana_endpoint grafana.service.asapo; @@ -79,6 +80,11 @@ http { proxy_pass http://$grafana_endpoint:{{ env "NOMAD_META_grafana_port" }}$uri$is_args$args; } + location /tv/ { + rewrite ^/tv(/.*) $1 break; + proxy_pass http://$monitoring_ui_endpoint:{{ env "NOMAD_META_monitoring_ui_port" }}$uri$is_args$args; + } + location /asapo-authorizer/ { rewrite ^/asapo-authorizer(/.*) $1 break; proxy_pass http://$authorizer_endpoint:{{ env "NOMAD_META_authorizer_port" }}$uri$is_args$args; diff --git a/deploy/asapo_services/scripts/resources_services.tf b/deploy/asapo_services/scripts/resources_services.tf index 08332309d5c5a92e6f7c6784c53d57fdeacde0e5..d4e31b92ad37b49550c4d6e19c76da4af6b12f66 100644 --- a/deploy/asapo_services/scripts/resources_services.tf +++ b/deploy/asapo_services/scripts/resources_services.tf @@ -71,9 +71,22 @@ resource "null_resource" "asapo-monitoring-server" { provisioner "local-exec" { command = "asapo-wait-service asapo-monitoring" } - depends_on = [nomad_job.asapo-monitoring] + depends_on = [nomad_job.asapo-perfmetrics] } +resource "null_resource" "asapo-monitoring-proxy" { + provisioner "local-exec" { + command = "asapo-wait-service asapo-monitoring-proxy" + } + depends_on = [nomad_job.asapo-perfmetrics] +} + +resource "null_resource" "asapo-monitoring-ui" { + provisioner "local-exec" { + command = "asapo-wait-service asapo-monitoring-ui" + } + depends_on = [nomad_job.asapo-perfmetrics] +} resource "null_resource" "asapo-fts" { provisioner "local-exec" { diff --git a/deploy/asapo_services/scripts/templates.tf b/deploy/asapo_services/scripts/templates.tf index 12b905c63206da63aa6446cda70cecd5f253e89b..43b94a118741b27d3700362dc2f1cfd56ba6ffd1 100644 --- a/deploy/asapo_services/scripts/templates.tf +++ b/deploy/asapo_services/scripts/templates.tf @@ -16,6 +16,7 @@ data "template_file" "nginx" { consul_dns_port = "${var.consul_dns_port}" prometheus_port = "${var.prometheus_port}" alertmanager_port = "${var.alertmanager_port}" + monitoring_ui_port = "${var.monitoring_ui_port}" } } @@ -108,6 +109,10 @@ data "template_file" "asapo_perfmetrics" { influxdb_rpc_port = "${var.influxdb_rpc_port}" perf_monitor = "${var.perf_monitor}" monitoring_server_total_memory_size = "${var.monitoring_server_total_memory_size}" + monitoring_proxy_total_memory_size = "${var.monitoring_proxy_total_memory_size}" + monitoring_ui_total_memory_size = "${var.monitoring_ui_total_memory_size}" + monitoring_proxy_port = "${var.monitoring_proxy_port}" + monitoring_ui_port = "${var.monitoring_ui_port}" force_pull_images = "${var.force_pull_images}" nomad_logs = "${var.nomad_logs}" scripts_dir = "${var.job_scripts_dir}" diff --git a/deploy/asapo_services/scripts/vars.tf b/deploy/asapo_services/scripts/vars.tf index 559b4fd24a5c638c11fb382cd6177df221f69d5a..d612c006f3ecef3ca9d699ebe9f6aed4a5d264e9 100644 --- a/deploy/asapo_services/scripts/vars.tf +++ b/deploy/asapo_services/scripts/vars.tf @@ -86,6 +86,10 @@ variable "alertmanager_total_memory_size" {} variable "monitoring_server_total_memory_size" {} +variable "monitoring_proxy_total_memory_size" {} + +variable "monitoring_ui_total_memory_size" {} + variable "grafana_port" {} variable "influxdb_port" {} @@ -112,6 +116,10 @@ variable "authorizer_port" {} variable "consul_dns_port" {} +variable "monitoring_proxy_port" {} + +variable "monitoring_ui_port" {} + variable "n_receivers" {} variable "n_brokers" {}