diff --git a/README.md b/README.md index 8392f2c..b8c1d12 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,11 @@ evaluations. This setup expects Prometheus to be running in the cluster and configured to scrape pod resource metrics. The address for Prometheus can be passed through `-prometheus-url` flag. + +## Compatibility + +#### Tested on the following environment: + +- Kubernetes v1.17 with Docker v19.03 +- Prometheus v2.20 +- Kube-state-metrics v1.8 \ No newline at end of file diff --git a/deploy/scaler-deployment.yaml b/deploy/scaler-deployment.yaml index 7b62284..6424a0c 100644 --- a/deploy/scaler-deployment.yaml +++ b/deploy/scaler-deployment.yaml @@ -18,7 +18,7 @@ spec: serviceAccountName: system containers: - name: scaler - image: arjunrn/simple-scaler:ca121dd + image: denisjd/simple-scaler:v2.0 args: - -prometheus-url=http://prometheus resources: diff --git a/pkg/replicacalculator/prometheus.go b/pkg/replicacalculator/prometheus.go index 29a10bd..3246185 100644 --- a/pkg/replicacalculator/prometheus.go +++ b/pkg/replicacalculator/prometheus.go @@ -12,8 +12,8 @@ import ( ) const ( - prometheusQuery = `sum(rate(container_cpu_usage_seconds_total{pod_name=~"%s", namespace="%s"}[1m])) by(pod_name) / - sum(kube_pod_container_resource_requests_cpu_cores{pod_name=~"%s", namespace="%s"}) by (pod_name)` + prometheusQuery = `sum(rate(container_cpu_usage_seconds_total{job="kubernetes-cadvisor",image!="",container!="POD",pod=~"%s",namespace="%s"}[1m])) by(pod) / + sum(kube_pod_container_resource_requests_cpu_cores{job="kube-state-metrics",pod=~"%s",namespace="%s"}) by (pod)` ) type MetricsSource interface { @@ -55,8 +55,9 @@ func (m *prometheusMetricsSource) GetPodMetrics(namespace string, podIDs []strin return nil, fmt.Errorf("unexpected return type from the prometheus api call: %v", results.Type()) } mapResults := make(map[string][]int) + log.Debugf("matrixResult ----: %v", matrixResult) for _, r := range matrixResult { - podName := string(r.Metric["pod_name"]) + podName := string(r.Metric["pod"]) mapResults[podName] = make([]int, len(r.Values)) for i, v := range r.Values { mapResults[podName][i] = int(v.Value * 100)