Skip to content

Commit

Permalink
Switch Loki to StatefulSet (grafana#585)
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Sheehy <ssheehy@firescope.com>
  • Loading branch information
Steven Sheehy authored and slim-bean committed May 31, 2019
1 parent a51da92 commit efd0475
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 52 deletions.
13 changes: 5 additions & 8 deletions production/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,17 @@ tls:

## How to contribute

If you want to add any feature to helm chart, you can follow as below:
After adding your new feature to the appropriate chart, you can build and deploy it locally to test:

```bash
$ # do some changes to loki/promtail in the corresponding directory
$ make helm
$ helm upgrade --install loki ./loki-stack-*.tgz
```

After verify changes, need to bump chart version.
For example, if you update the loki chart, you need to bump the version as following:
After verifying your changes, you need to bump the chart version following [semantic versioning](https://semver.org) rules.
For example, if you update the loki chart, you need to bump the versions as follows:

```bash
$ # update version loki/Chart.yaml
$ # update version loki-stack/Chart.yaml
```
- Update version loki/Chart.yaml
- Update version loki-stack/Chart.yaml

You can use the `make helm-debug` to test and print out all chart templates. If you want to install helm (tiller) in your cluster use `make helm-install`, to install the current build in your Kubernetes cluster run `make helm-upgrade`.
2 changes: 1 addition & 1 deletion production/helm/loki-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: loki-stack
version: 0.9.5
version: 0.10.0
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: loki
version: 0.8.5
version: 0.9.0
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
22 changes: 0 additions & 22 deletions production/helm/loki/templates/pvc.yaml

This file was deleted.

19 changes: 19 additions & 0 deletions production/helm/loki/templates/service-headless.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "loki.fullname" . }}-headless
labels:
app: {{ template "loki.name" . }}
chart: {{ template "loki.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
clusterIP: None
ports:
- port: {{ .Values.service.port }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
selector:
app: {{ template "loki.name" . }}
release: {{ .Release.Name }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: {{ template "loki.fullname" . }}
labels:
Expand All @@ -10,17 +10,15 @@ metadata:
annotations:
{{- toYaml .Values.annotations | nindent 4 }}
spec:
podManagementPolicy: {{ .Values.podManagementPolicy }}
replicas: {{ .Values.replicas }}
minReadySeconds: {{ .Values.minReadySeconds }}
selector:
matchLabels:
app: {{ template "loki.name" . }}
release: {{ .Release.Name }}
strategy:
type: {{ .Values.deploymentStrategy }}
{{- if ne .Values.deploymentStrategy "RollingUpdate" }}
rollingUpdate: null
{{- end }}
serviceName: {{ template "loki.fullname" . }}-headless
updateStrategy:
{{- toYaml .Values.updateStrategy | nindent 4 }}
template:
metadata:
labels:
Expand All @@ -29,7 +27,7 @@ spec:
release: {{ .Release.Name }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
Expand All @@ -50,7 +48,7 @@ spec:
- "-config.file=/etc/loki/loki.yaml"
{{- range $key, $value := .Values.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/loki
Expand Down Expand Up @@ -85,11 +83,25 @@ spec:
- name: config
secret:
secretName: {{ template "loki.fullname" . }}
{{- if not .Values.persistence.enabled }}
- name: storage
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "loki.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- else if .Values.persistence.existingClaim }}
- name: storage
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- else }}
volumeClaimTemplates:
- metadata:
name: storage
annotations:
{{- toYaml .Values.persistence.annotations | nindent 8 }}
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 8 }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}

12 changes: 6 additions & 6 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ affinity: {}
# - loki
# topologyKey: "kubernetes.io/hostname"

## Deployment annotations
## StatefulSet annotations
annotations: {}

# enable tracing for debug, need install jaeger and specify right jaeger_agent_host
Expand All @@ -20,7 +20,6 @@ tracing:

config:
auth_enabled: false

ingester:
chunk_idle_period: 15m
chunk_block_size: 262144
Expand Down Expand Up @@ -63,8 +62,6 @@ config:
retention_deletes_enabled: false
retention_period: 0

deploymentStrategy: RollingUpdate

image:
repository: grafana/loki
tag: latest
Expand All @@ -80,8 +77,6 @@ livenessProbe:
port: http-metrics
initialDelaySeconds: 45

minReadySeconds: 0

## Enable persistence using Persistent Volume Claims
networkPolicy:
enabled: false
Expand Down Expand Up @@ -111,6 +106,8 @@ podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "http-metrics"

podManagementPolicy: OrderedReady

## Assign a PriorityClassName to pods if set
# priorityClassName:

Expand Down Expand Up @@ -162,3 +159,6 @@ tolerations: []
podDisruptionBudget: {}
# minAvailable: 1
# maxUnavailable: 1

updateStrategy:
type: RollingUpdate

0 comments on commit efd0475

Please sign in to comment.