Files
devops-infra-argo-config-gcp/external-name-service-template/templates/service.yaml
T
2026-08-26 04:03:34 +05:30

53 lines
1.8 KiB
YAML

{{- $labels := .Values.labels -}}
{{- $bu := $labels.bu -}}
{{- $mcs := index .Values.mcs $bu | default "on" -}}
{{- range $namespace, $protocols := .Values.svcSpec }}
{{- if not (regexMatch (printf ".*%s.*" $bu) $namespace) }}
{{- $parts := splitList "-" $namespace -}}
{{- $keyPart := "" -}}
{{- if eq (print (index $parts 1)) "external" }}
{{- $keyPart = print (index $parts 2) }}
{{- else }}
{{- $keyPart = print (index $parts 3) }}
{{- end }}
{{- $ilb_key := printf "%s-ilb" $keyPart -}}
{{- $ilb_info := index $.Values $ilb_key | default dict -}}
{{- $ilb_zone := index $ilb_info "zone" | default $labels.zone -}}
{{- range $protocol_type := $protocols }}
{{- $envoyServiceName := $namespace -}}
{{- if $.Values.overrideEnvoyServiceNameWith }}
{{- $envoyServiceName = regexReplaceAll "-prd$" $namespace (printf "-%s-prd" $.Values.overrideEnvoyServiceNameWith) -}}
{{- end }}
{{- $envoySvcName := printf "%s-envoy%s" $envoyServiceName (ternary "-headless" "" (eq $protocol_type "grpc")) -}}
{{- $name := printf "%s-envoy%s" $namespace (ternary "-headless" "" (eq $protocol_type "grpc")) -}}
apiVersion: v1
kind: Service
metadata:
name: externalname-{{ $name }}
namespace: {{ $namespace }}
labels:
{{ toYaml $labels | indent 4 }}
spec:
type: ExternalName
ports:
- port: {{ include "service.port" $protocol_type }}
targetPort: {{ include "service.targetport" $protocol_type }}
protocol: TCP
name: {{ $protocol_type }}
externalName: {{ if and (eq $mcs "on") (hasKey $ilb_info "enabled") (eq $ilb_info.enabled false) }}{{ printf "%s.%s.svc.clusterset.local" $envoySvcName $namespace }}{{ else }}{{ printf "%s%s-%s%s.%s.meesho.int" (ternary "tcp-" "" (eq $protocol_type "grpc")) $namespace $labels.region $ilb_zone $labels.env }}{{ end }}
---
{{- end }}
{{- end }}
{{- end }}