Răsfoiți Sursa

Merge branch 'develop' into feat/build-info-metric

Mark 3 ani în urmă
părinte
comite
138aa409cf
6 a modificat fișierele cu 50 adăugiri și 7 ștergeri
  1. 1 0
      CONTRIBUTING.md
  2. 2 2
      pkg/costmodel/metrics.go
  3. 2 2
      pkg/metrics/jobmetrics.go
  4. 1 0
      ui/Dockerfile
  5. 8 3
      ui/default.nginx.conf
  6. 36 0
      ui/nginx.conf

+ 1 - 0
CONTRIBUTING.md

@@ -7,6 +7,7 @@ Thanks for your help improving the OpenCost project! There are many ways to cont
 * joining the discussion in the [CNCF Slack](https://slack.cncf.io/) in the [#opencost](https://cloud-native.slack.com/archives/C03D56FPD4G) channel
 * participating in the fortnightly [OpenCost Working Group](https://calendar.google.com/calendar/u/0/embed?src=c_c0f7q56e5eeod3j89bb320fvjg@group.calendar.google.com&ctz=America/Los_Angeles) meetings ([notes here](https://drive.google.com/drive/folders/1hXlcyFPePB7t3z6lyVzdxmdfrbzeT1Jz))
 * committing software via the workflow below
+* keep up with community events using our [Calendar](https://calendar.google.com/calendar/u/0/embed?src=c_c0f7q56e5eeod3j89bb320fvjg@group.calendar.google.com&ctz=America/Los_Angeles)
 
 ## Getting Help
 

+ 2 - 2
pkg/costmodel/metrics.go

@@ -38,7 +38,7 @@ type ClusterInfoCollector struct {
 // collected by this Collector.
 func (cic ClusterInfoCollector) Describe(ch chan<- *prometheus.Desc) {
 	disabledMetrics := cic.metricsConfig.GetDisabledMetricsMap()
-	if _, disabled := disabledMetrics["kube_pod_annotations"]; disabled {
+	if _, disabled := disabledMetrics["kubecost_cluster_info"]; disabled {
 		return
 	}
 
@@ -49,7 +49,7 @@ func (cic ClusterInfoCollector) Describe(ch chan<- *prometheus.Desc) {
 // Collect is called by the Prometheus registry when collecting metrics.
 func (cic ClusterInfoCollector) Collect(ch chan<- prometheus.Metric) {
 	disabledMetrics := cic.metricsConfig.GetDisabledMetricsMap()
-	if _, disabled := disabledMetrics["kube_pod_annotations"]; disabled {
+	if _, disabled := disabledMetrics["kubecost_cluster_info"]; disabled {
 		return
 	}
 

+ 2 - 2
pkg/metrics/jobmetrics.go

@@ -25,7 +25,7 @@ type KubeJobCollector struct {
 // collected by this Collector.
 func (kjc KubeJobCollector) Describe(ch chan<- *prometheus.Desc) {
 	disabledMetrics := kjc.metricsConfig.GetDisabledMetricsMap()
-	if _, disabled := disabledMetrics["kube_pod_annotations"]; disabled {
+	if _, disabled := disabledMetrics["kube_job_status_failed"]; disabled {
 		return
 	}
 
@@ -35,7 +35,7 @@ func (kjc KubeJobCollector) Describe(ch chan<- *prometheus.Desc) {
 // Collect is called by the Prometheus registry when collecting metrics.
 func (kjc KubeJobCollector) Collect(ch chan<- prometheus.Metric) {
 	disabledMetrics := kjc.metricsConfig.GetDisabledMetricsMap()
-	if _, disabled := disabledMetrics["kube_pod_annotations"]; disabled {
+	if _, disabled := disabledMetrics["kube_job_status_failed"]; disabled {
 		return
 	}
 

+ 1 - 0
ui/Dockerfile

@@ -9,3 +9,4 @@ RUN npx parcel build src/index.html
 FROM nginx:alpine
 COPY --from=builder /opt/ui/dist /var/www
 COPY default.nginx.conf /etc/nginx/conf.d/
+COPY nginx.conf /etc/nginx/

+ 8 - 3
ui/default.nginx.conf

@@ -31,6 +31,13 @@ gzip_types
     text/xml
     text/x-component
     text/x-cross-domain-policy;
+
+upstream model {
+    # Update to the cost model endpoint
+    # Example: host.docker.internal:9003;
+    server 0.0.0.0:9003;
+}
+
 server {
     server_name _;
     root /var/www;
@@ -51,7 +58,6 @@ server {
     add_header ETag "1.96.0";
     listen 9090;
     listen [::]:9090;
-    resolver kube-dns.kube-system.svc.cluster.local valid=5s;
     location /healthz {
         return 200 'OK';
     }
@@ -59,8 +65,7 @@ server {
         proxy_connect_timeout       180;
         proxy_send_timeout          180;
         proxy_read_timeout          180;
-        set $server http://opencost.opencost.svc.cluster.local.:9003;
-        proxy_pass $server;
+        proxy_pass http://model/;
         proxy_redirect off;
         proxy_http_version 1.1;
         proxy_set_header Connection "";

+ 36 - 0
ui/nginx.conf

@@ -0,0 +1,36 @@
+worker_processes  auto;
+
+error_log  /var/log/nginx/error.log notice;
+pid        /tmp/nginx.pid;
+
+
+events {
+    worker_connections  1024;
+}
+
+
+http {
+    proxy_temp_path /tmp/proxy_temp;
+    client_body_temp_path /tmp/client_temp;
+    fastcgi_temp_path /tmp/fastcgi_temp;
+    uwsgi_temp_path /tmp/uwsgi_temp;
+    scgi_temp_path /tmp/scgi_temp;
+
+    include       /etc/nginx/mime.types;
+    default_type  application/octet-stream;
+
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                      '$status $body_bytes_sent "$http_referer" '
+                      '"$http_user_agent" "$http_x_forwarded_for"';
+
+    access_log  /var/log/nginx/access.log  main;
+
+    sendfile        on;
+    #tcp_nopush     on;
+
+    keepalive_timeout  65;
+
+    #gzip  on;
+
+    include /etc/nginx/conf.d/*.conf;
+}