From 2e5bee9859ec175c3ea9472ae61daa905f690b2b Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Thu, 30 Jan 2025 12:01:00 +0100 Subject: [PATCH] feat: further extend services configuration (#9904) --- charts/kubernetes-dashboard/Chart.yaml | 2 +- .../templates/services/api.yaml | 18 +++++++++++------- .../templates/services/auth.yaml | 18 +++++++++++------- .../templates/services/metrics-scraper.yaml | 16 ++++++++++------ .../templates/services/web.yaml | 18 +++++++++++------- charts/kubernetes-dashboard/values.yaml | 12 ++++++++++++ 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/charts/kubernetes-dashboard/Chart.yaml b/charts/kubernetes-dashboard/Chart.yaml index e1ad9889dc0f..043b77bc46e8 100644 --- a/charts/kubernetes-dashboard/Chart.yaml +++ b/charts/kubernetes-dashboard/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v2 name: kubernetes-dashboard -version: 7.10.2 +version: 7.10.3 description: General-purpose web UI for Kubernetes clusters keywords: - kubernetes diff --git a/charts/kubernetes-dashboard/templates/services/api.yaml b/charts/kubernetes-dashboard/templates/services/api.yaml index 3ec0ee447bd3..bb3ff00fd01b 100644 --- a/charts/kubernetes-dashboard/templates/services/api.yaml +++ b/charts/kubernetes-dashboard/templates/services/api.yaml @@ -30,15 +30,19 @@ metadata: {{- end }} name: {{ template "kubernetes-dashboard.fullname" . }}-{{ .Values.api.role }} spec: + type: {{ .Values.api.service.type }} ports: - {{- with (index .Values.api.containers.ports 0) }} - - name: {{ .name }} - port: {{ .containerPort }} - {{ if .protocol }}protocol: {{ .protocol }}{{- end }} - {{ if .appProtocol }}appProtocol: {{ .appProtocol }}{{- end }} - {{ if .nodePort }}nodePort: {{ .nodePort }}{{- end }} - {{ if .targetPort }}targetPort: {{ .targetPort }}{{- end }} + {{- range $port := .Values.api.containers.ports }} + - name: {{ $port.name }} + port: {{ $port.containerPort }} + {{ if $port.protocol }}protocol: {{ $port.protocol }}{{- end }} + {{ if $port.appProtocol }}appProtocol: {{ $port.appProtocol }}{{- end }} + {{ if $port.nodePort }}nodePort: {{ $port.nodePort }}{{- end }} + {{ if $port.targetPort }}targetPort: {{ $port.targetPort }}{{- end }} {{- end }} + {{ with .Values.api.service.extraSpec }} + {{ . | toYaml | nindent 2 }} + {{- end }} selector: {{- include "kubernetes-dashboard.matchLabels" . | nindent 4 }} app.kubernetes.io/name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.api.role }} diff --git a/charts/kubernetes-dashboard/templates/services/auth.yaml b/charts/kubernetes-dashboard/templates/services/auth.yaml index 6e5bbb20f734..50a50054e977 100644 --- a/charts/kubernetes-dashboard/templates/services/auth.yaml +++ b/charts/kubernetes-dashboard/templates/services/auth.yaml @@ -32,15 +32,19 @@ metadata: {{- end }} name: {{ template "kubernetes-dashboard.fullname" . }}-{{ .Values.auth.role }} spec: + type: {{ .Values.auth.service.type }} ports: - {{- with (index .Values.auth.containers.ports 0) }} - - name: {{ .name }} - port: {{ .containerPort }} - {{ if .protocol }}protocol: {{ .protocol }}{{- end }} - {{ if .appProtocol }}appProtocol: {{ .appProtocol }}{{- end }} - {{ if .nodePort }}nodePort: {{ .nodePort }}{{- end }} - {{ if .targetPort }}targetPort: {{ .targetPort }}{{- end }} + {{- range $port := .Values.auth.containers.ports }} + - name: {{ $port.name }} + port: {{ $port.containerPort }} + {{ if $port.protocol }}protocol: {{ $port.protocol }}{{- end }} + {{ if $port.appProtocol }}appProtocol: {{ $port.appProtocol }}{{- end }} + {{ if $port.nodePort }}nodePort: {{ $port.nodePort }}{{- end }} + {{ if $port.targetPort }}targetPort: {{ $port.targetPort }}{{- end }} {{- end }} + {{ with .Values.auth.service.extraSpec }} + {{ . | toYaml | nindent 2 }} + {{- end }} selector: {{- include "kubernetes-dashboard.matchLabels" . | nindent 4 }} app.kubernetes.io/name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.auth.role }} diff --git a/charts/kubernetes-dashboard/templates/services/metrics-scraper.yaml b/charts/kubernetes-dashboard/templates/services/metrics-scraper.yaml index 51c9d5a6d676..884d3d570591 100644 --- a/charts/kubernetes-dashboard/templates/services/metrics-scraper.yaml +++ b/charts/kubernetes-dashboard/templates/services/metrics-scraper.yaml @@ -32,16 +32,20 @@ metadata: {{- end }} name: {{ template "kubernetes-dashboard.metrics-scraper.name" . }} spec: + type: {{ .Values.metricsScraper.service.type }} ports: - {{- with (index .Values.metricsScraper.containers.ports 0) }} + {{- range $port := .Values.metricsScraper.containers.ports }} # Name is intentionally not used here as it breaks the connection between API <-> Scraper # Named ports have an issue when trying to connect through in-cluster service proxy. - - port: {{ .containerPort }} - {{ if .protocol }}protocol: {{ .protocol }}{{- end }} - {{ if .appProtocol }}appProtocol: {{ .appProtocol }}{{- end }} - {{ if .nodePort }}nodePort: {{ .nodePort }}{{- end }} - {{ if .targetPort }}targetPort: {{ .targetPort }}{{- end }} + - port: {{ $port.containerPort }} + {{ if $port.protocol }}protocol: {{ $port.protocol }}{{- end }} + {{ if $port.appProtocol }}appProtocol: {{ $port.appProtocol }}{{- end }} + {{ if $port.nodePort }}nodePort: {{ $port.nodePort }}{{- end }} + {{ if $port.targetPort }}targetPort: {{ $port.targetPort }}{{- end }} {{- end }} + {{ with .Values.metricsScraper.service.extraSpec }} + {{ . | toYaml | nindent 2 }} + {{- end }} selector: {{- include "kubernetes-dashboard.matchLabels" . | nindent 4 }} app.kubernetes.io/name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.metricsScraper.role }} diff --git a/charts/kubernetes-dashboard/templates/services/web.yaml b/charts/kubernetes-dashboard/templates/services/web.yaml index 5c52a25267a3..97d4a6c0b896 100644 --- a/charts/kubernetes-dashboard/templates/services/web.yaml +++ b/charts/kubernetes-dashboard/templates/services/web.yaml @@ -32,15 +32,19 @@ metadata: {{- end }} name: {{ template "kubernetes-dashboard.fullname" . }}-{{ .Values.web.role }} spec: + type: {{ .Values.web.service.type }} ports: - {{- with (index .Values.web.containers.ports 0) }} - - name: {{ .name }} - port: {{ .containerPort }} - {{ if .protocol }}protocol: {{ .protocol }}{{- end }} - {{ if .appProtocol }}appProtocol: {{ .appProtocol }}{{- end }} - {{ if .nodePort }}nodePort: {{ .nodePort }}{{- end }} - {{ if .targetPort }}targetPort: {{ .targetPort }}{{- end }} + {{- range $port := .Values.web.containers.ports }} + - name: {{ $port.name }} + port: {{ $port.containerPort }} + {{ if $port.protocol }}protocol: {{ $port.protocol }}{{- end }} + {{ if $port.appProtocol }}appProtocol: {{ $port.appProtocol }}{{- end }} + {{ if $port.nodePort }}nodePort: {{ $port.nodePort }}{{- end }} + {{ if $port.targetPort }}targetPort: {{ $port.targetPort }}{{- end }} {{- end }} + {{ with .Values.web.service.extraSpec }} + {{ . | toYaml | nindent 2 }} + {{- end }} selector: {{- include "kubernetes-dashboard.matchLabels" . | nindent 4 }} app.kubernetes.io/name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.web.role }} diff --git a/charts/kubernetes-dashboard/values.yaml b/charts/kubernetes-dashboard/values.yaml index 5536f7d09e98..da3179972e92 100644 --- a/charts/kubernetes-dashboard/values.yaml +++ b/charts/kubernetes-dashboard/values.yaml @@ -149,6 +149,9 @@ auth: scaling: replicas: 1 revisionHistoryLimit: 10 + service: + type: ClusterIP + extraSpec: ~ containers: ports: - name: auth @@ -188,6 +191,9 @@ api: scaling: replicas: 1 revisionHistoryLimit: 10 + service: + type: ClusterIP + extraSpec: ~ containers: ports: - name: api @@ -245,6 +251,9 @@ web: scaling: replicas: 1 revisionHistoryLimit: 10 + service: + type: ClusterIP + extraSpec: ~ containers: ports: - name: web @@ -305,6 +314,9 @@ metricsScraper: scaling: replicas: 1 revisionHistoryLimit: 10 + service: + type: ClusterIP + extraSpec: ~ containers: ports: - containerPort: 8000