@@ -1163,173 +1163,3 @@ env:
11631163{{- end -}}
11641164{{- end -}}
11651165
1166- {{/*
1167- Gateway API version detection
1168- */ }}
1169- {{- define " loki.gatewayApi.apiVersion" -}}
1170- {{- if .Capabilities.APIVersions.Has " gateway.networking.k8s.io/v1" }}
1171- {{- print " gateway.networking.k8s.io/v1" }}
1172- {{- else if .Capabilities.APIVersions.Has " gateway.networking.k8s.io/v1beta1" }}
1173- {{- print " gateway.networking.k8s.io/v1beta1" }}
1174- {{- else }}
1175- {{- print " gateway.networking.k8s.io/v1" }}
1176- {{- end }}
1177- {{- end -}}
1178-
1179- {{/*
1180- Gateway API route manifest shared between the nginx gateway route and direct Loki service routes.
1181- Params:
1182- ctx - chart root context ($)
1183- route - route values object
1184- name - resource name for the HTTPRoute object
1185- rules - pre-rendered rules string to embed under spec.rules
1186- labelsTemplate - optional: name of the labels helper to use (default "loki.labels")
1187- */ }}
1188- {{- define " loki.route" -}}
1189- {{- $route := .route -}}
1190- {{- $ctx := .ctx }}
1191- ---
1192- apiVersion: {{ $route .apiVersion | default (include " loki.gatewayApi.apiVersion" $ctx ) }}
1193- kind: {{ $route .kind | default " HTTPRoute" }}
1194- metadata:
1195- name: {{ .name }}
1196- namespace: {{ include " loki.namespace" $ctx }}
1197- labels:
1198- {{- include (.labelsTemplate | default " loki.labels" ) $ctx | nindent 4 }}
1199- {{- with $route .labels }}
1200- {{- toYaml . | nindent 4 }}
1201- {{- end }}
1202- {{- with $route .annotations }}
1203- annotations:
1204- {{- toYaml . | nindent 4 }}
1205- {{- end }}
1206- spec:
1207- {{- with $route .parentRefs }}
1208- parentRefs:
1209- {{- toYaml . | nindent 4 }}
1210- {{- end }}
1211- {{- with $route .hostnames }}
1212- hostnames:
1213- {{- tpl (toYaml . ) $ctx | nindent 4 }}
1214- {{- end }}
1215- rules:
1216- {{- with $route .additionalRules }}
1217- {{- tpl (toYaml . ) $ctx | nindent 4 }}
1218- {{- end }}
1219- {{- .rules | nindent 4 }}
1220- {{- end -}}
1221-
1222- {{/*
1223- HTTPRoute rule that points to the nginx gateway backend.
1224- Params:
1225- ctx - chart root context ($)
1226- route - route values object
1227- name - backend service name
1228- port - backend service port
1229- */ }}
1230- {{- define " loki.route.gatewayRule" -}}
1231- - backendRefs:
1232- - group: " "
1233- kind: Service
1234- name: {{ .name }}
1235- port: {{ .port }}
1236- weight: 1
1237- {{- with .route.filters }}
1238- filters:
1239- {{- toYaml . | nindent 2 }}
1240- {{- end }}
1241- {{- with .route.matches }}
1242- matches:
1243- {{- toYaml . | nindent 2 }}
1244- {{- end }}
1245- {{- with .route.timeouts }}
1246- timeouts:
1247- {{- toYaml . | nindent 2 }}
1248- {{- end }}
1249- {{- end -}}
1250-
1251- {{/*
1252- Generate HTTPRoute rules based on deployment type for direct routing to Loki services.
1253- Params:
1254- ctx - chart root context ($)
1255- paths - paths object from the route entry (e.g. .Values.route.main.paths)
1256- */ }}
1257- {{- define " loki.route.rules" -}}
1258- {{- $ctx := .ctx -}}
1259- {{- $paths := .paths -}}
1260- {{- if (eq (include " loki.deployment.isSingleBinary" $ctx ) " true" ) -}}
1261- {{- include " loki.route.singleBinaryRules" (dict " ctx" $ctx " paths" $paths ) }}
1262- {{- else if (eq (include " loki.deployment.isDistributed" $ctx ) " true" ) -}}
1263- {{- include " loki.route.distributedRules" (dict " ctx" $ctx " paths" $paths ) }}
1264- {{- else if and (eq (include " loki.deployment.isScalable" $ctx ) " true" ) -}}
1265- {{- include " loki.route.scalableRules" (dict " ctx" $ctx " paths" $paths ) }}
1266- {{- end -}}
1267- {{- end -}}
1268-
1269- {{/*
1270- HTTPRoute rules for distributed deployment
1271- */ }}
1272- {{- define " loki.route.distributedRules" -}}
1273- {{- $ctx := .ctx -}}
1274- {{- $paths := .paths -}}
1275- {{- $distributorServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " distributor" ) }}
1276- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $distributorServiceName " paths" $paths .distributor ) }}
1277- {{- $queryFrontendServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " query-frontend" ) }}
1278- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $queryFrontendServiceName " paths" $paths .queryFrontend ) }}
1279- {{- $rulerServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " ruler" ) }}
1280- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $rulerServiceName " paths" $paths .ruler ) }}
1281- {{- $compactorServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " compactor" ) }}
1282- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $compactorServiceName " paths" $paths .compactor ) }}
1283- {{- end -}}
1284-
1285- {{/*
1286- HTTPRoute rules for simple scalable deployment
1287- */ }}
1288- {{- define " loki.route.scalableRules" -}}
1289- {{- $ctx := .ctx -}}
1290- {{- $paths := .paths -}}
1291- {{- $readServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " read" ) }}
1292- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $readServiceName " paths" $paths .queryFrontend ) }}
1293- {{- $writeServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " write" ) }}
1294- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $writeServiceName " paths" $paths .distributor ) }}
1295- {{- $backendServiceName := include " loki.resourceName" (dict " ctx" $ctx " component" " backend" ) }}
1296- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $backendServiceName " paths" $paths .ruler ) }}
1297- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $backendServiceName " paths" $paths .compactor ) }}
1298- {{- end -}}
1299-
1300- {{/*
1301- HTTPRoute rules for single binary deployment
1302- */ }}
1303- {{- define " loki.route.singleBinaryRules" -}}
1304- {{- $ctx := .ctx -}}
1305- {{- $paths := .paths -}}
1306- {{- $serviceName := include " loki.singleBinaryFullname" $ctx }}
1307- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $serviceName " paths" $paths .distributor ) }}
1308- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $serviceName " paths" $paths .queryFrontend ) }}
1309- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $serviceName " paths" $paths .ruler ) }}
1310- {{- include " loki.route.serviceRule" (dict " ctx" $ctx " serviceName" $serviceName " paths" $paths .compactor ) }}
1311- {{- end -}}
1312-
1313- {{/*
1314- HTTPRoute service rule helper.
1315- Params:
1316- ctx - chart root context ($)
1317- serviceName - fully qualified k8s service name
1318- paths - list of URL path prefixes to match
1319- */ }}
1320- {{- define " loki.route.serviceRule" -}}
1321- {{- if .paths }}
1322- - backendRefs:
1323- - group: " "
1324- kind: Service
1325- name: {{ .serviceName }}
1326- port: {{ .ctx.Values.loki.server.http_listen_port }}
1327- weight: 1
1328- matches:
1329- {{- range .paths }}
1330- - path:
1331- type: PathPrefix
1332- value: {{ . }}
1333- {{- end }}
1334- {{- end -}}
1335- {{- end -}}
0 commit comments