From f4972121bcb41c8d74748917804d2b239ab757f9 Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Thu, 7 Oct 2021 17:18:37 -0700 Subject: [PATCH] Migrate Ingress resources to networking.k8s.io/v1 This change updates the helm-toolkit and ingress charts to migrate Ingress resources to the networking.k8s.io/v1 API version, available since v1.19. [0] 0: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122 Change-Id: Ic6bd6d158b1294da26c165797c90107831dcb508 --- helm-toolkit/Chart.yaml | 2 +- helm-toolkit/templates/manifests/_ingress.tpl | 180 ++++++++++++------ ingress/Chart.yaml | 2 +- ingress/templates/ingress.yaml | 15 +- releasenotes/notes/helm-toolkit.yaml | 1 + releasenotes/notes/ingress.yaml | 1 + 6 files changed, 141 insertions(+), 60 deletions(-) diff --git a/helm-toolkit/Chart.yaml b/helm-toolkit/Chart.yaml index c9a13eed4..9c8915a8d 100644 --- a/helm-toolkit/Chart.yaml +++ b/helm-toolkit/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Helm-Toolkit name: helm-toolkit -version: 0.2.23 +version: 0.2.24 home: https://docs.openstack.org/openstack-helm icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png sources: diff --git a/helm-toolkit/templates/manifests/_ingress.tpl b/helm-toolkit/templates/manifests/_ingress.tpl index 2d62a1701..c1693aa4e 100644 --- a/helm-toolkit/templates/manifests/_ingress.tpl +++ b/helm-toolkit/templates/manifests/_ingress.tpl @@ -62,7 +62,7 @@ examples: {{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" "endpoint" "public" ) -}} return: | --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican @@ -76,25 +76,34 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default.svc.cluster.local http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican-namespace-fqdn @@ -112,11 +121,14 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican-cluster-fqdn @@ -134,9 +146,12 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - values: | network: api: @@ -182,7 +197,7 @@ examples: {{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" "endpoint" "public" ) -}} return: | --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican @@ -202,23 +217,32 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default.svc.cluster.local http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - values: | cert_issuer_type: issuer network: @@ -273,7 +297,7 @@ examples: {{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" "endpoint" "public" "certIssuer" "ca-issuer" ) -}} return: | --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican @@ -295,23 +319,32 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default.svc.cluster.local http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - values: | network: @@ -366,7 +399,7 @@ examples: {{- include "helm-toolkit.manifests.ingress" ( dict "envAll" . "backendServiceType" "key-manager" "backendPort" "b-api" "endpoint" "public" "certIssuer" "ca-issuer") -}} return: | --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: barbican @@ -388,23 +421,32 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api - host: barbican.default.svc.cluster.local http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: barbican-api - servicePort: b-api + service: + name: barbican-api + port: + name: b-api # Sample usage for multiple DNS names associated with the same public # endpoint and certificate - values: | @@ -441,7 +483,7 @@ examples: {{ $ingressOpts | include "helm-toolkit.manifests.ingress" }} return: | --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: grafana @@ -455,25 +497,34 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard - host: grafana.default http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard - host: grafana.default.svc.cluster.local http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: grafana-namespace-fqdn @@ -492,18 +543,24 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard - host: grafana-alt.openstackhelm.example http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard --- - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: grafana-cluster-fqdn @@ -522,16 +579,22 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard - host: grafana-alt.openstackhelm.example http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: grafana-dashboard - servicePort: dashboard + service: + name: grafana-dashboard + port: + name: dashboard */}} @@ -543,9 +606,16 @@ examples: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: {{ $backendName }} - servicePort: {{ $backendPort }} + service: + name: {{ $backendName }} + port: +{{- if or (kindIs "int" $backendPort) (regexMatch "^[0-9]{1,5}$" $backendPort) }} + number: {{ $backendPort | int }} +{{- else }} + name: {{ $backendPort | quote }} +{{- end }} {{- end }} {{- define "helm-toolkit.manifests.ingress" -}} @@ -564,7 +634,7 @@ examples: {{- $certIssuerType = $envAll.Values.cert_issuer_type }} {{- end }} --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ $ingressName }} @@ -618,7 +688,7 @@ spec: {{- range $key2, $ingressController := tuple "namespace" "cluster" }} {{- $vHosts := list $hostNameFull }} --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ printf "%s-%s-%s" $ingressName $ingressController "fqdn" }} diff --git a/ingress/Chart.yaml b/ingress/Chart.yaml index ac26b0ea0..a0f32c9e6 100644 --- a/ingress/Chart.yaml +++ b/ingress/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v0.42.0 description: OpenStack-Helm Ingress Controller name: ingress -version: 0.2.4 +version: 0.2.5 home: https://github.com/kubernetes/ingress sources: - https://github.com/kubernetes/ingress diff --git a/ingress/templates/ingress.yaml b/ingress/templates/ingress.yaml index ecc275e86..1f67c7a70 100644 --- a/ingress/templates/ingress.yaml +++ b/ingress/templates/ingress.yaml @@ -18,8 +18,10 @@ limitations under the License. {{- if empty (index .Values.network.ingress.annotations "kubernetes.io/ingress.class") -}} {{- $_ := set .Values.network.ingress.annotations "kubernetes.io/ingress.class" .Values.deployment.cluster.class -}} {{- end -}} +{{- $serviceName := tuple "ingress" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" -}} +{{- $servicePort := tuple "ingress" "internal" "http" . | include "helm-toolkit.endpoints.endpoint_port_lookup" -}} --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ .Release.Namespace }}-{{ .Release.Name }} @@ -31,8 +33,15 @@ spec: http: paths: - path: / + pathType: ImplementationSpecific backend: - serviceName: {{ tuple "ingress" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} - servicePort: {{ tuple "ingress" "internal" "http" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + service: + name: {{ $serviceName }} + port: +{{- if or (kindIs "int" $servicePort) (regexMatch "^[0-9]{1,5}$" $servicePort) }} + number: {{ $servicePort | int }} +{{- else }} + name: {{ $servicePort | quote }} +{{- end }} {{- end }} {{- end }} diff --git a/releasenotes/notes/helm-toolkit.yaml b/releasenotes/notes/helm-toolkit.yaml index f2fbb6e8b..669ba9617 100644 --- a/releasenotes/notes/helm-toolkit.yaml +++ b/releasenotes/notes/helm-toolkit.yaml @@ -30,4 +30,5 @@ helm-toolkit: - 0.2.21 Fix issue with db backup error return code being eaten - 0.2.22 Add ability to set labels to add to resources - 0.2.23 Helm 3 - Fix Job labels + - 0.2.24 Migrate Ingress resources to networking.k8s.io/v1 ... diff --git a/releasenotes/notes/ingress.yaml b/releasenotes/notes/ingress.yaml index 19bbb447d..cd9cd50d3 100644 --- a/releasenotes/notes/ingress.yaml +++ b/releasenotes/notes/ingress.yaml @@ -8,4 +8,5 @@ ingress: - 0.2.2 Use full image ref for docker official images - 0.2.3 Uplift ingress to 0.42.0 - 0.2.4 Update htk requirements + - 0.2.5 Migrate Ingress resources to networking.k8s.io/v1 ...