mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Update dependencies to Kubernetes 1.11
This updates our dependencies to the Kubernetes 1.11 versions. In the future, this will also allow us to support the external metrics API.
This commit is contained in:
parent
1e5cd68533
commit
be018f76e3
10 changed files with 108 additions and 109 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.8
|
- '1.10'
|
||||||
|
|
||||||
# blech, Travis downloads with capitals in DirectXMan12, which confuses go
|
# blech, Travis downloads with capitals in DirectXMan12, which confuses go
|
||||||
go_import_path: github.com/directxman12/k8s-prometheus-adapter
|
go_import_path: github.com/directxman12/k8s-prometheus-adapter
|
||||||
|
|
|
||||||
86
Gopkg.lock
generated
86
Gopkg.lock
generated
|
|
@ -194,12 +194,6 @@
|
||||||
]
|
]
|
||||||
revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3"
|
revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/howeyc/gopass"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "bf9dde6d0d2c004a008c27aaee91170c786f6db8"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/imdario/mergo"
|
name = "github.com/imdario/mergo"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
|
@ -219,12 +213,7 @@
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/juju/ratelimit"
|
branch = "master"
|
||||||
packages = ["."]
|
|
||||||
revision = "59fac5042749a5afb9af70e813da1dd5474f0167"
|
|
||||||
version = "1.0.1"
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
name = "github.com/kubernetes-incubator/custom-metrics-apiserver"
|
name = "github.com/kubernetes-incubator/custom-metrics-apiserver"
|
||||||
packages = [
|
packages = [
|
||||||
"pkg/apiserver",
|
"pkg/apiserver",
|
||||||
|
|
@ -232,9 +221,10 @@
|
||||||
"pkg/cmd/server",
|
"pkg/cmd/server",
|
||||||
"pkg/dynamicmapper",
|
"pkg/dynamicmapper",
|
||||||
"pkg/provider",
|
"pkg/provider",
|
||||||
"pkg/registry/custom_metrics"
|
"pkg/registry/custom_metrics",
|
||||||
|
"pkg/registry/external_metrics"
|
||||||
]
|
]
|
||||||
revision = "fae01650d93f5de6151a024e36323344e14427aa"
|
revision = "d8f23423aa1d0ff2bc9656da863d721725b3c68a"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
@ -264,12 +254,6 @@
|
||||||
revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f"
|
revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/mxk/go-flowrate"
|
|
||||||
packages = ["flowrate"]
|
|
||||||
revision = "cca7078d478f8520f85629ad7c68962d31ed7682"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/pborman/uuid"
|
name = "github.com/pborman/uuid"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
|
@ -365,8 +349,6 @@
|
||||||
name = "golang.org/x/net"
|
name = "golang.org/x/net"
|
||||||
packages = [
|
packages = [
|
||||||
"context",
|
"context",
|
||||||
"html",
|
|
||||||
"html/atom",
|
|
||||||
"http/httpguts",
|
"http/httpguts",
|
||||||
"http2",
|
"http2",
|
||||||
"http2/hpack",
|
"http2/hpack",
|
||||||
|
|
@ -408,6 +390,12 @@
|
||||||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
version = "v0.3.0"
|
version = "v0.3.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/time"
|
||||||
|
packages = ["rate"]
|
||||||
|
revision = "fbb02b2291d28baffd63558aa44b4b56f178d650"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "google.golang.org/genproto"
|
name = "google.golang.org/genproto"
|
||||||
|
|
@ -493,13 +481,14 @@
|
||||||
"rbac/v1alpha1",
|
"rbac/v1alpha1",
|
||||||
"rbac/v1beta1",
|
"rbac/v1beta1",
|
||||||
"scheduling/v1alpha1",
|
"scheduling/v1alpha1",
|
||||||
|
"scheduling/v1beta1",
|
||||||
"settings/v1alpha1",
|
"settings/v1alpha1",
|
||||||
"storage/v1",
|
"storage/v1",
|
||||||
"storage/v1alpha1",
|
"storage/v1alpha1",
|
||||||
"storage/v1beta1"
|
"storage/v1beta1"
|
||||||
]
|
]
|
||||||
revision = "af4bc157c3a209798fc897f6d4aaaaeb6c2e0d6a"
|
revision = "91b2d7a92a8930454bf5020e0595b8ea0f2a5047"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "k8s.io/apimachinery"
|
name = "k8s.io/apimachinery"
|
||||||
|
|
@ -510,14 +499,11 @@
|
||||||
"pkg/api/resource",
|
"pkg/api/resource",
|
||||||
"pkg/api/validation",
|
"pkg/api/validation",
|
||||||
"pkg/api/validation/path",
|
"pkg/api/validation/path",
|
||||||
"pkg/apimachinery",
|
|
||||||
"pkg/apimachinery/announced",
|
|
||||||
"pkg/apimachinery/registered",
|
|
||||||
"pkg/apis/meta/internalversion",
|
"pkg/apis/meta/internalversion",
|
||||||
"pkg/apis/meta/v1",
|
"pkg/apis/meta/v1",
|
||||||
"pkg/apis/meta/v1/unstructured",
|
"pkg/apis/meta/v1/unstructured",
|
||||||
"pkg/apis/meta/v1/validation",
|
"pkg/apis/meta/v1/validation",
|
||||||
"pkg/apis/meta/v1alpha1",
|
"pkg/apis/meta/v1beta1",
|
||||||
"pkg/conversion",
|
"pkg/conversion",
|
||||||
"pkg/conversion/queryparams",
|
"pkg/conversion/queryparams",
|
||||||
"pkg/fields",
|
"pkg/fields",
|
||||||
|
|
@ -537,12 +523,10 @@
|
||||||
"pkg/util/diff",
|
"pkg/util/diff",
|
||||||
"pkg/util/errors",
|
"pkg/util/errors",
|
||||||
"pkg/util/framer",
|
"pkg/util/framer",
|
||||||
"pkg/util/httpstream",
|
|
||||||
"pkg/util/intstr",
|
"pkg/util/intstr",
|
||||||
"pkg/util/json",
|
"pkg/util/json",
|
||||||
"pkg/util/mergepatch",
|
"pkg/util/mergepatch",
|
||||||
"pkg/util/net",
|
"pkg/util/net",
|
||||||
"pkg/util/proxy",
|
|
||||||
"pkg/util/rand",
|
"pkg/util/rand",
|
||||||
"pkg/util/runtime",
|
"pkg/util/runtime",
|
||||||
"pkg/util/sets",
|
"pkg/util/sets",
|
||||||
|
|
@ -556,11 +540,10 @@
|
||||||
"pkg/version",
|
"pkg/version",
|
||||||
"pkg/watch",
|
"pkg/watch",
|
||||||
"third_party/forked/golang/json",
|
"third_party/forked/golang/json",
|
||||||
"third_party/forked/golang/netutil",
|
|
||||||
"third_party/forked/golang/reflect"
|
"third_party/forked/golang/reflect"
|
||||||
]
|
]
|
||||||
revision = "180eddb345a5be3a157cea1c624700ad5bd27b8f"
|
revision = "fda675fbe85280c4550452dae2a5ebf74e4a59b7"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "k8s.io/apiserver"
|
name = "k8s.io/apiserver"
|
||||||
|
|
@ -575,12 +558,12 @@
|
||||||
"pkg/admission/plugin/webhook/config/apis/webhookadmission",
|
"pkg/admission/plugin/webhook/config/apis/webhookadmission",
|
||||||
"pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1",
|
"pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1",
|
||||||
"pkg/admission/plugin/webhook/errors",
|
"pkg/admission/plugin/webhook/errors",
|
||||||
|
"pkg/admission/plugin/webhook/generic",
|
||||||
"pkg/admission/plugin/webhook/mutating",
|
"pkg/admission/plugin/webhook/mutating",
|
||||||
"pkg/admission/plugin/webhook/namespace",
|
"pkg/admission/plugin/webhook/namespace",
|
||||||
"pkg/admission/plugin/webhook/request",
|
"pkg/admission/plugin/webhook/request",
|
||||||
"pkg/admission/plugin/webhook/rules",
|
"pkg/admission/plugin/webhook/rules",
|
||||||
"pkg/admission/plugin/webhook/validating",
|
"pkg/admission/plugin/webhook/validating",
|
||||||
"pkg/admission/plugin/webhook/versioned",
|
|
||||||
"pkg/apis/apiserver",
|
"pkg/apis/apiserver",
|
||||||
"pkg/apis/apiserver/install",
|
"pkg/apis/apiserver/install",
|
||||||
"pkg/apis/apiserver/v1alpha1",
|
"pkg/apis/apiserver/v1alpha1",
|
||||||
|
|
@ -625,6 +608,7 @@
|
||||||
"pkg/server/httplog",
|
"pkg/server/httplog",
|
||||||
"pkg/server/mux",
|
"pkg/server/mux",
|
||||||
"pkg/server/options",
|
"pkg/server/options",
|
||||||
|
"pkg/server/resourceconfig",
|
||||||
"pkg/server/routes",
|
"pkg/server/routes",
|
||||||
"pkg/server/routes/data/swagger",
|
"pkg/server/routes/data/swagger",
|
||||||
"pkg/server/storage",
|
"pkg/server/storage",
|
||||||
|
|
@ -643,16 +627,19 @@
|
||||||
"pkg/util/flag",
|
"pkg/util/flag",
|
||||||
"pkg/util/flushwriter",
|
"pkg/util/flushwriter",
|
||||||
"pkg/util/logs",
|
"pkg/util/logs",
|
||||||
|
"pkg/util/openapi",
|
||||||
"pkg/util/trace",
|
"pkg/util/trace",
|
||||||
"pkg/util/webhook",
|
"pkg/util/webhook",
|
||||||
"pkg/util/wsstream",
|
"pkg/util/wsstream",
|
||||||
|
"plugin/pkg/audit/buffered",
|
||||||
"plugin/pkg/audit/log",
|
"plugin/pkg/audit/log",
|
||||||
|
"plugin/pkg/audit/truncate",
|
||||||
"plugin/pkg/audit/webhook",
|
"plugin/pkg/audit/webhook",
|
||||||
"plugin/pkg/authenticator/token/webhook",
|
"plugin/pkg/authenticator/token/webhook",
|
||||||
"plugin/pkg/authorizer/webhook"
|
"plugin/pkg/authorizer/webhook"
|
||||||
]
|
]
|
||||||
revision = "91e14f394e4796abf5a994a349a222e7081d86b6"
|
revision = "44b612291bb7545430c499a3882c610c727f37b0"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "k8s.io/client-go"
|
name = "k8s.io/client-go"
|
||||||
|
|
@ -694,6 +681,7 @@
|
||||||
"informers/rbac/v1beta1",
|
"informers/rbac/v1beta1",
|
||||||
"informers/scheduling",
|
"informers/scheduling",
|
||||||
"informers/scheduling/v1alpha1",
|
"informers/scheduling/v1alpha1",
|
||||||
|
"informers/scheduling/v1beta1",
|
||||||
"informers/settings",
|
"informers/settings",
|
||||||
"informers/settings/v1alpha1",
|
"informers/settings/v1alpha1",
|
||||||
"informers/storage",
|
"informers/storage",
|
||||||
|
|
@ -726,6 +714,7 @@
|
||||||
"kubernetes/typed/rbac/v1alpha1",
|
"kubernetes/typed/rbac/v1alpha1",
|
||||||
"kubernetes/typed/rbac/v1beta1",
|
"kubernetes/typed/rbac/v1beta1",
|
||||||
"kubernetes/typed/scheduling/v1alpha1",
|
"kubernetes/typed/scheduling/v1alpha1",
|
||||||
|
"kubernetes/typed/scheduling/v1beta1",
|
||||||
"kubernetes/typed/settings/v1alpha1",
|
"kubernetes/typed/settings/v1alpha1",
|
||||||
"kubernetes/typed/storage/v1",
|
"kubernetes/typed/storage/v1",
|
||||||
"kubernetes/typed/storage/v1alpha1",
|
"kubernetes/typed/storage/v1alpha1",
|
||||||
|
|
@ -750,13 +739,19 @@
|
||||||
"listers/rbac/v1alpha1",
|
"listers/rbac/v1alpha1",
|
||||||
"listers/rbac/v1beta1",
|
"listers/rbac/v1beta1",
|
||||||
"listers/scheduling/v1alpha1",
|
"listers/scheduling/v1alpha1",
|
||||||
|
"listers/scheduling/v1beta1",
|
||||||
"listers/settings/v1alpha1",
|
"listers/settings/v1alpha1",
|
||||||
"listers/storage/v1",
|
"listers/storage/v1",
|
||||||
"listers/storage/v1alpha1",
|
"listers/storage/v1alpha1",
|
||||||
"listers/storage/v1beta1",
|
"listers/storage/v1beta1",
|
||||||
|
"pkg/apis/clientauthentication",
|
||||||
|
"pkg/apis/clientauthentication/v1alpha1",
|
||||||
|
"pkg/apis/clientauthentication/v1beta1",
|
||||||
"pkg/version",
|
"pkg/version",
|
||||||
|
"plugin/pkg/client/auth/exec",
|
||||||
"rest",
|
"rest",
|
||||||
"rest/watch",
|
"rest/watch",
|
||||||
|
"restmapper",
|
||||||
"testing",
|
"testing",
|
||||||
"tools/auth",
|
"tools/auth",
|
||||||
"tools/cache",
|
"tools/cache",
|
||||||
|
|
@ -770,12 +765,14 @@
|
||||||
"transport",
|
"transport",
|
||||||
"util/buffer",
|
"util/buffer",
|
||||||
"util/cert",
|
"util/cert",
|
||||||
|
"util/connrotation",
|
||||||
"util/flowcontrol",
|
"util/flowcontrol",
|
||||||
"util/homedir",
|
"util/homedir",
|
||||||
"util/integer"
|
"util/integer",
|
||||||
|
"util/retry"
|
||||||
]
|
]
|
||||||
revision = "78700dec6369ba22221b72770783300f143df150"
|
revision = "4cacfee698b01630072bc41e3384280562a97d95"
|
||||||
version = "v6.0.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
@ -794,14 +791,17 @@
|
||||||
packages = [
|
packages = [
|
||||||
"pkg/apis/custom_metrics",
|
"pkg/apis/custom_metrics",
|
||||||
"pkg/apis/custom_metrics/install",
|
"pkg/apis/custom_metrics/install",
|
||||||
"pkg/apis/custom_metrics/v1beta1"
|
"pkg/apis/custom_metrics/v1beta1",
|
||||||
|
"pkg/apis/external_metrics",
|
||||||
|
"pkg/apis/external_metrics/install",
|
||||||
|
"pkg/apis/external_metrics/v1beta1"
|
||||||
]
|
]
|
||||||
revision = "bc50bbd13d9f360ab1438b486623e1debd1f424d"
|
revision = "89f8a18a5efb0c0162a32c75db752bc53ed7f8ee"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "20d60ed2d6d92b2bafc310f59695cd1aa446c54328caeb1c25d87c8b2516925b"
|
inputs-digest = "922da691d7be0fa3bde2ab628c629fea6718792cb234a2e5c661a193f0545d6f"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
||||||
13
Gopkg.toml
13
Gopkg.toml
|
|
@ -48,30 +48,29 @@
|
||||||
|
|
||||||
# Kubernetes incubator deps
|
# Kubernetes incubator deps
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
# hard lock on a commit until we have releases
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
revision = "fae01650d93f5de6151a024e36323344e14427aa"
|
|
||||||
name = "github.com/kubernetes-incubator/custom-metrics-apiserver"
|
name = "github.com/kubernetes-incubator/custom-metrics-apiserver"
|
||||||
|
|
||||||
# Core Kubernetes deps
|
# Core Kubernetes deps
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "k8s.io/api"
|
name = "k8s.io/api"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "k8s.io/apimachinery"
|
name = "k8s.io/apimachinery"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "k8s.io/apiserver"
|
name = "k8s.io/apiserver"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "k8s.io/client-go"
|
name = "k8s.io/client-go"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "k8s.io/metrics"
|
name = "k8s.io/metrics"
|
||||||
version = "kubernetes-1.9.0"
|
version = "kubernetes-1.11.0-rc.1"
|
||||||
|
|
||||||
# Test deps
|
# Test deps
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
|
|
|
||||||
4
Makefile
4
Makefile
|
|
@ -8,7 +8,7 @@ OUT_DIR?=./_output
|
||||||
VENDOR_DOCKERIZED=0
|
VENDOR_DOCKERIZED=0
|
||||||
|
|
||||||
VERSION?=latest
|
VERSION?=latest
|
||||||
GOIMAGE=golang:1.8
|
GOIMAGE=golang:1.10
|
||||||
|
|
||||||
ifeq ($(ARCH),amd64)
|
ifeq ($(ARCH),amd64)
|
||||||
BASEIMAGE?=busybox
|
BASEIMAGE?=busybox
|
||||||
|
|
@ -24,7 +24,7 @@ ifeq ($(ARCH),ppc64le)
|
||||||
endif
|
endif
|
||||||
ifeq ($(ARCH),s390x)
|
ifeq ($(ARCH),s390x)
|
||||||
BASEIMAGE?=s390x/busybox
|
BASEIMAGE?=s390x/busybox
|
||||||
GOIMAGE=s390x/golang:1.8
|
GOIMAGE=s390x/golang:1.10
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all docker-build push-% push test verify-gofmt gofmt verify build-local-image
|
.PHONY: all docker-build push-% push test verify-gofmt gofmt verify build-local-image
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
|
||||||
"k8s.io/client-go/discovery"
|
"k8s.io/client-go/discovery"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
|
|
@ -162,12 +161,12 @@ func (o PrometheusAdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-c
|
||||||
return fmt.Errorf("unable to construct discovery client for dynamic client: %v", err)
|
return fmt.Errorf("unable to construct discovery client for dynamic client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamicMapper, err := dynamicmapper.NewRESTMapper(discoveryClient, apimeta.InterfacesForUnstructured, o.DiscoveryInterval)
|
dynamicMapper, err := dynamicmapper.NewRESTMapper(discoveryClient, o.DiscoveryInterval)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to construct dynamic discovery mapper: %v", err)
|
return fmt.Errorf("unable to construct dynamic discovery mapper: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
clientPool := dynamic.NewClientPool(clientConfig, dynamicMapper, dynamic.LegacyAPIPathResolverFunc)
|
dynamicClient, err := dynamic.NewForConfig(clientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to construct lister client to initialize provider: %v", err)
|
return fmt.Errorf("unable to construct lister client to initialize provider: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -190,10 +189,10 @@ func (o PrometheusAdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-c
|
||||||
return fmt.Errorf("unable to construct naming scheme from metrics rules: %v", err)
|
return fmt.Errorf("unable to construct naming scheme from metrics rules: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmProvider, runner := cmprov.NewPrometheusProvider(dynamicMapper, clientPool, promClient, namers, o.MetricsRelistInterval)
|
cmProvider, runner := cmprov.NewPrometheusProvider(dynamicMapper, dynamicClient, promClient, namers, o.MetricsRelistInterval)
|
||||||
runner.RunUntil(stopCh)
|
runner.RunUntil(stopCh)
|
||||||
|
|
||||||
server, err := config.Complete().New("prometheus-custom-metrics-adapter", cmProvider)
|
server, err := config.Complete().New("prometheus-custom-metrics-adapter", cmProvider, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ func (n *metricNamer) ResourcesForSeries(series prom.Series) ([]schema.GroupReso
|
||||||
// if not, check if it matches the form we expect, and if so,
|
// if not, check if it matches the form we expect, and if so,
|
||||||
// convert to a group-resource.
|
// convert to a group-resource.
|
||||||
if groupRes, ok = n.labelResExtractor.GroupResourceForLabel(lbl); ok {
|
if groupRes, ok = n.labelResExtractor.GroupResourceForLabel(lbl); ok {
|
||||||
info, _, err := provider.MetricInfo{GroupResource: groupRes}.Normalized(n.mapper)
|
info, _, err := provider.CustomMetricInfo{GroupResource: groupRes}.Normalized(n.mapper)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unable to normalize group-resource %s from label %q, skipping: %v", groupRes.String(), lbl, err)
|
glog.Errorf("unable to normalize group-resource %s from label %q, skipping: %v", groupRes.String(), lbl, err)
|
||||||
continue
|
continue
|
||||||
|
|
@ -452,7 +452,7 @@ func NamersFromConfig(cfg *config.MetricsDiscoveryConfig, mapper apimeta.RESTMap
|
||||||
|
|
||||||
// invert the structure for consistency with the template
|
// invert the structure for consistency with the template
|
||||||
for lbl, groupRes := range rule.Resources.Overrides {
|
for lbl, groupRes := range rule.Resources.Overrides {
|
||||||
infoRaw := provider.MetricInfo{
|
infoRaw := provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: groupRes.Group,
|
Group: groupRes.Group,
|
||||||
Resource: groupRes.Resource,
|
Resource: groupRes.Resource,
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,13 @@ type Runnable interface {
|
||||||
|
|
||||||
type prometheusProvider struct {
|
type prometheusProvider struct {
|
||||||
mapper apimeta.RESTMapper
|
mapper apimeta.RESTMapper
|
||||||
kubeClient dynamic.ClientPool
|
kubeClient dynamic.Interface
|
||||||
promClient prom.Client
|
promClient prom.Client
|
||||||
|
|
||||||
SeriesRegistry
|
SeriesRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.ClientPool, promClient prom.Client, namers []MetricNamer, updateInterval time.Duration) (provider.CustomMetricsProvider, Runnable) {
|
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.Interface, promClient prom.Client, namers []MetricNamer, updateInterval time.Duration) (provider.CustomMetricsProvider, Runnable) {
|
||||||
lister := &cachingMetricsLister{
|
lister := &cachingMetricsLister{
|
||||||
updateInterval: updateInterval,
|
updateInterval: updateInterval,
|
||||||
promClient: promClient,
|
promClient: promClient,
|
||||||
|
|
@ -95,7 +95,7 @@ func (p *prometheusProvider) metricFor(value pmodel.SampleValue, groupResource s
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) metricsFor(valueSet pmodel.Vector, info provider.MetricInfo, list runtime.Object) (*custom_metrics.MetricValueList, error) {
|
func (p *prometheusProvider) metricsFor(valueSet pmodel.Vector, info provider.CustomMetricInfo, list runtime.Object) (*custom_metrics.MetricValueList, error) {
|
||||||
if !apimeta.IsListType(list) {
|
if !apimeta.IsListType(list) {
|
||||||
return nil, apierr.NewInternalError(fmt.Errorf("result of label selector list operation was not a list"))
|
return nil, apierr.NewInternalError(fmt.Errorf("result of label selector list operation was not a list"))
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ func (p *prometheusProvider) metricsFor(valueSet pmodel.Vector, info provider.Me
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) buildQuery(info provider.MetricInfo, namespace string, names ...string) (pmodel.Vector, error) {
|
func (p *prometheusProvider) buildQuery(info provider.CustomMetricInfo, namespace string, names ...string) (pmodel.Vector, error) {
|
||||||
query, found := p.QueryForMetric(info, namespace, names...)
|
query, found := p.QueryForMetric(info, namespace, names...)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, provider.NewMetricNotFoundError(info.GroupResource, info.Metric)
|
return nil, provider.NewMetricNotFoundError(info.GroupResource, info.Metric)
|
||||||
|
|
@ -151,7 +151,7 @@ func (p *prometheusProvider) buildQuery(info provider.MetricInfo, namespace stri
|
||||||
return *queryResults.Vector, nil
|
return *queryResults.Vector, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) getSingle(info provider.MetricInfo, namespace, name string) (*custom_metrics.MetricValue, error) {
|
func (p *prometheusProvider) getSingle(info provider.CustomMetricInfo, namespace, name string) (*custom_metrics.MetricValue, error) {
|
||||||
queryResults, err := p.buildQuery(info, namespace, name)
|
queryResults, err := p.buildQuery(info, namespace, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -179,24 +179,25 @@ func (p *prometheusProvider) getSingle(info provider.MetricInfo, namespace, name
|
||||||
return p.metricFor(resultValue, info.GroupResource, "", name, info.Metric)
|
return p.metricFor(resultValue, info.GroupResource, "", name, info.Metric)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) getMultiple(info provider.MetricInfo, namespace string, selector labels.Selector) (*custom_metrics.MetricValueList, error) {
|
func (p *prometheusProvider) getMultiple(info provider.CustomMetricInfo, namespace string, selector labels.Selector) (*custom_metrics.MetricValueList, error) {
|
||||||
// construct a client to list the names of objects matching the label selector
|
fullResources, err := p.mapper.ResourcesFor(info.GroupResource.WithVersion(""))
|
||||||
client, err := p.kubeClient.ClientForGroupVersionResource(info.GroupResource.WithVersion(""))
|
if err == nil && len(fullResources) == 0 {
|
||||||
|
err = fmt.Errorf("no fully versioned resources known for group-resource %v", info.GroupResource)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unable to construct dynamic client to list matching resource names: %v", err)
|
glog.Errorf("unable to find preferred version to list matching resource names: %v", err)
|
||||||
// don't leak implementation details to the user
|
// don't leak implementation details to the user
|
||||||
return nil, apierr.NewInternalError(fmt.Errorf("unable to list matching resources"))
|
return nil, apierr.NewInternalError(fmt.Errorf("unable to list matching resources"))
|
||||||
}
|
}
|
||||||
|
var client dynamic.ResourceInterface
|
||||||
// we can construct a this APIResource ourself, since the dynamic client only uses Name and Namespaced
|
if namespace != "" {
|
||||||
apiRes := &metav1.APIResource{
|
client = p.kubeClient.Resource(fullResources[0]).Namespace(namespace)
|
||||||
Name: info.GroupResource.Resource,
|
} else {
|
||||||
Namespaced: info.Namespaced,
|
client = p.kubeClient.Resource(fullResources[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// actually list the objects matching the label selector
|
// actually list the objects matching the label selector
|
||||||
matchingObjectsRaw, err := client.Resource(apiRes, namespace).
|
matchingObjectsRaw, err := client.List(metav1.ListOptions{LabelSelector: selector.String()})
|
||||||
List(metav1.ListOptions{LabelSelector: selector.String()})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unable to list matching resource names: %v", err)
|
glog.Errorf("unable to list matching resource names: %v", err)
|
||||||
// don't leak implementation details to the user
|
// don't leak implementation details to the user
|
||||||
|
|
@ -225,7 +226,7 @@ func (p *prometheusProvider) getMultiple(info provider.MetricInfo, namespace str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) GetRootScopedMetricByName(groupResource schema.GroupResource, name string, metricName string) (*custom_metrics.MetricValue, error) {
|
func (p *prometheusProvider) GetRootScopedMetricByName(groupResource schema.GroupResource, name string, metricName string) (*custom_metrics.MetricValue, error) {
|
||||||
info := provider.MetricInfo{
|
info := provider.CustomMetricInfo{
|
||||||
GroupResource: groupResource,
|
GroupResource: groupResource,
|
||||||
Metric: metricName,
|
Metric: metricName,
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
|
|
@ -235,7 +236,7 @@ func (p *prometheusProvider) GetRootScopedMetricByName(groupResource schema.Grou
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) GetRootScopedMetricBySelector(groupResource schema.GroupResource, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error) {
|
func (p *prometheusProvider) GetRootScopedMetricBySelector(groupResource schema.GroupResource, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error) {
|
||||||
info := provider.MetricInfo{
|
info := provider.CustomMetricInfo{
|
||||||
GroupResource: groupResource,
|
GroupResource: groupResource,
|
||||||
Metric: metricName,
|
Metric: metricName,
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
|
|
@ -244,7 +245,7 @@ func (p *prometheusProvider) GetRootScopedMetricBySelector(groupResource schema.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) GetNamespacedMetricByName(groupResource schema.GroupResource, namespace string, name string, metricName string) (*custom_metrics.MetricValue, error) {
|
func (p *prometheusProvider) GetNamespacedMetricByName(groupResource schema.GroupResource, namespace string, name string, metricName string) (*custom_metrics.MetricValue, error) {
|
||||||
info := provider.MetricInfo{
|
info := provider.CustomMetricInfo{
|
||||||
GroupResource: groupResource,
|
GroupResource: groupResource,
|
||||||
Metric: metricName,
|
Metric: metricName,
|
||||||
Namespaced: true,
|
Namespaced: true,
|
||||||
|
|
@ -254,7 +255,7 @@ func (p *prometheusProvider) GetNamespacedMetricByName(groupResource schema.Grou
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prometheusProvider) GetNamespacedMetricBySelector(groupResource schema.GroupResource, namespace string, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error) {
|
func (p *prometheusProvider) GetNamespacedMetricBySelector(groupResource schema.GroupResource, namespace string, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error) {
|
||||||
info := provider.MetricInfo{
|
info := provider.CustomMetricInfo{
|
||||||
GroupResource: groupResource,
|
GroupResource: groupResource,
|
||||||
Metric: metricName,
|
Metric: metricName,
|
||||||
Namespaced: true,
|
Namespaced: true,
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ func (c *fakePromClient) QueryRange(_ context.Context, r prom.Range, query prom.
|
||||||
|
|
||||||
func setupPrometheusProvider(t *testing.T) (provider.CustomMetricsProvider, *fakePromClient) {
|
func setupPrometheusProvider(t *testing.T) (provider.CustomMetricsProvider, *fakePromClient) {
|
||||||
fakeProm := &fakePromClient{}
|
fakeProm := &fakePromClient{}
|
||||||
fakeKubeClient := &fakedyn.FakeClientPool{}
|
fakeKubeClient := &fakedyn.FakeDynamicClient{}
|
||||||
|
|
||||||
cfg := config.DefaultConfig(1*time.Minute, "")
|
cfg := config.DefaultConfig(1*time.Minute, "")
|
||||||
namers, err := NamersFromConfig(cfg, restMapper())
|
namers, err := NamersFromConfig(cfg, restMapper())
|
||||||
|
|
@ -148,7 +148,7 @@ func TestListAllMetrics(t *testing.T) {
|
||||||
actualMetrics := prov.ListAllMetrics()
|
actualMetrics := prov.ListAllMetrics()
|
||||||
sort.Sort(metricInfoSorter(actualMetrics))
|
sort.Sort(metricInfoSorter(actualMetrics))
|
||||||
|
|
||||||
expectedMetrics := []provider.MetricInfo{
|
expectedMetrics := []provider.CustomMetricInfo{
|
||||||
{schema.GroupResource{Resource: "services"}, true, "ingress_hits"},
|
{schema.GroupResource{Resource: "services"}, true, "ingress_hits"},
|
||||||
{schema.GroupResource{Group: "extensions", Resource: "ingresses"}, true, "ingress_hits"},
|
{schema.GroupResource{Group: "extensions", Resource: "ingresses"}, true, "ingress_hits"},
|
||||||
{schema.GroupResource{Resource: "pods"}, true, "ingress_hits"},
|
{schema.GroupResource{Resource: "pods"}, true, "ingress_hits"},
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,12 @@ type SeriesRegistry interface {
|
||||||
// Each slice in series should correspond to a MetricNamer in namers.
|
// Each slice in series should correspond to a MetricNamer in namers.
|
||||||
SetSeries(series [][]prom.Series, namers []MetricNamer) error
|
SetSeries(series [][]prom.Series, namers []MetricNamer) error
|
||||||
// ListAllMetrics lists all metrics known to this registry
|
// ListAllMetrics lists all metrics known to this registry
|
||||||
ListAllMetrics() []provider.MetricInfo
|
ListAllMetrics() []provider.CustomMetricInfo
|
||||||
// SeriesForMetric looks up the minimum required series information to make a query for the given metric
|
// SeriesForMetric looks up the minimum required series information to make a query for the given metric
|
||||||
// against the given resource (namespace may be empty for non-namespaced resources)
|
// against the given resource (namespace may be empty for non-namespaced resources)
|
||||||
QueryForMetric(info provider.MetricInfo, namespace string, resourceNames ...string) (query prom.Selector, found bool)
|
QueryForMetric(info provider.CustomMetricInfo, namespace string, resourceNames ...string) (query prom.Selector, found bool)
|
||||||
// MatchValuesToNames matches result values to resource names for the given metric and value set
|
// MatchValuesToNames matches result values to resource names for the given metric and value set
|
||||||
MatchValuesToNames(metricInfo provider.MetricInfo, values pmodel.Vector) (matchedValues map[string]pmodel.SampleValue, found bool)
|
MatchValuesToNames(metricInfo provider.CustomMetricInfo, values pmodel.Vector) (matchedValues map[string]pmodel.SampleValue, found bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
type seriesInfo struct {
|
type seriesInfo struct {
|
||||||
|
|
@ -68,9 +68,9 @@ type basicSeriesRegistry struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
|
||||||
// info maps metric info to information about the corresponding series
|
// info maps metric info to information about the corresponding series
|
||||||
info map[provider.MetricInfo]seriesInfo
|
info map[provider.CustomMetricInfo]seriesInfo
|
||||||
// metrics is the list of all known metrics
|
// metrics is the list of all known metrics
|
||||||
metrics []provider.MetricInfo
|
metrics []provider.CustomMetricInfo
|
||||||
|
|
||||||
mapper apimeta.RESTMapper
|
mapper apimeta.RESTMapper
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers
|
||||||
return fmt.Errorf("need one set of series per namer")
|
return fmt.Errorf("need one set of series per namer")
|
||||||
}
|
}
|
||||||
|
|
||||||
newInfo := make(map[provider.MetricInfo]seriesInfo)
|
newInfo := make(map[provider.CustomMetricInfo]seriesInfo)
|
||||||
for i, newSeries := range newSeriesSlices {
|
for i, newSeries := range newSeriesSlices {
|
||||||
namer := namers[i]
|
namer := namers[i]
|
||||||
for _, series := range newSeries {
|
for _, series := range newSeries {
|
||||||
|
|
@ -92,7 +92,7 @@ func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, resource := range resources {
|
for _, resource := range resources {
|
||||||
info := provider.MetricInfo{
|
info := provider.CustomMetricInfo{
|
||||||
GroupResource: resource,
|
GroupResource: resource,
|
||||||
Namespaced: namespaced,
|
Namespaced: namespaced,
|
||||||
Metric: name,
|
Metric: name,
|
||||||
|
|
@ -113,7 +113,7 @@ func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers
|
||||||
}
|
}
|
||||||
|
|
||||||
// regenerate metrics
|
// regenerate metrics
|
||||||
newMetrics := make([]provider.MetricInfo, 0, len(newInfo))
|
newMetrics := make([]provider.CustomMetricInfo, 0, len(newInfo))
|
||||||
for info := range newInfo {
|
for info := range newInfo {
|
||||||
newMetrics = append(newMetrics, info)
|
newMetrics = append(newMetrics, info)
|
||||||
}
|
}
|
||||||
|
|
@ -127,14 +127,14 @@ func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *basicSeriesRegistry) ListAllMetrics() []provider.MetricInfo {
|
func (r *basicSeriesRegistry) ListAllMetrics() []provider.CustomMetricInfo {
|
||||||
r.mu.RLock()
|
r.mu.RLock()
|
||||||
defer r.mu.RUnlock()
|
defer r.mu.RUnlock()
|
||||||
|
|
||||||
return r.metrics
|
return r.metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *basicSeriesRegistry) QueryForMetric(metricInfo provider.MetricInfo, namespace string, resourceNames ...string) (prom.Selector, bool) {
|
func (r *basicSeriesRegistry) QueryForMetric(metricInfo provider.CustomMetricInfo, namespace string, resourceNames ...string) (prom.Selector, bool) {
|
||||||
r.mu.RLock()
|
r.mu.RLock()
|
||||||
defer r.mu.RUnlock()
|
defer r.mu.RUnlock()
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ func (r *basicSeriesRegistry) QueryForMetric(metricInfo provider.MetricInfo, nam
|
||||||
return query, true
|
return query, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *basicSeriesRegistry) MatchValuesToNames(metricInfo provider.MetricInfo, values pmodel.Vector) (matchedValues map[string]pmodel.SampleValue, found bool) {
|
func (r *basicSeriesRegistry) MatchValuesToNames(metricInfo provider.CustomMetricInfo, values pmodel.Vector) (matchedValues map[string]pmodel.SampleValue, found bool) {
|
||||||
r.mu.RLock()
|
r.mu.RLock()
|
||||||
defer r.mu.RUnlock()
|
defer r.mu.RUnlock()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import (
|
||||||
// restMapper creates a RESTMapper with just the types we need for
|
// restMapper creates a RESTMapper with just the types we need for
|
||||||
// these tests.
|
// these tests.
|
||||||
func restMapper() apimeta.RESTMapper {
|
func restMapper() apimeta.RESTMapper {
|
||||||
mapper := apimeta.NewDefaultRESTMapper([]schema.GroupVersion{coreapi.SchemeGroupVersion}, apimeta.InterfacesForUnstructured)
|
mapper := apimeta.NewDefaultRESTMapper([]schema.GroupVersion{coreapi.SchemeGroupVersion})
|
||||||
|
|
||||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Pod"), apimeta.RESTScopeNamespace)
|
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Pod"), apimeta.RESTScopeNamespace)
|
||||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Service"), apimeta.RESTScopeNamespace)
|
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Service"), apimeta.RESTScopeNamespace)
|
||||||
|
|
@ -132,7 +132,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
// make sure each metric got registered and can form queries
|
// make sure each metric got registered and can form queries
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
title string
|
title string
|
||||||
info provider.MetricInfo
|
info provider.CustomMetricInfo
|
||||||
namespace string
|
namespace string
|
||||||
resourceNames []string
|
resourceNames []string
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
// container metrics
|
// container metrics
|
||||||
{
|
{
|
||||||
title: "container metrics gauge / multiple resource names",
|
title: "container metrics gauge / multiple resource names",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_usage"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_usage"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "container metrics counter",
|
title: "container metrics counter",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_count"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_count"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "container metrics seconds counter",
|
title: "container metrics seconds counter",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_time"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "pods"}, true, "some_time"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
|
|
||||||
|
|
@ -166,7 +166,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
// namespaced metrics
|
// namespaced metrics
|
||||||
{
|
{
|
||||||
title: "namespaced metrics counter / multidimensional (service)",
|
title: "namespaced metrics counter / multidimensional (service)",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "service"}, true, "ingress_hits"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "service"}, true, "ingress_hits"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somesvc"},
|
resourceNames: []string{"somesvc"},
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "namespaced metrics counter / multidimensional (ingress)",
|
title: "namespaced metrics counter / multidimensional (ingress)",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Group: "extensions", Resource: "ingress"}, true, "ingress_hits"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Group: "extensions", Resource: "ingress"}, true, "ingress_hits"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"someingress"},
|
resourceNames: []string{"someingress"},
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "namespaced metrics counter / multidimensional (pod)",
|
title: "namespaced metrics counter / multidimensional (pod)",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "pod"}, true, "ingress_hits"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "pod"}, true, "ingress_hits"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somepod"},
|
resourceNames: []string{"somepod"},
|
||||||
|
|
||||||
|
|
@ -190,7 +190,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "namespaced metrics gauge",
|
title: "namespaced metrics gauge",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "service"}, true, "service_proxy_packets"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "service"}, true, "service_proxy_packets"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somesvc"},
|
resourceNames: []string{"somesvc"},
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "namespaced metrics seconds counter",
|
title: "namespaced metrics seconds counter",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Group: "extensions", Resource: "deployment"}, true, "work_queue_wait"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Group: "extensions", Resource: "deployment"}, true, "work_queue_wait"},
|
||||||
namespace: "somens",
|
namespace: "somens",
|
||||||
resourceNames: []string{"somedep"},
|
resourceNames: []string{"somedep"},
|
||||||
|
|
||||||
|
|
@ -207,21 +207,21 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
// non-namespaced series
|
// non-namespaced series
|
||||||
{
|
{
|
||||||
title: "root scoped metrics gauge",
|
title: "root scoped metrics gauge",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "node"}, false, "node_gigawatts"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "node"}, false, "node_gigawatts"},
|
||||||
resourceNames: []string{"somenode"},
|
resourceNames: []string{"somenode"},
|
||||||
|
|
||||||
expectedQuery: "sum(node_gigawatts{kube_node=\"somenode\"}) by (kube_node)",
|
expectedQuery: "sum(node_gigawatts{kube_node=\"somenode\"}) by (kube_node)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "root scoped metrics counter",
|
title: "root scoped metrics counter",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "persistentvolume"}, false, "volume_claims"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "persistentvolume"}, false, "volume_claims"},
|
||||||
resourceNames: []string{"somepv"},
|
resourceNames: []string{"somepv"},
|
||||||
|
|
||||||
expectedQuery: "sum(rate(volume_claims_total{kube_persistentvolume=\"somepv\"}[1m])) by (kube_persistentvolume)",
|
expectedQuery: "sum(rate(volume_claims_total{kube_persistentvolume=\"somepv\"}[1m])) by (kube_persistentvolume)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "root scoped metrics seconds counter",
|
title: "root scoped metrics seconds counter",
|
||||||
info: provider.MetricInfo{schema.GroupResource{Resource: "node"}, false, "node_fan"},
|
info: provider.CustomMetricInfo{schema.GroupResource{Resource: "node"}, false, "node_fan"},
|
||||||
resourceNames: []string{"somenode"},
|
resourceNames: []string{"somenode"},
|
||||||
|
|
||||||
expectedQuery: "sum(rate(node_fan_seconds_total{kube_node=\"somenode\"}[1m])) by (kube_node)",
|
expectedQuery: "sum(rate(node_fan_seconds_total{kube_node=\"somenode\"}[1m])) by (kube_node)",
|
||||||
|
|
@ -238,7 +238,7 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
allMetrics := registry.ListAllMetrics()
|
allMetrics := registry.ListAllMetrics()
|
||||||
expectedMetrics := []provider.MetricInfo{
|
expectedMetrics := []provider.CustomMetricInfo{
|
||||||
{schema.GroupResource{Resource: "pods"}, true, "some_count"},
|
{schema.GroupResource{Resource: "pods"}, true, "some_count"},
|
||||||
{schema.GroupResource{Resource: "namespaces"}, false, "some_count"},
|
{schema.GroupResource{Resource: "namespaces"}, false, "some_count"},
|
||||||
{schema.GroupResource{Resource: "pods"}, true, "some_time"},
|
{schema.GroupResource{Resource: "pods"}, true, "some_time"},
|
||||||
|
|
@ -289,8 +289,8 @@ func BenchmarkSetSeries(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// metricInfoSorter is a sort.Interface for sorting provider.MetricInfos
|
// metricInfoSorter is a sort.Interface for sorting provider.CustomMetricInfos
|
||||||
type metricInfoSorter []provider.MetricInfo
|
type metricInfoSorter []provider.CustomMetricInfo
|
||||||
|
|
||||||
func (s metricInfoSorter) Len() int {
|
func (s metricInfoSorter) Len() int {
|
||||||
return len(s)
|
return len(s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue