Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[loki-distributed] feat: add labels on ingresses/services #3610

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[loki-distributed] feat: add labels on ingresses/services, support co…
…mmonLabels

Signed-off-by: Stavros Foteinopoulos <[email protected]>
stafot committed Mar 19, 2025

Verified

This commit was signed with the committer’s verified signature.
stafot Stavros Foteinopoulos
commit 54b0b53f2e07a99a40bbed707eeac044c085c3bc
2 changes: 1 addition & 1 deletion charts/loki-distributed/Chart.yaml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ name: loki-distributed
description: Helm chart for Grafana Loki in microservices mode
type: application
appVersion: 2.9.10
version: 0.80.2
version: 0.80.3
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
5 changes: 4 additions & 1 deletion charts/loki-distributed/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki-distributed

![Version: 0.80.2](https://img.shields.io/badge/Version-0.80.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.10](https://img.shields.io/badge/AppVersion-2.9.10-informational?style=flat-square)
![Version: 0.80.3](https://img.shields.io/badge/Version-0.80.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.10](https://img.shields.io/badge/AppVersion-2.9.10-informational?style=flat-square)

Helm chart for Grafana Loki in microservices mode

@@ -205,6 +205,7 @@ kubectl delete statefulset RELEASE_NAME-loki-distributed-querier -n LOKI_NAMESPA
| gateway.ingress.enabled | bool | `false` | Specifies whether an ingress for the gateway should be created |
| gateway.ingress.hosts | list | `[{"host":"gateway.loki.example.com","paths":[{"path":"/"}]}]` | Hosts configuration for the gateway ingress |
| gateway.ingress.ingressClassName | string | `""` | Ingress Class Name. MAY be required for Kubernetes versions >= 1.18 For example: `ingressClassName: nginx` |
| gateway.ingress.labels | object | `{}` | Custom labels for the gateway ingress |
| gateway.ingress.tls | list | `[]` | TLS configuration for the gateway ingress |
| gateway.livenessProbe.httpGet.path | string | `"/"` | |
| gateway.livenessProbe.httpGet.port | string | `"http"` | |
@@ -240,6 +241,7 @@ kubectl delete statefulset RELEASE_NAME-loki-distributed-querier -n LOKI_NAMESPA
| gateway.tolerations | list | `[]` | Tolerations for gateway pods |
| gateway.verboseLogging | bool | `true` | Enable logging of 2xx and 3xx HTTP requests |
| global.clusterDomain | string | `"cluster.local"` | configures cluster domain ("cluster.local" by default) |
| global.commonLabels | object | `{}` | Common labels to be added to all resources |
| global.dnsNamespace | string | `"kube-system"` | configures DNS service namespace |
| global.dnsService | string | `"kube-dns"` | configures DNS service name |
| global.image.registry | string | `nil` | Overrides the Docker registry globally for all images |
@@ -330,6 +332,7 @@ kubectl delete statefulset RELEASE_NAME-loki-distributed-querier -n LOKI_NAMESPA
| ingress.annotations | object | `{}` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0] | string | `"loki.example.com"` | |
| ingress.labels | object | `{}` | Custom labels for the ingress |
| ingress.paths.distributor[0] | string | `"/api/prom/push"` | |
| ingress.paths.distributor[1] | string | `"/loki/api/v1/push"` | |
| ingress.paths.querier[0] | string | `"/api/prom/tail"` | |
33 changes: 21 additions & 12 deletions charts/loki-distributed/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{{/*
Common labels from global configuration
*/}}
{{- define "loki.commonLabels" -}}
{{- with .Values.global.commonLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

{{/*
Expand the name of the chart.
*/}}
@@ -30,18 +39,6 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "loki.labels" -}}
helm.sh/chart: {{ include "loki.chart" . }}
{{ include "loki.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
@@ -179,3 +176,15 @@ livenessProbe:
{{- define "loki.config.checksum" -}}
checksum/config: {{ tpl (mergeOverwrite (tpl .Values.loki.config . | fromYaml) .Values.loki.structuredConfig | toYaml) . | sha256sum }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "loki.labels" -}}
helm.sh/chart: {{ include "loki.chart" . }}
{{ include "loki.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.labels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.compactor.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.distributorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.distributor.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ metadata:
name: {{ include "loki.gatewayFullname" . }}
labels:
{{- include "loki.gatewayLabels" . | nindent 4 }}
{{- with .Values.gateway.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.gateway.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
name: {{ include "loki.gatewayFullname" . }}
labels:
{{- include "loki.gatewayLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.gateway.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
name: {{ include "loki.indexGatewayFullname" . }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.indexGateway.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.ingester.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/loki-distributed/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.labels" . | nindent 4 }}
{{- with .Values.global.commonLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.memcachedChunksSelectorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.memcachedChunks.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.memcachedFrontendSelectorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.memcachedFrontend.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.memcachedIndexQueriesSelectorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.memcachedIndexQueries.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.memcachedIndexWritesSelectorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.memcachedIndexWrites.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querierLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.querier.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.queryFrontendLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.queryFrontend.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.querySchedulerLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.queryScheduler.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
name: {{ include "loki.rulerFullname" . }}
labels:
{{- include "loki.rulerSelectorLabels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
{{- with .Values.ruler.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.labels" . | nindent 4 }}
{{- include "loki.commonLabels" . | nindent 4 }}
spec:
type: ClusterIP
clusterIP: None
7 changes: 7 additions & 0 deletions charts/loki-distributed/values.yaml
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ global:
dnsService: "kube-dns"
# -- configures DNS service namespace
dnsNamespace: "kube-system"
# -- Common labels to be added to all resources
commonLabels: {}

# -- Overrides the chart's name
nameOverride: null
@@ -995,6 +997,8 @@ ingress:
# nginx.ingress.kubernetes.io/auth-secret-type: auth-map
# nginx.ingress.kubernetes.io/configuration-snippet: |
# proxy_set_header X-Scope-OrgID $remote_user;
# -- Custom labels for the ingress
labels: {}
paths:
distributor:
- /api/prom/push
@@ -1164,13 +1168,16 @@ gateway:

# -- Annotations for the gateway ingress
annotations: {}
# -- Custom labels for the gateway ingress
labels: {}
# -- Hosts configuration for the gateway ingress
hosts:
- host: gateway.loki.example.com
paths:
- path: /
# -- pathType (e.g. ImplementationSpecific, Prefix, .. etc.) might also be required by some Ingress Controllers
# pathType: Prefix

# -- TLS configuration for the gateway ingress
tls: []
# tls: