Dashboard: New Ingress API support (networking.k8s.io/v1beta1)

Created on 21 Sep 2020  路  5Comments  路  Source: kubernetes/dashboard

Environment
Kubernetes version: v1.14+
Dashboard version: 2.*
Expected result

The dashboard uses non-deprecated versions of the APIs

Considering that the new APIs are available from version 1.14, the Dashboard fully supports 1.19 (and partially from 1.15) could it be time for the dashboard to migrate to the new API for ingresses?

To date, the APIs used are hard-coded in the code [1][2][3]. Might it make sense to parameterize the APIs based on the underlying k8s version?

[1] https://github.com/kubernetes/dashboard/blob/master/src/app/backend/resource/ingress/common.go#L19
[2] https://github.com/kubernetes/dashboard/blob/master/src/app/backend/resource/ingress/detail.go#L21
[3] https://github.com/kubernetes/dashboard/blob/master/src/app/backend/resource/ingress/list.go#L24

kinfeature

Most helpful comment

Actually if helm with lint is used, the deployment fails on recent K8S versions:

Error: malformed chart or values:
        templates/ingress.yaml: the kind "extensions/v1beta1 Ingress" is deprecated in favor of "networking.k8s.io/v1beta1 Ingress"
        templates/networkpolicy.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253
        templates/pdb.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253
        templates/psp.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253

A proper way to support also older k8s versions could be:

{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}

All 5 comments

This is something that we'll be working on in the API v2. Nevertheless, considering that API versions for different parts of kubernetes can differ we can at most move client creation logic to separate file(s) to easier migrate to newer versions.

Actually if helm with lint is used, the deployment fails on recent K8S versions:

Error: malformed chart or values:
        templates/ingress.yaml: the kind "extensions/v1beta1 Ingress" is deprecated in favor of "networking.k8s.io/v1beta1 Ingress"
        templates/networkpolicy.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253
        templates/pdb.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253
        templates/psp.yaml: object name does not conform to Kubernetes naming requirements: "": invalid metadata name, must match regex ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$ and the length must not longer than 253

A proper way to support also older k8s versions could be:

{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}

@cf-sewe if you could turn your suggestion into a PR I think it would be terrific.
If @floreks agree of course!

As an experiment, I implemented the k8s 1.19 API (networking/v1) ( #5741 ).
It is nice, but now it broke the dashboard on k8s <= 1.18, which is not something I am prod of.

Suggestions are welcome...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maciaszczykm picture maciaszczykm  路  4Comments

donspaulding picture donspaulding  路  5Comments

Fohlen picture Fohlen  路  4Comments

shu-mutou picture shu-mutou  路  3Comments

andrei-dascalu picture andrei-dascalu  路  3Comments