@@ -63,29 +63,65 @@ ServiceAccount name
6363{{- end }}
6464{{- end }}
6565
66+ {{/*
67+ Resolve the OpenLIT Kubernetes service name.
68+
69+ Priority (highest to lowest):
70+ 1. config.openlitServiceName — explicit override for standalone deployments.
71+ 2. Auto-derive — mirrors the parent "openlit" chart's fullname logic so the
72+ name is correct when deployed as a subchart regardless of release name.
73+ */ }}
74+ {{- define " openlit-controller.parentServiceName" -}}
75+ {{- if .Values.config.openlitServiceName }}
76+ {{- .Values.config.openlitServiceName | trunc 63 | trimSuffix " -" }}
77+ {{- else }}
78+ {{- $parentName := " openlit" }}
79+ {{- if contains $parentName .Release.Name }}
80+ {{- .Release.Name | trunc 63 | trimSuffix " -" }}
81+ {{- else }}
82+ {{- printf " %s -%s " .Release.Name $parentName | trunc 63 | trimSuffix " -" }}
83+ {{- end }}
84+ {{- end }}
85+ {{- end }}
86+
87+ {{/*
88+ Build a host string for the parent OpenLIT service.
89+
90+ When config.openlitNamespace is set (standalone / cross-namespace), produce a
91+ fully-qualified DNS name. Otherwise use the short service name (same namespace).
92+ */ }}
93+ {{- define " openlit-controller.parentServiceHost" -}}
94+ {{- $svc := include " openlit-controller.parentServiceName" . }}
95+ {{- if .Values.config.openlitNamespace }}
96+ {{- printf " %s .%s .svc.cluster.local" $svc .Values.config.openlitNamespace }}
97+ {{- else }}
98+ {{- $svc }}
99+ {{- end }}
100+ {{- end }}
101+
66102{{/*
67103Resolve the OpenLIT dashboard URL.
68- When config.openlitUrl is set, use it directly.
69- Otherwise, derive from the parent chart's release name (subchart mode) .
104+
105+ Priority: explicit config.openlitUrl > auto-derived from service name + namespace .
70106*/ }}
71107{{- define " openlit-controller.openlitUrl" -}}
72108{{- if .Values.config.openlitUrl }}
73109{{- .Values.config.openlitUrl }}
74110{{- else }}
75- {{- printf " http://%s -openlit :%s " .Release.Name " 3000" }}
111+ {{- printf " http://%s :%s " (include " openlit-controller.parentServiceHost " . ) " 3000" }}
76112{{- end }}
77113{{- end }}
78114
79115{{/*
80116Resolve the OTLP endpoint.
81- When config.otlpEndpoint is set, use it directly.
82- Otherwise, derive from the parent chart's release name (subchart mode) .
117+
118+ Priority: explicit config.otlpEndpoint > auto-derived from service name + namespace .
83119*/ }}
84120{{- define " openlit-controller.otlpEndpoint" -}}
85121{{- if .Values.config.otlpEndpoint }}
86122{{- .Values.config.otlpEndpoint }}
87123{{- else }}
88- {{- printf " http://%s -openlit :%s " .Release.Name " 4318" }}
124+ {{- printf " http://%s :%s " (include " openlit-controller.parentServiceHost " . ) " 4318" }}
89125{{- end }}
90126{{- end }}
91127
0 commit comments