diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index 2220e23172b..99c7c19a02b 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -48,5 +48,4 @@ sources: - https://hub.docker.com/_/ - https://hub.docker.com/r/mikefarah/yq type: library -version: 28.2.4 - +version: 28.3.0 diff --git a/charts/library/common/templates/spawner/_service.tpl b/charts/library/common/templates/spawner/_service.tpl index b9f84703050..8d03e8b478b 100644 --- a/charts/library/common/templates/spawner/_service.tpl +++ b/charts/library/common/templates/spawner/_service.tpl @@ -8,6 +8,8 @@ {{/* Primary validation for enabled service. */}} {{- include "tc.v1.common.lib.service.primaryValidation" $ -}} + {{/* Initialize with existing URLs or an empty list */}} + {{- $allUrls := $.Values.chartContext.internalUrls | default list -}} {{- range $name, $service := .Values.service -}} {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict @@ -15,45 +17,57 @@ "name" $name "caller" "Service" "key" "service")) -}} - {{- if eq $enabled "true" -}} + {{- if ne $enabled "true" -}}{{- continue -}}{{- end -}} - {{/* Create a copy of the configmap */}} - {{- $objectData := (mustDeepCopy $service) -}} + {{/* Create a copy of the configmap */}} + {{- $objectData := (mustDeepCopy $service) -}} + {{- $namespace := (include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $ "objectData" $service "caller" "Service")) -}} - {{/* Init object name */}} - {{- $objectName := $name -}} + {{/* Init object name */}} + {{- $objectName := $name -}} - {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict - "rootCtx" $ "objectData" $objectData - "name" $name "caller" "Service" - "key" "service")) -}} - - {{- if eq $expandName "true" -}} - {{/* Expand the name of the service if expandName resolves to true */}} - {{- $objectName = $fullname -}} - {{- end -}} - - {{- if and (eq $expandName "true") (not $objectData.primary) -}} - {{/* If the service is not primary append its name to fullname */}} - {{- $objectName = (printf "%s-%s" $fullname $name) -}} - {{- end -}} - - {{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}} - - {{/* Perform validations */}} - {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} - {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service") -}} - {{- include "tc.v1.common.lib.service.validation" (dict "rootCtx" $ "objectData" $objectData) -}} - - {{/* Set the name of the service */}} - {{- $_ := set $objectData "name" $objectName -}} - {{- $_ := set $objectData "shortName" $name -}} - - {{/* Call class to create the object */}} - {{- include "tc.v1.common.class.service" (dict "rootCtx" $ "objectData" $objectData) -}} + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $ "objectData" $objectData + "name" $name "caller" "Service" + "key" "service")) -}} + {{- if eq $expandName "true" -}} + {{/* Expand the name of the service if expandName resolves to true */}} + {{- $objectName = $fullname -}} {{- end -}} + {{- if and (eq $expandName "true") (not $objectData.primary) -}} + {{/* If the service is not primary append its name to fullname */}} + {{- $objectName = (printf "%s-%s" $fullname $name) -}} + {{- end -}} + + {{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}} + + {{/* Perform validations */}} + {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $objectName) -}} + {{- include "tc.v1.common.lib.metadata.validation" (dict "objectData" $objectData "caller" "Service") -}} + {{- include "tc.v1.common.lib.service.validation" (dict "rootCtx" $ "objectData" $objectData) -}} + + {{/* Set the name of the service */}} + {{- $_ := set $objectData "name" $objectName -}} + {{- $_ := set $objectData "shortName" $name -}} + + {{/* Now iterate over the ports in the service */}} + {{- range $port := $service.ports -}} + {{- $enabledP := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $port + "name" $name "caller" "service" + "key" "port")) -}} + {{- if ne $enabledP "true" -}}{{- continue -}}{{- end -}} + {{- $internalUrl := (printf "%s.%s.svc.cluster.local:%s" $objectName $namespace $port.port) -}} + {{/* Append URLS */}} + {{- $allUrls = mustAppend $allUrls $internalUrl -}} + {{- end -}} + + {{/* Call class to create the object */}} + {{- include "tc.v1.common.class.service" (dict "rootCtx" $ "objectData" $objectData) -}} {{- end -}} + {{/* Update internalUrls after the loop */}} + {{- $_ := set $.Values.chartContext "internalUrls" $allUrls -}} {{- end -}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 3a91580e94d..fe9762e7645 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -450,6 +450,16 @@ notes: {{- end }} {{- end }} + + {{- if .Values.chartContext.internalUrls }} + ## Connecting Internally + + You can reach this chart inside your cluster, using the following service URLS: + {{- range $url := .Values.chartContext.internalUrls -}} + - {{ $url }} + {{- end }} + {{- end }} + ## Sources for {{ .Chart.Name }} {{- range .Chart.Sources }}