diff --git a/.golangci.yml b/.golangci.yml index 07d83e4da2..42dc3ab9ab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,11 +30,6 @@ linters: - linters: - revive text: 'package-comments:|var-naming:' - # This needs to stay as long as we support exposing v1.endpoints metrics - - linters: - - staticcheck - text: 'SA1019: v1.Endpoint' - path: 'internal/store/endpoint.*.go|internal/store/builder.go' # TODO: Use functions with context https://github.com/kubernetes/kube-state-metrics/issues/2721 - linters: - staticcheck diff --git a/docs/README.md b/docs/README.md index ad68cf054b..36a4fb1c80 100644 --- a/docs/README.md +++ b/docs/README.md @@ -38,7 +38,6 @@ See each file for specific documentation about the exposed metrics: * [CronJob Metrics](metrics/workload/cronjob-metrics.md) * [DaemonSet Metrics](metrics/workload/daemonset-metrics.md) * [Deployment Metrics](metrics/workload/deployment-metrics.md) -* [Endpoint Metrics](metrics/service/endpoint-metrics.md) * [Horizontal Pod Autoscaler Metrics](metrics/workload/horizontalpodautoscaler-metrics.md) * [Ingress Metrics](metrics/service/ingress-metrics.md) * [Job Metrics](metrics/workload/job-metrics.md) diff --git a/docs/metrics/service/endpoint-metrics.md b/docs/metrics/service/endpoint-metrics.md deleted file mode 100644 index da4152d9c3..0000000000 --- a/docs/metrics/service/endpoint-metrics.md +++ /dev/null @@ -1,10 +0,0 @@ -# Endpoint Metrics - -| Metric name | Metric type | Description | Labels/tags | Status | -| ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | -| kube_endpoint_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`annotation_ENDPOINT_ANNOTATION`=<ENDPOINT_ANNOTATION> | EXPERIMENTAL | -| kube_endpoint_info | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | -| kube_endpoint_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`label_ENDPOINT_LABEL`=<ENDPOINT_LABEL> | STABLE | -| kube_endpoint_created | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | -| kube_endpoint_ports | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number> | STABLE (Deprecated from 2.14.0) | -| kube_endpoint_address | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`ip`=<endpoint-ip>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number>`ready`=<true if available, false if unavailalbe> | STABLE | diff --git a/examples/autosharding/cluster-role.yaml b/examples/autosharding/cluster-role.yaml index cc0cc0eaea..0642869634 100644 --- a/examples/autosharding/cluster-role.yaml +++ b/examples/autosharding/cluster-role.yaml @@ -22,7 +22,6 @@ rules: - persistentvolumeclaims - persistentvolumes - namespaces - - endpoints verbs: - list - watch diff --git a/examples/daemonsetsharding/cluster-role.yaml b/examples/daemonsetsharding/cluster-role.yaml index cc0cc0eaea..0642869634 100644 --- a/examples/daemonsetsharding/cluster-role.yaml +++ b/examples/daemonsetsharding/cluster-role.yaml @@ -22,7 +22,6 @@ rules: - persistentvolumeclaims - persistentvolumes - namespaces - - endpoints verbs: - list - watch diff --git a/examples/deploymentsharding/cluster-role.yaml b/examples/deploymentsharding/cluster-role.yaml index cc0cc0eaea..0642869634 100644 --- a/examples/deploymentsharding/cluster-role.yaml +++ b/examples/deploymentsharding/cluster-role.yaml @@ -22,7 +22,6 @@ rules: - persistentvolumeclaims - persistentvolumes - namespaces - - endpoints verbs: - list - watch diff --git a/examples/standard/cluster-role.yaml b/examples/standard/cluster-role.yaml index cc0cc0eaea..0642869634 100644 --- a/examples/standard/cluster-role.yaml +++ b/examples/standard/cluster-role.yaml @@ -22,7 +22,6 @@ rules: - persistentvolumeclaims - persistentvolumes - namespaces - - endpoints verbs: - list - watch diff --git a/internal/store/builder.go b/internal/store/builder.go index 04df9e400a..a52091b102 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -330,7 +330,6 @@ var availableStores = map[string]func(f *Builder) []cache.Store{ "cronjobs": func(b *Builder) []cache.Store { return b.buildCronJobStores() }, "daemonsets": func(b *Builder) []cache.Store { return b.buildDaemonSetStores() }, "deployments": func(b *Builder) []cache.Store { return b.buildDeploymentStores() }, - "endpoints": func(b *Builder) []cache.Store { return b.buildEndpointsStores() }, "endpointslices": func(b *Builder) []cache.Store { return b.buildEndpointSlicesStores() }, "horizontalpodautoscalers": func(b *Builder) []cache.Store { return b.buildHPAStores() }, "ingresses": func(b *Builder) []cache.Store { return b.buildIngressStores() }, @@ -389,10 +388,6 @@ func (b *Builder) buildDeploymentStores() []cache.Store { return b.buildStoresFunc(deploymentMetricFamilies(b.allowAnnotationsList["deployments"], b.allowLabelsList["deployments"]), &appsv1.Deployment{}, createDeploymentListWatch, b.useAPIServerCache, b.objectLimit) } -func (b *Builder) buildEndpointsStores() []cache.Store { - return b.buildStoresFunc(endpointMetricFamilies(b.allowAnnotationsList["endpoints"], b.allowLabelsList["endpoints"]), &v1.Endpoints{}, createEndpointsListWatch, b.useAPIServerCache, b.objectLimit) -} - func (b *Builder) buildEndpointSlicesStores() []cache.Store { return b.buildStoresFunc(endpointSliceMetricFamilies(b.allowAnnotationsList["endpointslices"], b.allowLabelsList["endpointslices"]), &discoveryv1.EndpointSlice{}, createEndpointSliceListWatch, b.useAPIServerCache, b.objectLimit) } diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go deleted file mode 100644 index fddfa4fde5..0000000000 --- a/internal/store/endpoint.go +++ /dev/null @@ -1,213 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package store - -import ( - "context" - "strconv" - - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - clientset "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/cache" - basemetrics "k8s.io/component-base/metrics" - - "k8s.io/kube-state-metrics/v2/pkg/metric" - generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" -) - -var ( - descEndpointAnnotationsName = "kube_endpoint_annotations" - descEndpointAnnotationsHelp = "Kubernetes annotations converted to Prometheus labels." - descEndpointLabelsName = "kube_endpoint_labels" - descEndpointLabelsHelp = "Kubernetes labels converted to Prometheus labels." - descEndpointLabelsDefaultLabels = []string{"namespace", "endpoint"} -) - -func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { - return []generator.FamilyGenerator{ - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_info", - "Information about endpoint.", - metric.Gauge, - basemetrics.STABLE, - "", - wrapEndpointFunc(func(_ *v1.Endpoints) *metric.Family { - return &metric.Family{ - Metrics: []*metric.Metric{ - { - Value: 1, - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_created", - "Unix creation timestamp", - metric.Gauge, - basemetrics.STABLE, - "", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - ms := []*metric.Metric{} - - if !e.CreationTimestamp.IsZero() { - ms = append(ms, &metric.Metric{ - - Value: float64(e.CreationTimestamp.Unix()), - }) - } - - return &metric.Family{ - Metrics: ms, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - descEndpointAnnotationsName, - descEndpointAnnotationsHelp, - metric.Gauge, - basemetrics.ALPHA, - "", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - if len(allowAnnotationsList) == 0 { - return &metric.Family{} - } - annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", e.Annotations, allowAnnotationsList) - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: annotationKeys, - LabelValues: annotationValues, - Value: 1, - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - descEndpointLabelsName, - descEndpointLabelsHelp, - metric.Gauge, - basemetrics.STABLE, - "", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - if len(allowLabelsList) == 0 { - return &metric.Family{} - } - labelKeys, labelValues := createPrometheusLabelKeysValues("label", e.Labels, allowLabelsList) - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: labelKeys, - LabelValues: labelValues, - Value: 1, - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_address", - "Information about Endpoint available and non available addresses.", - metric.Gauge, - basemetrics.STABLE, - "", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - ms := []*metric.Metric{} - labelKeys := []string{"port_protocol", "port_number", "port_name", "ip", "ready"} - - for _, s := range e.Subsets { - for _, port := range s.Ports { - for _, available := range s.Addresses { - labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10), port.Name} - - ms = append(ms, &metric.Metric{ - LabelValues: append(labelValues, available.IP, "true"), - LabelKeys: labelKeys, - Value: 1, - }) - } - for _, notReadyAddresses := range s.NotReadyAddresses { - labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10), port.Name} - - ms = append(ms, &metric.Metric{ - LabelValues: append(labelValues, notReadyAddresses.IP, "false"), - LabelKeys: labelKeys, - Value: 1, - }) - } - } - } - return &metric.Family{ - Metrics: ms, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_ports", - "Information about the Endpoint ports.", - metric.Gauge, - basemetrics.STABLE, - "v2.14.0", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - ms := []*metric.Metric{} - for _, s := range e.Subsets { - for _, port := range s.Ports { - ms = append(ms, &metric.Metric{ - LabelValues: []string{port.Name, string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)}, - LabelKeys: []string{"port_name", "port_protocol", "port_number"}, - Value: 1, - }) - } - } - return &metric.Family{ - Metrics: ms, - } - }), - ), - } -} - -func wrapEndpointFunc(f func(*v1.Endpoints) *metric.Family) func(interface{}) *metric.Family { - return func(obj interface{}) *metric.Family { - endpoint := obj.(*v1.Endpoints) - - metricFamily := f(endpoint) - - for _, m := range metricFamily.Metrics { - m.LabelKeys, m.LabelValues = mergeKeyValues(descEndpointLabelsDefaultLabels, []string{endpoint.Namespace, endpoint.Name}, m.LabelKeys, m.LabelValues) - } - - return metricFamily - } -} - -func createEndpointsListWatch(kubeClient clientset.Interface, ns string, fieldSelector string) cache.ListerWatcher { - return &cache.ListWatch{ - ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { - opts.FieldSelector = fieldSelector - return kubeClient.CoreV1().Endpoints(ns).List(context.TODO(), opts) - }, - WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { - opts.FieldSelector = fieldSelector - return kubeClient.CoreV1().Endpoints(ns).Watch(context.TODO(), opts) - }, - } -} diff --git a/internal/store/endpoint_test.go b/internal/store/endpoint_test.go deleted file mode 100644 index b38374767d..0000000000 --- a/internal/store/endpoint_test.go +++ /dev/null @@ -1,291 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package store - -import ( - "testing" - "time" - - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" -) - -func TestEndpointStore(t *testing.T) { - // Fixed metadata on type and help text. We prepend this to every expected - // output so we only have to modify a single place when doing adjustments. - const metadata = ` - # HELP kube_endpoint_annotations Kubernetes annotations converted to Prometheus labels. - # TYPE kube_endpoint_annotations gauge - # HELP kube_endpoint_created [STABLE] Unix creation timestamp - # TYPE kube_endpoint_created gauge - # HELP kube_endpoint_info [STABLE] Information about endpoint. - # TYPE kube_endpoint_info gauge - # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. - # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports [STABLE] (Deprecated since v2.14.0) Information about the Endpoint ports. - # TYPE kube_endpoint_ports gauge - # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. - # TYPE kube_endpoint_address gauge - ` - cases := []generateMetricsTestCase{ - { - Obj: &v1.Endpoints{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-endpoint", - CreationTimestamp: metav1.Time{Time: time.Unix(1500000000, 0)}, - Namespace: "default", - Labels: map[string]string{ - "app": "foobar", - }, - }, - Subsets: []v1.EndpointSubset{ - { - Addresses: []v1.EndpointAddress{ - {IP: "127.0.0.1"}, {IP: "10.0.0.1"}, - }, - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "10.0.0.10"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8080, Name: "http", Protocol: v1.ProtocolTCP}, {Port: 8081, Name: "app", Protocol: v1.ProtocolTCP}, - }, - }, - { - Addresses: []v1.EndpointAddress{ - {IP: "172.22.23.202"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8443, Name: "https", Protocol: v1.ProtocolTCP}, {Port: 9090, Name: "prometheus", Protocol: v1.ProtocolTCP}, - }, - }, - { - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "192.168.1.3"}, {IP: "192.168.2.2"}, - }, - Ports: []v1.EndpointPort{ - {Port: 1234, Name: "syslog", Protocol: v1.ProtocolUDP}, {Port: 5678, Name: "syslog-tcp", Protocol: v1.ProtocolTCP}, - }, - }, - }, - }, - Want: metadata + ` - kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09 - kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="https",port_number="8443",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="prometheus",port_number="9090",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="http",port_protocol="TCP",port_number="8080"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="app",port_protocol="TCP",port_number="8081"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="https",port_protocol="TCP",port_number="8443"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1 - `, - }, - { - Obj: &v1.Endpoints{ - ObjectMeta: metav1.ObjectMeta{ - Name: "single-port-endpoint", - CreationTimestamp: metav1.Time{Time: time.Unix(1500000000, 0)}, - Namespace: "default", - Labels: map[string]string{ - "app": "single-foobar", - }, - }, - Subsets: []v1.EndpointSubset{ - { - Addresses: []v1.EndpointAddress{ - {IP: "127.0.0.1"}, {IP: "10.0.0.1"}, - }, - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "10.0.0.10"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8080, Protocol: v1.ProtocolTCP}, - }, - }, - }, - }, - Want: metadata + ` - kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 - kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 - kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 - `, - }, - } - for i, c := range cases { - c.Func = generator.ComposeMetricGenFuncs(endpointMetricFamilies(nil, nil)) - c.Headers = generator.ExtractMetricFamilyHeaders(endpointMetricFamilies(nil, nil)) - if err := c.run(); err != nil { - t.Errorf("unexpected collecting result in %vth run:\n%s", i, err) - } - } -} - -func TestEndpointStoreWithLabels(t *testing.T) { - // Fixed metadata on type and help text. We prepend this to every expected - // output so we only have to modify a single place when doing adjustments. - const metadata = ` - # HELP kube_endpoint_annotations Kubernetes annotations converted to Prometheus labels. - # TYPE kube_endpoint_annotations gauge - # HELP kube_endpoint_created [STABLE] Unix creation timestamp - # TYPE kube_endpoint_created gauge - # HELP kube_endpoint_info [STABLE] Information about endpoint. - # TYPE kube_endpoint_info gauge - # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. - # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports [STABLE] (Deprecated since v2.14.0) Information about the Endpoint ports. - # TYPE kube_endpoint_ports gauge - # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. - # TYPE kube_endpoint_address gauge - ` - cases := []generateMetricsTestCase{ - { - Obj: &v1.Endpoints{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-endpoint", - CreationTimestamp: metav1.Time{Time: time.Unix(1500000000, 0)}, - Namespace: "default", - Annotations: map[string]string{ - "app": "foobar", - }, - Labels: map[string]string{ - "app": "foobar", - }, - }, - Subsets: []v1.EndpointSubset{ - { - Addresses: []v1.EndpointAddress{ - {IP: "127.0.0.1"}, {IP: "10.0.0.1"}, - }, - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "10.0.0.10"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8080, Name: "http", Protocol: v1.ProtocolTCP}, {Port: 8081, Name: "app", Protocol: v1.ProtocolTCP}, - }, - }, - { - Addresses: []v1.EndpointAddress{ - {IP: "172.22.23.202"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8443, Name: "https", Protocol: v1.ProtocolTCP}, {Port: 9090, Name: "prometheus", Protocol: v1.ProtocolTCP}, - }, - }, - { - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "192.168.1.3"}, {IP: "192.168.2.2"}, - }, - Ports: []v1.EndpointPort{ - {Port: 1234, Name: "syslog", Protocol: v1.ProtocolUDP}, {Port: 5678, Name: "syslog-tcp", Protocol: v1.ProtocolTCP}, - }, - }, - }, - }, - Want: metadata + ` - kube_endpoint_annotations{endpoint="test-endpoint",annotation_app="foobar",namespace="default"} 1 - kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09 - kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1 - kube_endpoint_labels{endpoint="test-endpoint",label_app="foobar",namespace="default"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="http",port_protocol="TCP",port_number="8080"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="app",port_protocol="TCP",port_number="8081"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="https",port_protocol="TCP",port_number="8443"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1 - kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="https",port_number="8443",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="prometheus",port_number="9090",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 - `, - }, - { - Obj: &v1.Endpoints{ - ObjectMeta: metav1.ObjectMeta{ - Name: "single-port-endpoint", - CreationTimestamp: metav1.Time{Time: time.Unix(1500000000, 0)}, - Namespace: "default", - Annotations: map[string]string{ - "app": "single-foobar", - }, - Labels: map[string]string{ - "app": "single-foobar", - }, - }, - Subsets: []v1.EndpointSubset{ - { - Addresses: []v1.EndpointAddress{ - {IP: "127.0.0.1"}, {IP: "10.0.0.1"}, - }, - NotReadyAddresses: []v1.EndpointAddress{ - {IP: "10.0.0.10"}, - }, - Ports: []v1.EndpointPort{ - {Port: 8080, Protocol: v1.ProtocolTCP}, - }, - }, - }, - }, - Want: metadata + ` - kube_endpoint_annotations{endpoint="single-port-endpoint",annotation_app="single-foobar",namespace="default"} 1 - kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 - kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 - kube_endpoint_labels{endpoint="single-port-endpoint",label_app="single-foobar",namespace="default"} 1 - kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 - `, - }, - } - for i, c := range cases { - allowAnnotations := []string{ - "app", - } - allowLabels := []string{ - "app", - } - c.Func = generator.ComposeMetricGenFuncs(endpointMetricFamilies(allowAnnotations, allowLabels)) - c.Headers = generator.ExtractMetricFamilyHeaders(endpointMetricFamilies(allowAnnotations, allowLabels)) - if err := c.run(); err != nil { - t.Errorf("unexpected collecting result in %vth run:\n%s", i, err) - } - } -} diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index f3deeb026b..5dd739e178 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -57,7 +57,6 @@ 'persistentvolumeclaims', 'persistentvolumes', 'namespaces', - 'endpoints', ], verbs: ['list', 'watch'], }, diff --git a/tests/e2e/main_test.go b/tests/e2e/main_test.go index 441053fd04..637833262a 100644 --- a/tests/e2e/main_test.go +++ b/tests/e2e/main_test.go @@ -282,7 +282,6 @@ func TestDefaultCollectorMetricsAvailable(t *testing.T) { nonDefaultResources := map[string]bool{ "clusterrole": true, "clusterrolebinding": true, - "endpoint": true, "ingressclass": true, "role": true, "rolebinding": true,