Skip to content

Commit

Permalink
[loki-distributed] Add overrides exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Monkevicius <[email protected]>
  • Loading branch information
lukas-unity committed Jan 23, 2024
1 parent 04eb45b commit 3d9c2aa
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/loki-distributed/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: loki-distributed
description: Helm chart for Grafana Loki in microservices mode
type: application
appVersion: 2.9.2
version: 0.78.1
version: 0.79.0
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
Expand Down
24 changes: 23 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.78.1](https://img.shields.io/badge/Version-0.78.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.2](https://img.shields.io/badge/AppVersion-2.9.2-informational?style=flat-square)
![Version: 0.79.0](https://img.shields.io/badge/Version-0.79.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.2](https://img.shields.io/badge/AppVersion-2.9.2-informational?style=flat-square)

Helm chart for Grafana Loki in microservices mode

Expand Down Expand Up @@ -476,6 +476,28 @@ kubectl delete statefulset RELEASE_NAME-loki-distributed-querier -n LOKI_NAMESPA
| networkPolicy.metrics.cidrs | list | `[]` | Specifies specific network CIDRs which are allowed to access the metrics port. In case you use namespaceSelector, you also have to specify your kubelet networks here. The metrics ports are also used for probes. |
| networkPolicy.metrics.namespaceSelector | object | `{}` | Specifies the namespaces which are allowed to access the metrics port |
| networkPolicy.metrics.podSelector | object | `{}` | Specifies the Pods which are allowed to access the metrics port. As this is cross-namespace communication, you also need the namespaceSelector. |
| overridesExporter.affinity | string | Hard node and soft zone anti-affinity | Affinity for overrides-exporter pods. Passed through `tpl` and, thus, to be configured as string |
| overridesExporter.enabled | bool | `false` | Specifies whether the overrides-exporter should be enabled |
| overridesExporter.extraArgs | list | `[]` | Additional CLI args for the overrides-exporter |
| overridesExporter.extraContainers | list | `[]` | Containers to add to the overrides-exporter pods |
| overridesExporter.extraEnv | list | `[]` | Environment variables to add to the overrides-exporter pods |
| overridesExporter.extraEnvFrom | list | `[]` | Environment variables from secrets or configmaps to add to the overrides-exporter pods |
| overridesExporter.extraVolumeMounts | list | `[]` | Volume mounts to add to the overrides-exporter pods |
| overridesExporter.extraVolumes | list | `[]` | Volumes to add to the overrides-exporter pods |
| overridesExporter.hostAliases | list | `[]` | hostAliases to add |
| overridesExporter.image.registry | string | `nil` | The Docker registry for the overrides-exporter image. Overrides `loki.image.registry` |
| overridesExporter.image.repository | string | `nil` | Docker image repository for the overrides-exporter image. Overrides `loki.image.repository` |
| overridesExporter.image.tag | string | `nil` | Docker image tag for the overrides-exporter image. Overrides `loki.image.tag` |
| overridesExporter.maxUnavailable | string | `nil` | Pod Disruption Budget maxUnavailable |
| overridesExporter.nodeSelector | object | `{}` | Node selector for overrides-exporter pods |
| overridesExporter.podAnnotations | object | `{}` | Annotations for overrides-exporter pods |
| overridesExporter.podLabels | object | `{}` | Labels for overrides-exporter pods |
| overridesExporter.priorityClassName | string | `nil` | The name of the PriorityClass for overrides-exporter pods |
| overridesExporter.replicas | int | `1` | Number of replicas for the overrides-exporter. |
| overridesExporter.resources | object | `{}` | Resource requests and limits for the overrides-exporter |
| overridesExporter.serviceLabels | object | `{}` | Labels for overrides-exporter service |
| overridesExporter.terminationGracePeriodSeconds | int | `30` | Grace period to allow the overrides-exporter to shutdown before it is killed |
| overridesExporter.tolerations | list | `[]` | Tolerations for overrides-exporter pods |
| prometheusRule.annotations | object | `{}` | PrometheusRule annotations |
| prometheusRule.enabled | bool | `false` | If enabled, a PrometheusRule resource for Prometheus Operator is created |
| prometheusRule.groups | list | `[]` | Contents of Prometheus rules file |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/*
overrides-exporter fullname
*/}}
{{- define "loki.overridesExporterFullname" -}}
{{ include "loki.fullname" . }}-overrides-exporter
{{- end }}

{{/*
overrides-exporter common labels
*/}}
{{- define "loki.overridesExporterLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: overrides-exporter
{{- end }}

{{/*
overrides-exporter selector labels
*/}}
{{- define "loki.overridesExporterSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: overrides-exporter
{{- end }}

{{/*
overrides-exporter image
*/}}
{{- define "loki.overridesExporterImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.overridesExporter.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}

{{/*
overrides-exporter priority class name
*/}}
{{- define "loki.overridesExporterPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.overridesExporter.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{{- if .Values.overridesExporter.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.overridesExporterLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.overridesExporter.replicas }}
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: {{ .Values.overridesExporter.maxUnavailable }}
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "loki.overridesExporterSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.overridesExporter.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.overridesExporterSelectorLabels" . | nindent 8 }}
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.overridesExporter.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.overridesExporter.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.overridesExporterPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.overridesExporter.terminationGracePeriodSeconds }}
containers:
- name: overrides-exporter
image: {{ include "loki.overridesExporterImage" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=overrides-exporter
{{- with .Values.overridesExporter.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
{{- with .Values.overridesExporter.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.overridesExporter.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /var/{{ include "loki.name" . }}-runtime
{{- with .Values.overridesExporter.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.overridesExporter.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.overridesExporter.extraContainers }}
{{- toYaml .Values.overridesExporter.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.overridesExporter.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- end }}
{{- with .Values.overridesExporter.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.overridesExporter.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- if .Values.loki.existingSecretForConfig }}
secret:
secretName: {{ .Values.loki.existingSecretForConfig }}
{{- else if .Values.loki.configAsSecret }}
secret:
secretName: {{ include "loki.fullname" . }}-config
{{- else }}
configMap:
name: {{ include "loki.fullname" . }}
{{- end }}
- name: runtime-config
configMap:
name: {{ template "loki.fullname" . }}-runtime
{{- with .Values.overridesExporter.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if and .Values.overridesExporter.enabled (gt (int .Values.overridesExporter.replicas) 1) }}
{{- if not .Values.overridesExporter.maxUnavailable }}
{{- fail "`.Values.overridesExporter.maxUnavailable` must be set when `.Values.overridesExporter.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.overridesExporterLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.overridesExporterSelectorLabels" . | nindent 6 }}
{{- with .Values.overridesExporter.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.overridesExporter.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.overridesExporterLabels" . | nindent 4 }}
{{- with .Values.overridesExporter.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.loki.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- name: http
port: 3100
targetPort: http
protocol: TCP
- name: grpclb
port: 9095
targetPort: grpc
protocol: TCP
selector:
{{- include "loki.overridesExporterSelectorLabels" . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.overridesExporter.enabled }}
{{- with .Values.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "loki.overridesExporterFullname" $ }}
{{- with .namespace }}
namespace: {{ . }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "loki.overridesExporterLabels" $ | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .namespaceSelector }}
namespaceSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "loki.overridesExporterSelectorLabels" $ | nindent 6 }}
{{- with .matchExpressions }}
matchExpressions:
{{- toYaml . | nindent 6 }}
{{- end }}
endpoints:
- port: http
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- with .relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .scheme }}
scheme: {{ . }}
{{- end }}
{{- with .tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 3d9c2aa

Please sign in to comment.