mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2026-06-01 02:17:01 +00:00
Limit ingress support to only networking.k8s.io/v1
Given the deprecation of extensions/v1beta1, remove it from Ingress possibilities. Signed-off-by: Katyanna Moura <amelie.kn@gmail.com>
This commit is contained in:
@@ -60,7 +60,7 @@ rules:
|
|||||||
verbs:
|
verbs:
|
||||||
- get
|
- get
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- extensions
|
- networking.k8s.io
|
||||||
resources:
|
resources:
|
||||||
- ingresses
|
- ingresses
|
||||||
verbs:
|
verbs:
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ rules:
|
|||||||
# only relevant if running with the flag:
|
# only relevant if running with the flag:
|
||||||
# --skipper-ingress-metrics
|
# --skipper-ingress-metrics
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- extensions
|
|
||||||
- networking.k8s.io
|
- networking.k8s.io
|
||||||
resources:
|
resources:
|
||||||
- ingresses
|
- ingresses
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ spec:
|
|||||||
- type: Object
|
- type: Object
|
||||||
object:
|
object:
|
||||||
describedObject:
|
describedObject:
|
||||||
apiVersion: extensions/v1beta1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
name: custom-metrics-consumer
|
name: custom-metrics-consumer
|
||||||
metric:
|
metric:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
apiVersion: extensions/v1beta1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: custom-metrics-consumer
|
name: custom-metrics-consumer
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ func (c *SkipperCollector) getCollector(ctx context.Context) (Collector, error)
|
|||||||
var backendWeight float64
|
var backendWeight float64
|
||||||
switch c.objectReference.Kind {
|
switch c.objectReference.Kind {
|
||||||
case "Ingress":
|
case "Ingress":
|
||||||
ingress, err := c.client.NetworkingV1beta1().Ingresses(c.objectReference.Namespace).Get(ctx, c.objectReference.Name, metav1.GetOptions{})
|
ingress, err := c.client.NetworkingV1().Ingresses(c.objectReference.Namespace).Get(ctx, c.objectReference.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
v1beta1 "k8s.io/api/networking/v1beta1"
|
netv1 "k8s.io/api/networking/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
@@ -547,29 +547,31 @@ func makeIngress(client kubernetes.Interface, namespace, resourceName, backend s
|
|||||||
}
|
}
|
||||||
annotations[anno] = string(sWeights)
|
annotations[anno] = string(sWeights)
|
||||||
}
|
}
|
||||||
ingress := &v1beta1.Ingress{
|
ingress := &netv1.Ingress{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: resourceName,
|
Name: resourceName,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
},
|
},
|
||||||
Spec: v1beta1.IngressSpec{
|
Spec: netv1.IngressSpec{
|
||||||
Backend: &v1beta1.IngressBackend{
|
DefaultBackend: &netv1.IngressBackend{
|
||||||
ServiceName: backend,
|
Service: &netv1.IngressServiceBackend{
|
||||||
|
Name: backend,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
TLS: nil,
|
TLS: nil,
|
||||||
},
|
},
|
||||||
Status: v1beta1.IngressStatus{
|
Status: netv1.IngressStatus{
|
||||||
LoadBalancer: corev1.LoadBalancerStatus{
|
LoadBalancer: corev1.LoadBalancerStatus{
|
||||||
Ingress: nil,
|
Ingress: nil,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, hostname := range hostnames {
|
for _, hostname := range hostnames {
|
||||||
ingress.Spec.Rules = append(ingress.Spec.Rules, v1beta1.IngressRule{
|
ingress.Spec.Rules = append(ingress.Spec.Rules, netv1.IngressRule{
|
||||||
Host: hostname,
|
Host: hostname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_, err := client.NetworkingV1beta1().Ingresses(namespace).Create(context.TODO(), ingress, metav1.CreateOptions{})
|
_, err := client.NetworkingV1().Ingresses(namespace).Create(context.TODO(), ingress, metav1.CreateOptions{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ func (s *MetricStore) insertCustomMetric(value custom_metrics.MetricValue) {
|
|||||||
Resource: "pods",
|
Resource: "pods",
|
||||||
}
|
}
|
||||||
case "Ingress":
|
case "Ingress":
|
||||||
// group can be either `extensions` or `networking.k8s.io`
|
group := "networking.k8s.io"
|
||||||
group := "extensions"
|
|
||||||
gv, err := schema.ParseGroupVersion(value.DescribedObject.APIVersion)
|
gv, err := schema.ParseGroupVersion(value.DescribedObject.APIVersion)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
group = gv.Group
|
group = gv.Group
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
DescribedObject: custom_metrics.ObjectReference{
|
DescribedObject: custom_metrics.ObjectReference{
|
||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -328,7 +328,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
list: []provider.CustomMetricInfo{
|
list: []provider.CustomMetricInfo{
|
||||||
{
|
{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -342,7 +342,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -358,7 +358,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
selector: labels.SelectorFromSet(labels.Set{"select_key": "select_value"}),
|
selector: labels.SelectorFromSet(labels.Set{"select_key": "select_value"}),
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -376,7 +376,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
DescribedObject: custom_metrics.ObjectReference{
|
DescribedObject: custom_metrics.ObjectReference{
|
||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -384,7 +384,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
list: []provider.CustomMetricInfo{
|
list: []provider.CustomMetricInfo{
|
||||||
{
|
{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -398,7 +398,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -414,7 +414,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
selector: labels.Everything(),
|
selector: labels.Everything(),
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -433,7 +433,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Namespace: "right",
|
Namespace: "right",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -441,7 +441,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
list: []provider.CustomMetricInfo{
|
list: []provider.CustomMetricInfo{
|
||||||
{
|
{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: true,
|
Namespaced: true,
|
||||||
@@ -455,7 +455,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
name: types.NamespacedName{Name: "metricObject", Namespace: "wrong"},
|
name: types.NamespacedName{Name: "metricObject", Namespace: "wrong"},
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: true,
|
Namespaced: true,
|
||||||
@@ -471,7 +471,7 @@ func TestInternalMetricStorage(t *testing.T) {
|
|||||||
selector: labels.Everything(),
|
selector: labels.Everything(),
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: true,
|
Namespaced: true,
|
||||||
@@ -535,7 +535,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
|||||||
DescribedObject: custom_metrics.ObjectReference{
|
DescribedObject: custom_metrics.ObjectReference{
|
||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -547,7 +547,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
|||||||
DescribedObject: custom_metrics.ObjectReference{
|
DescribedObject: custom_metrics.ObjectReference{
|
||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/v1beta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -555,7 +555,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
|||||||
list: []provider.CustomMetricInfo{
|
list: []provider.CustomMetricInfo{
|
||||||
{
|
{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -569,7 +569,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
|||||||
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
name: types.NamespacedName{Name: "metricObject", Namespace: ""},
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -585,7 +585,7 @@ func TestMultipleMetricValues(t *testing.T) {
|
|||||||
selector: labels.Everything(),
|
selector: labels.Everything(),
|
||||||
info: provider.CustomMetricInfo{
|
info: provider.CustomMetricInfo{
|
||||||
GroupResource: schema.GroupResource{
|
GroupResource: schema.GroupResource{
|
||||||
Group: "extensions",
|
Group: "networking.k8s.io",
|
||||||
Resource: "ingresses",
|
Resource: "ingresses",
|
||||||
},
|
},
|
||||||
Namespaced: false,
|
Namespaced: false,
|
||||||
@@ -831,7 +831,7 @@ func TestCustomMetricsStorageErrors(t *testing.T) {
|
|||||||
Name: "metricObject",
|
Name: "metricObject",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Kind: "Ingress",
|
Kind: "Ingress",
|
||||||
APIVersion: "extensions/vbeta1",
|
APIVersion: "networking.k8s.io/v1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user