From 246f10593dcd4febef330d7f74f6e23c4b4abdff Mon Sep 17 00:00:00 2001 From: Massimiliano Mirelli Date: Wed, 9 Mar 2022 00:09:02 +0200 Subject: [PATCH 1/3] Update Ingress API Version (`extensions/v1beta1` -> `networking.k8s.io/v1`) The change was done accordingly to the k8s deprecation guide (https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122) and taking as an example the apache pulsar helmchart (https://github.com/apache/pulsar-helm-chart/commit/83bb8bd6). The correctness of the change was only syntactally verified by the following command run against k8s server versions v1.18.20 and v1.19.16 (and respective kubectl versions). The helm version used for both runs is v3.6.3. ``` helm install "pulsar" helm-chart-sources/pulsar/ --namespace pulsar --create-namespace --values examples/dev-values.yaml --set "kube-prometheus-stack.enabled=false,extra.pulsarSQL=true,pulsarSQL.ingress.enabled=true,extra.pulsarAdminConsole=true,pulsarAdminConsole.ingress.enabled=true,proxy.ingress.enabled=true" --dry-run --debug | grep -A 30 -B 2 "kind: Ingress" ``` It should be noted that `kube-prometheus-stack.enabled=false` was necessary in order to avoid the error: ``` Error: unable to build kubernetes objects from release manifest: [unable to recognize no matches for kind "PrometheusRule" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"] helm.go:88: [debug] [unable to recognize no matches for kind "PrometheusRule" in version "monitoring.coreos.com/v1", unable to recognize "": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"] ``` --- .../pulsar-admin-console-ingress.yaml | 22 ++++++++ .../pulsar/templates/proxy/proxy-ingress.yaml | 54 ++++++++++++++++++- .../pulsar/templates/pulsarSql/ingress.yaml | 15 +++++- 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/helm-chart-sources/pulsar/templates/admin-console/pulsar-admin-console-ingress.yaml b/helm-chart-sources/pulsar/templates/admin-console/pulsar-admin-console-ingress.yaml index d6d79d4e..ec2ffc22 100644 --- a/helm-chart-sources/pulsar/templates/admin-console/pulsar-admin-console-ingress.yaml +++ b/helm-chart-sources/pulsar/templates/admin-console/pulsar-admin-console-ingress.yaml @@ -17,7 +17,11 @@ {{- if .Values.extra.pulsarAdminConsole }} {{- if .Values.pulsarAdminConsole.ingress.enabled }} +{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} apiVersion: extensions/v1beta1 +{{- else }} +apiVersion: networking.k8s.io/v1 +{{- end }} kind: Ingress metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarAdminConsole.component }}" @@ -37,13 +41,31 @@ spec: http: paths: - path: / + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarAdminConsole.component }}" servicePort: 8080 + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarAdminConsole.component }}" + port: + number: 8080 + {{- end }} - path: /ws/ + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarAdminConsole.component }}" servicePort: 8080 + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarAdminConsole.component }}" + port: + number: 8080 + {{- end }} {{- if and .Values.enableTls .Values.pulsarAdminConsole.ingress.enableTls}} tls: - hosts: diff --git a/helm-chart-sources/pulsar/templates/proxy/proxy-ingress.yaml b/helm-chart-sources/pulsar/templates/proxy/proxy-ingress.yaml index 7e55678d..aaa89259 100644 --- a/helm-chart-sources/pulsar/templates/proxy/proxy-ingress.yaml +++ b/helm-chart-sources/pulsar/templates/proxy/proxy-ingress.yaml @@ -16,7 +16,11 @@ # {{- if .Values.proxy.ingress.enabled }} +{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} apiVersion: extensions/v1beta1 +{{- else }} +apiVersion: networking.k8s.io/v1 +{{- end }} kind: Ingress metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" @@ -42,6 +46,7 @@ spec: http: paths: - path: / + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" {{- if .Values.enableTls }} @@ -49,8 +54,21 @@ spec: {{- else }} servicePort: 8080 {{- end }} + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" + port: + {{- if .Values.enableTls }} + number: 8443 + {{- else }} + number: 8080 + {{- end }} + {{- end }} {{- if .Values.proxy.ingress.enableWebSocket }} - path: /ws + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" {{- if .Values.enableTls }} @@ -58,15 +76,37 @@ spec: {{- else }} servicePort: 8000 {{- end }} + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" + port: + {{- if .Values.enableTls }} + number: {{ .Values.proxy.ingress.wssPortOnProxy }} + {{- else }} + number: 8000 + {{- end }} + {{- end }} {{- end }} {{- if .Values.proxy.ingress.enableBurnell }} - path: /br + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" servicePort: 8964 + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" + port: + number: 8964 + {{- end }} {{- end }} {{- if .Values.broker.ingress.enabled }} - path: /broker + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}" {{- if .Values.enableTls }} @@ -74,5 +114,17 @@ spec: {{- else }} servicePort: 8080 {{- end }} + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}" + port: + {{- if .Values.enableTls }} + number: 8443 + {{- else }} + number: 8080 + {{- end }} + {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml b/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml index eeb93c01..7d63e78a 100644 --- a/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml +++ b/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml @@ -17,7 +17,11 @@ {{- if .Values.extra.pulsarSQL }} {{- if .Values.pulsarSQL.ingress.enabled }} +{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} apiVersion: extensions/v1beta1 +{{- else }} +apiVersion: networking.k8s.io/v1 +{{- end }} kind: Ingress metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarSQL.component }}" @@ -37,8 +41,17 @@ spec: http: paths: - path: / + {{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version }} backend: serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarSQL.component }}" servicePort: 8080 + {{- else }} + pathType: ImplementationSpecific + backend: + service: + name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarSQL.component }}" + port: + number: 8080 + {{- end }} +{{- end }} {{- end }} -{{- end }} \ No newline at end of file From 8c6803cdc124f08a23e17be2d0481884153b8f46 Mon Sep 17 00:00:00 2001 From: Massimiliano Mirelli Date: Fri, 11 Mar 2022 17:01:46 +0200 Subject: [PATCH 2/3] Remove extra `port.number` from deployment for version > 1.19 --- helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml b/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml index 4ccab168..bbadbc36 100644 --- a/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml +++ b/helm-chart-sources/pulsar/templates/pulsarSql/ingress.yaml @@ -52,7 +52,6 @@ spec: service: name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsarSQL.component }}" port: - number: 8080 name: "http-coord" {{- end }} {{- end }} From 9bfeaa4a10ae852332a92157cdd79d77511f2026 Mon Sep 17 00:00:00 2001 From: Massimiliano Mirelli Date: Fri, 11 Mar 2022 19:38:56 +0200 Subject: [PATCH 3/3] Enable `pulsarAdminConsole` ingress --- helm-chart-sources/pulsar/ci/test-notls-values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm-chart-sources/pulsar/ci/test-notls-values.yaml b/helm-chart-sources/pulsar/ci/test-notls-values.yaml index fcddf460..04093c2c 100644 --- a/helm-chart-sources/pulsar/ci/test-notls-values.yaml +++ b/helm-chart-sources/pulsar/ci/test-notls-values.yaml @@ -108,6 +108,8 @@ grafanaDashboards: pulsarAdminConsole: replicaCount: 1 + ingress: + enabled: true kube-prometheus-stack: enabled: false