Skip to content

Commit

Permalink
Upgrade to Loki 2.0.0 and add compactor support (grafana#27)
Browse files Browse the repository at this point in the history
Signed-off-by: Reinhard Nägele <[email protected]>
  • Loading branch information
unguiculus authored Oct 27, 2020
1 parent f4ac5eb commit d7ea57b
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/loki-distributed/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: loki-distributed
description: Helm chart for Grafana Loki in microservices mode
type: application
appVersion: 1.6.1
version: 0.11.1
appVersion: 2.0.0
version: 0.12.0
home: https://github.com/unguiculus/loki-helm-chart
sources:
- https://github.com/grafana/loki
Expand Down
16 changes: 14 additions & 2 deletions charts/loki-distributed/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki-distributed

![Version: 0.11.0](https://img.shields.io/badge/Version-0.11.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.6.1](https://img.shields.io/badge/AppVersion-1.6.1-informational?style=flat-square)
![Version: 0.12.0](https://img.shields.io/badge/Version-0.12.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0](https://img.shields.io/badge/AppVersion-2.0.0-informational?style=flat-square)

Helm chart for Grafana Loki in microservices mode

Expand All @@ -24,6 +24,18 @@ helm repo add loki https://unguiculus.github.io/loki-helm-chart

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| compactor.enabled | bool | `false` | Specifies whether compactor should be enabled |
| compactor.extraArgs | list | `[]` | Additional CLI args for the compactor |
| compactor.extraEnv | list | `[]` | Environment variables to add to the compactor pods |
| compactor.extraEnvFrom | list | `[]` | Environment variables from secrets or configmaps to add to the compactor pods |
| compactor.nodeSelector | object | `{}` | Node selector for compactor pods |
| compactor.persistence.enabled | bool | `false` | Enable creating PVCs for the compactor |
| compactor.persistence.size | string | `"10Gi"` | Size of persistent disk |
| compactor.persistence.storageClass | string | `""` | Storage class to be used. If defined, storageClassName: <storageClass>. If set to "-", storageClassName: "", which disables dynamic provisioning. If empty (the default) or set to null, no storageClassName spec is set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack). |
| compactor.podAnnotations | object | `{}` | Annotations for compactor pods |
| compactor.resources | object | `{}` | Resource requests and limits for the compactor |
| compactor.terminationGracePeriodSeconds | int | `30` | Grace period to allow the compactor to shutdown before it is killed |
| compactor.tolerations | list | `[]` | Tolerations for compactor pods |
| distributor.affinity | string | Hard node and soft zone anti-affinity | Affinity for distributor pods. Passed through `tpl` and, thus, to be configured as string |
| distributor.extraArgs | list | `[]` | Additional CLI args for the distributor |
| distributor.extraEnv | list | `[]` | Environment variables to add to the distributor pods |
Expand Down Expand Up @@ -231,6 +243,7 @@ loki:
ingestion_rate_mb: 10
ingestion_burst_size_mb: 20
max_concurrent_tail_requests: 20
max_cache_freshness_per_query: 10m
schema_config:
configs:
Expand Down Expand Up @@ -260,7 +273,6 @@ loki:
cache_results: true
results_cache:
max_freshness: 10m
cache:
enable_fifocache: true
fifocache:
Expand Down
7 changes: 5 additions & 2 deletions charts/loki-distributed/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ loki:
store: memberlist

ingester:
# disable chunk transfer which is not possible with statefulsets
# Disable chunk transfer which is not possible with statefulsets
# and unnecessary for boltdb-shipper
max_transfer_retries: 0
chunk_idle_period: 1h
chunk_target_size: 1536000
max_chunk_age: 1h
lifecycler:
join_after: 0s
ring:
Expand All @@ -70,6 +73,7 @@ loki:
ingestion_rate_mb: 10
ingestion_burst_size_mb: 20
max_concurrent_tail_requests: 20
max_cache_freshness_per_query: 10m

schema_config:
configs:
Expand Down Expand Up @@ -99,7 +103,6 @@ loki:
cache_results: true

results_cache:
max_freshness: 10m
cache:
enable_fifocache: true
fifocache:
Expand Down
1 change: 0 additions & 1 deletion charts/loki-distributed/ci/cache-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ loki:
split_queries_by_interval: 30m
cache_results: true
results_cache:
max_freshness: 10m
cache:
memcached_client:
consistent_hash: true
Expand Down
22 changes: 22 additions & 0 deletions charts/loki-distributed/templates/compactor/_helpers-compactor.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{/*
compactor fullname
*/}}
{{- define "loki.compactorFullname" -}}
{{ include "loki.fullname" . }}-compactor
{{- end }}

{{/*
compactor common labels
*/}}
{{- define "loki.compactorLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: compactor
{{- end }}

{{/*
compactor selector labels
*/}}
{{- define "loki.compactorSelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: compactor
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{{- if .Values.compactor.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "loki.compactorFullname" . }}
labels:
{{- include "loki.compactorLabels" . | nindent 4 }}
spec:
replicas: 1
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "loki.compactorSelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print .Template.BasePath "/configmap.yaml") $ | sha256sum }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.compactorSelectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
fsGroup: 10001
runAsGroup: 10001
runAsNonRoot: true
runAsUser: 10001
terminationGracePeriodSeconds: {{ .Values.compactor.terminationGracePeriodSeconds }}
containers:
- name: loki
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/loki.yaml
- -target=compactor
- -boltdb.shipper.compactor.working-directory=/var/loki/compactor
{{- with .Values.compactor.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 3100
protocol: TCP
{{- with .Values.compactor.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.compactor.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
readOnlyRootFilesystem: true
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 15
timeoutSeconds: 1
volumeMounts:
- name: config
mountPath: /etc/loki
- name: data
mountPath: /var/loki
resources:
{{- toYaml .Values.compactor.resources | nindent 12 }}
{{- with .Values.compactor.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.compactor.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: data-{{ include "loki.fullname" . }}
- name: data
{{- if .Values.compactor.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "loki.compactorFullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.compactor.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-{{ include "loki.compactorFullname" . }}
labels:
{{- include "loki.compactorLabels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
{{- with .Values.compactor.persistence.storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: "{{ .Values.compactor.persistence.size }}"
{{- end }}
19 changes: 19 additions & 0 deletions charts/loki-distributed/templates/compactor/service-compactor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.compactor.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.fullname" . }}-compactor
labels:
{{- include "loki.labels" . | nindent 4 }}
app.kubernetes.io/component: compactor
spec:
type: ClusterIP
ports:
- name: http
port: 3100
targetPort: http
protocol: TCP
selector:
{{- include "loki.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: compactor
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.compactor.enabled }}
{{- with .Values.serviceMonitor }}
{{- if .enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "loki.compactorFullname" $ }}
{{- with .namespace }}
namespace: {{ . }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "loki.compactorLabels" $ | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .namespaceSelector }}
namespaceSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "loki.compactorSelectorLabels" $ | nindent 6 }}
endpoints:
- port: http
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
34 changes: 33 additions & 1 deletion charts/loki-distributed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ loki:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
max_cache_freshness_per_query: 10m
schema_config:
configs:
Expand Down Expand Up @@ -83,7 +84,6 @@ loki:
split_queries_by_interval: 15m
cache_results: true
results_cache:
max_freshness: 10m
cache:
enable_fifocache: true
fifocache:
Expand Down Expand Up @@ -488,6 +488,38 @@ gateway:
}
}
# Configuration for the compactor
compactor:
# compactor.enabled -- Specifies whether compactor should be enabled
enabled: false
# compactor.podAnnotations -- Annotations for compactor pods
podAnnotations: {}
# compactor.extraArgs -- Additional CLI args for the compactor
extraArgs: []
# compactor.extraEnv -- Environment variables to add to the compactor pods
extraEnv: []
# compactor.extraEnvFrom -- Environment variables from secrets or configmaps to add to the compactor pods
extraEnvFrom: []
# compactor.resources -- Resource requests and limits for the compactor
resources: {}
# compactor.terminationGracePeriodSeconds -- Grace period to allow the compactor to shutdown before it is killed
terminationGracePeriodSeconds: 30
# compactor.nodeSelector -- Node selector for compactor pods
nodeSelector: {}
# compactor.tolerations -- Tolerations for compactor pods
tolerations: []
persistence:
# compactor.persistence.enabled -- Enable creating PVCs for the compactor
enabled: false
# compactor.persistence.size -- Size of persistent disk
size: 10Gi
# compactor.persistence.storageClass -- Storage class to be used.
# If defined, storageClassName: <storageClass>.
# If set to "-", storageClassName: "", which disables dynamic provisioning.
# If empty (the default) or set to null, no storageClassName spec is
# set, choosing the default provisioner (gp2 on AWS, standard on GKE, AWS, and OpenStack).
storageClass: ""

memcached:
image:
# memcached.image.repository -- Memcached Docker image repository
Expand Down

0 comments on commit d7ea57b

Please sign in to comment.