mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
Update deps for Kubernetes 1.8
This updates the dependencies to be compatible with Kubernetes 1.8, including the new custom.metrics.k8s.io/v1beta1 API group and the corresponding custom-metrics-apiserver changes.
This commit is contained in:
parent
cc94ef4068
commit
43bd4798b5
6 changed files with 155 additions and 92 deletions
|
|
@ -24,15 +24,31 @@ import (
|
|||
pmodel "github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
coreapi "k8s.io/api/core/v1"
|
||||
extapi "k8s.io/api/extensions/v1beta1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
|
||||
// install extensions so that our RESTMapper knows about it
|
||||
_ "k8s.io/client-go/pkg/apis/extensions/install"
|
||||
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
)
|
||||
|
||||
// restMapper creates a RESTMapper with just the types we need for
|
||||
// these tests.
|
||||
func restMapper() apimeta.RESTMapper {
|
||||
mapper := apimeta.NewDefaultRESTMapper([]schema.GroupVersion{coreapi.SchemeGroupVersion}, apimeta.InterfacesForUnstructured)
|
||||
|
||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Pod"), apimeta.RESTScopeNamespace)
|
||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Service"), apimeta.RESTScopeNamespace)
|
||||
mapper.Add(extapi.SchemeGroupVersion.WithKind("Ingress"), apimeta.RESTScopeNamespace)
|
||||
mapper.Add(extapi.SchemeGroupVersion.WithKind("Deployment"), apimeta.RESTScopeNamespace)
|
||||
|
||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Node"), apimeta.RESTScopeRoot)
|
||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("PersistentVolume"), apimeta.RESTScopeRoot)
|
||||
mapper.Add(coreapi.SchemeGroupVersion.WithKind("Namespace"), apimeta.RESTScopeRoot)
|
||||
|
||||
return mapper
|
||||
}
|
||||
|
||||
func setupMetricNamer(t *testing.T) *metricNamer {
|
||||
return &metricNamer{
|
||||
overrides: map[string]seriesSpec{
|
||||
|
|
@ -41,7 +57,7 @@ func setupMetricNamer(t *testing.T) *metricNamer {
|
|||
kind: GaugeSeries,
|
||||
},
|
||||
},
|
||||
mapper: api.Registry.RESTMapper(),
|
||||
mapper: restMapper(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ import (
|
|||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
_ "k8s.io/client-go/pkg/api/install"
|
||||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
|
|
@ -86,7 +84,7 @@ func (p *prometheusProvider) metricFor(value pmodel.SampleValue, groupResource s
|
|||
}
|
||||
|
||||
return &custom_metrics.MetricValue{
|
||||
DescribedObject: api.ObjectReference{
|
||||
DescribedObject: custom_metrics.ObjectReference{
|
||||
APIVersion: groupResource.Group + "/" + runtime.APIVersionInternal,
|
||||
Kind: kind.Kind,
|
||||
Name: name,
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
fakedyn "k8s.io/client-go/dynamic/fake"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
|
||||
// install extensions so that our RESTMapper knows about it
|
||||
_ "k8s.io/client-go/pkg/apis/extensions/install"
|
||||
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
pmodel "github.com/prometheus/common/model"
|
||||
|
|
@ -94,7 +90,7 @@ func setupPrometheusProvider(t *testing.T, stopCh <-chan struct{}) (provider.Cus
|
|||
fakeProm := &fakePromClient{}
|
||||
fakeKubeClient := &fakedyn.FakeClientPool{}
|
||||
|
||||
prov := NewPrometheusProvider(api.Registry.RESTMapper(), fakeKubeClient, fakeProm, fakeProviderUpdateInterval, 1*time.Minute, stopCh)
|
||||
prov := NewPrometheusProvider(restMapper(), fakeKubeClient, fakeProm, fakeProviderUpdateInterval, 1*time.Minute, stopCh)
|
||||
|
||||
containerSel := prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container_name", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod_name", ""))
|
||||
namespacedSel := prom.MatchSeries("", prom.LabelNeq("namespace", ""), prom.NameNotMatches("^container_.*"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue