From 5a425f2fb954b755aa7f940e936ec203c37ff630 Mon Sep 17 00:00:00 2001 From: Luong Vo Date: Thu, 30 Jan 2020 16:47:52 +0700 Subject: [PATCH] Make nodeport optional In some use cases, users of kafdrop may opt for clusterIP or other K8s Service Types. This help avoid errors from helm when installing the service. Such error may be expressed as: ``` Forbidden: ... may not be used when `type` is 'ClusterIP' ``` Ref: 1. https://github.com/kubernetes/kubectl/issues/221 2. Similar issue: https://github.com/helm/charts/issues/16940 Signed-off-by: Luong Vo --- chart/templates/service.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml index c5758b8b..43466074 100644 --- a/chart/templates/service.yaml +++ b/chart/templates/service.yaml @@ -14,7 +14,9 @@ spec: targetPort: http protocol: TCP name: http - nodePort: {{ .Values.service.nodePort }} +{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{.Values.service.nodePort}} +{{ end }} selector: app.kubernetes.io/name: {{ include "chart.name" . }} app.kubernetes.io/instance: {{ .Release.Name }}