From fa3bc07fe35b92055be9516e4cb599f8c4cb7d21 Mon Sep 17 00:00:00 2001 From: Alan Rodrigues Date: Fri, 2 Aug 2024 15:07:24 -0700 Subject: [PATCH 1/2] alerts NGINX routing to aggregator pod --- ...analyzer-frontend-config-map-template.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml b/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml index 16bd61d46..5e986526d 100755 --- a/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml +++ b/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml @@ -1203,6 +1203,25 @@ data: proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + + # alert end points + location = /model/alerts { + proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; + proxy_pass http://aggregator/alerts; + proxy_redirect off; + proxy_set_header Connection ""; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location ~* ^/model/alerts/(.*) { + proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; + proxy_pass http://aggregator/alerts/$1; + proxy_redirect off; + proxy_set_header Connection ""; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + {{- end }} location = /model/hideOrphanedResources { default_type 'application/json'; From d7b1bcf6dbd3330743b44ae25406a16c4f5960cb Mon Sep 17 00:00:00 2001 From: Alan Rodrigues Date: Tue, 6 Aug 2024 11:11:18 -0700 Subject: [PATCH 2/2] route v2/alerts requests to aggregator and /alerts to cost-model --- ...analyzer-frontend-config-map-template.yaml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml b/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml index 5e986526d..2a9e2402f 100755 --- a/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml +++ b/cost-analyzer/templates/cost-analyzer-frontend-config-map-template.yaml @@ -1204,8 +1204,8 @@ data: proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - # alert end points - location = /model/alerts { + # alert end points with v2 will be routed to aggregator server + location = /model/v2/alerts { proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; proxy_pass http://aggregator/alerts; proxy_redirect off; @@ -1213,7 +1213,7 @@ data: proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - location ~* ^/model/alerts/(.*) { + location ~* ^/model/v2/alerts/(.*) { proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; proxy_pass http://aggregator/alerts/$1; proxy_redirect off; @@ -1221,7 +1221,23 @@ data: proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - + # alert end points without any version will be routed to model server + location = /model/alerts { + proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; + proxy_pass http://model/alerts; + proxy_redirect off; + proxy_set_header Connection ""; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location ~* ^/model/alerts/(.*) { + proxy_read_timeout {{ .Values.kubecostFrontend.timeoutSeconds | default 300 }}; + proxy_pass http://model/alerts/$1; + proxy_redirect off; + proxy_set_header Connection ""; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } {{- end }} location = /model/hideOrphanedResources { default_type 'application/json';