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