diff --git a/charts/statefull/Chart.yaml b/charts/statefull/Chart.yaml index a075991..86cd05d 100644 --- a/charts/statefull/Chart.yaml +++ b/charts/statefull/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart for statefull vality services name: statefull -version: 1.0.35 \ No newline at end of file +version: 1.0.36 \ No newline at end of file diff --git a/charts/statefull/templates/_helpers.tpl b/charts/statefull/templates/_helpers.tpl index 15dd584..99ae7cf 100644 --- a/charts/statefull/templates/_helpers.tpl +++ b/charts/statefull/templates/_helpers.tpl @@ -89,16 +89,15 @@ Build secretName for tls {{/* Normalize a single path entry. -Input: { entry: , fullName: , defaultPort: } +Input: { entry: , defaultPort: , serviceName: } Output: YAML string with keys: path, serviceName, port (contains number or name field) */}} {{- define "statefull.ingress.normalizePath" -}} {{- $entry := index . "entry" -}} - {{- $fullName := index . "fullName" -}} + {{- $serviceName := index . "serviceName" -}} {{- $defaultPort := index . "defaultPort" -}} {{- $path := "/" -}} - {{- $serviceName := $fullName -}} {{- $port := dict "number" $defaultPort -}} {{- if kindIs "string" $entry }} @@ -118,4 +117,12 @@ Output: YAML string with keys: path, serviceName, port (contains number or name {{- end }} {{- toYaml (dict "path" $path "serviceName" $serviceName "port" $port) | trimSuffix "\n" -}} -{{- end }} \ No newline at end of file +{{- end }} + +{{- define "statefull.servicename" -}} +{{- if .Values.servicenameOverride -}} +{{- .Values.servicenameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- include "statefull.fullname" . | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/statefull/templates/extra-ingress-alb.yaml b/charts/statefull/templates/extra-ingress-alb.yaml index 437151c..7cbf384 100644 --- a/charts/statefull/templates/extra-ingress-alb.yaml +++ b/charts/statefull/templates/extra-ingress-alb.yaml @@ -1,6 +1,7 @@ {{- range $entryIngress := .Values.extraIngress }} {{- if and $entryIngress.enabled (eq $entryIngress.ingressClassName "alb") }} {{- $fullName := include "statefull.fullname" $ }} +{{- $svcName := include "statefull.servicename" $ }} {{- $svcPort := $entryIngress.servicePort }} --- apiVersion: networking.k8s.io/v1 @@ -28,7 +29,7 @@ spec: {{- $host := include "statefull.ingress.fqdn" (dict "ctx" $ "domain" $domain) }} - {{ $host | quote }} {{- end }} - secretName: {{ $entryIngress.name }}-{{ include "stateless.ingress.secretName" $ }} + secretName: {{ $entryIngress.name }}-{{ include "statefull.ingress.secretName" $ }} {{- end }} rules: @@ -38,7 +39,7 @@ spec: http: paths: {{- range $entry := $entryIngress.paths }} - {{- $parsed := include "statefull.ingress.normalizePath" (dict "entry" $entry "fullName" $fullName "defaultPort" $svcPort) | fromYaml }} + {{- $parsed := include "statefull.ingress.normalizePath" (dict "entry" $entry "defaultPort" $svcPort "serviceName" $svcName) | fromYaml }} {{- $path := index $parsed "path" }} {{- $serviceName := index $parsed "serviceName" }} {{- $portObj := index $parsed "port" }} diff --git a/charts/statefull/templates/ingress-alb.yaml b/charts/statefull/templates/ingress-alb.yaml index f2f0181..44d4cb8 100644 --- a/charts/statefull/templates/ingress-alb.yaml +++ b/charts/statefull/templates/ingress-alb.yaml @@ -7,6 +7,7 @@ {{- $annotations := .annotations }} {{- $fullName := include "statefull.fullname" $ }} {{- $kVer := $.Capabilities.KubeVersion.GitVersion }} +{{- $svcName := include "statefull.servicename" $ }} {{- $svcPort := $.Values.ingress.servicePort }} --- {{- if semverCompare ">=1.19.0-0" $kVer }} @@ -48,7 +49,7 @@ spec: http: paths: {{- range $entry := $.Values.ingress.paths }} - {{- $parsed := include "statefull.ingress.normalizePath" (dict "entry" $entry "fullName" $fullName "defaultPort" $svcPort) | fromYaml }} + {{- $parsed := include "statefull.ingress.normalizePath" (dict "entry" $entry "defaultPort" $svcPort "serviceName" $svcName) | fromYaml }} {{- $path := index $parsed "path" }} {{- $serviceName := index $parsed "serviceName" }} {{- $portObj := index $parsed "port" }} diff --git a/charts/statefull/templates/service.yaml b/charts/statefull/templates/service.yaml index ec1f198..56d5d4b 100644 --- a/charts/statefull/templates/service.yaml +++ b/charts/statefull/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "statefull.fullname" . }} + name: {{ include "statefull.servicename" . }} labels: {{ include "statefull.labels" . | indent 4 }} spec: diff --git a/charts/statefull/values.yaml b/charts/statefull/values.yaml index 9c81e1e..0ddc6ce 100644 --- a/charts/statefull/values.yaml +++ b/charts/statefull/values.yaml @@ -12,6 +12,7 @@ image: imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +servicenameOverride: "" serviceAccount: create: true diff --git a/charts/stateless/Chart.yaml b/charts/stateless/Chart.yaml index 9ea500a..e232269 100644 --- a/charts/stateless/Chart.yaml +++ b/charts/stateless/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart for stateless vality services name: stateless -version: 1.0.50 \ No newline at end of file +version: 1.0.51 \ No newline at end of file diff --git a/charts/stateless/templates/_helpers.tpl b/charts/stateless/templates/_helpers.tpl index 8dca80e..e1f15db 100644 --- a/charts/stateless/templates/_helpers.tpl +++ b/charts/stateless/templates/_helpers.tpl @@ -89,16 +89,15 @@ Build secretName for tls {{/* Normalize a single path entry. -Input: { entry: , fullName: , defaultPort: } +Input: { entry: , defaultPort: , serviceName: } Output: YAML string with keys: path, serviceName, port (contains number or name field) */}} {{- define "stateless.ingress.normalizePath" -}} {{- $entry := index . "entry" -}} - {{- $fullName := index . "fullName" -}} + {{- $serviceName := index . "serviceName" -}} {{- $defaultPort := index . "defaultPort" -}} {{- $path := "/" -}} - {{- $serviceName := $fullName -}} {{- $port := dict "number" $defaultPort -}} {{- if kindIs "string" $entry }} @@ -118,4 +117,12 @@ Output: YAML string with keys: path, serviceName, port (contains number or name {{- end }} {{- toYaml (dict "path" $path "serviceName" $serviceName "port" $port) | trimSuffix "\n" -}} -{{- end }} \ No newline at end of file +{{- end }} + +{{- define "stateless.servicename" -}} +{{- if .Values.servicenameOverride -}} +{{- .Values.servicenameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- include "stateless.fullname" . | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/stateless/templates/extra-ingress-alb.yaml b/charts/stateless/templates/extra-ingress-alb.yaml index ea2c8f7..adbc1ba 100644 --- a/charts/stateless/templates/extra-ingress-alb.yaml +++ b/charts/stateless/templates/extra-ingress-alb.yaml @@ -1,6 +1,7 @@ {{- range $entryIngress := .Values.extraIngress }} {{- if and $entryIngress.enabled (eq $entryIngress.ingressClassName "alb") }} {{- $fullName := include "stateless.fullname" $ }} +{{- $svcName := include "stateless.servicename" $ }} {{- $svcPort := $entryIngress.servicePort }} --- apiVersion: networking.k8s.io/v1 @@ -38,7 +39,7 @@ spec: http: paths: {{- range $entry := $entryIngress.paths }} - {{- $parsed := include "stateless.ingress.normalizePath" (dict "entry" $entry "fullName" $fullName "defaultPort" $svcPort) | fromYaml }} + {{- $parsed := include "stateless.ingress.normalizePath" (dict "entry" $entry "defaultPort" $svcPort "serviceName" $svcName) | fromYaml }} {{- $path := index $parsed "path" }} {{- $serviceName := index $parsed "serviceName" }} {{- $portObj := index $parsed "port" }} diff --git a/charts/stateless/templates/ingress-alb.yaml b/charts/stateless/templates/ingress-alb.yaml index 03e7887..4a94b86 100644 --- a/charts/stateless/templates/ingress-alb.yaml +++ b/charts/stateless/templates/ingress-alb.yaml @@ -7,6 +7,7 @@ {{- $annotations := .annotations }} {{- $fullName := include "stateless.fullname" $ }} {{- $kVer := $.Capabilities.KubeVersion.GitVersion }} +{{- $svcName := include "stateless.servicename" $ }} {{- $svcPort := $.Values.ingress.servicePort }} --- {{- if semverCompare ">=1.19.0-0" $kVer }} @@ -48,7 +49,7 @@ spec: http: paths: {{- range $entry := $.Values.ingress.paths }} - {{- $parsed := include "stateless.ingress.normalizePath" (dict "entry" $entry "fullName" $fullName "defaultPort" $svcPort) | fromYaml }} + {{- $parsed := include "stateless.ingress.normalizePath" (dict "entry" $entry "defaultPort" $svcPort "serviceName" $svcName) | fromYaml }} {{- $path := index $parsed "path" }} {{- $serviceName := index $parsed "serviceName" }} {{- $portObj := index $parsed "port" }} diff --git a/charts/stateless/templates/service.yaml b/charts/stateless/templates/service.yaml index e276236..a66001a 100644 --- a/charts/stateless/templates/service.yaml +++ b/charts/stateless/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "stateless.fullname" . }} + name: {{ include "stateless.servicename" . }} labels: {{ include "stateless.labels" . | indent 4 }} {{- if or .Values.service.annotations .Values.TopologyAwareRouting.enabled }} @@ -27,3 +27,33 @@ spec: selector: app.kubernetes.io/name: {{ include "stateless.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "stateless.fullname" . }} + labels: +{{ include "stateless.labels" . | indent 4 }} + {{- if or .Values.service.annotations .Values.TopologyAwareRouting.enabled }} + annotations: + {{- if .Values.TopologyAwareRouting.enabled }} + service.kubernetes.io/topology-mode: auto + {{- end }} + {{- if .Values.service.annotations }} + {{- with .Values.service.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + {{- range .Values.service.ports }} + - port: {{ .port }} + targetPort: {{ .name }} + protocol: TCP + name: {{ .name }} + {{- end }} + selector: + app.kubernetes.io/name: {{ include "stateless.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} \ No newline at end of file diff --git a/charts/stateless/values.yaml b/charts/stateless/values.yaml index 87327d0..787c767 100644 --- a/charts/stateless/values.yaml +++ b/charts/stateless/values.yaml @@ -12,6 +12,7 @@ image: imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +servicenameOverride: "" serviceAccount: create: true