Switch Loki to StatefulSet (#585)

Signed-off-by: Steven Sheehy <ssheehy@firescope.com>
pull/631/head
Steven Sheehy 6 years ago committed by Cyril Tovena
parent e58b1db6ce
commit 18392ea19c
  1. 13
      production/helm/README.md
  2. 2
      production/helm/loki-stack/Chart.yaml
  3. 2
      production/helm/loki/Chart.yaml
  4. 22
      production/helm/loki/templates/pvc.yaml
  5. 19
      production/helm/loki/templates/service-headless.yaml
  6. 40
      production/helm/loki/templates/statefulset.yaml
  7. 12
      production/helm/loki/values.yaml

@ -105,20 +105,17 @@ tls:
## How to contribute ## 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 ```bash
$ # do some changes to loki/promtail in the corresponding directory
$ make helm $ make helm
$ helm upgrade --install loki ./loki-stack-*.tgz $ helm upgrade --install loki ./loki-stack-*.tgz
``` ```
After verify changes, need to bump chart version. 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 version as following: 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/Chart.yaml - Update version loki-stack/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`. 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`.

@ -1,5 +1,5 @@
name: loki-stack name: loki-stack
version: 0.9.5 version: 0.10.0
appVersion: 0.0.1 appVersion: 0.0.1
kubeVersion: "^1.10.0-0" kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs." description: "Loki: like Prometheus, but for logs."

@ -1,5 +1,5 @@
name: loki name: loki
version: 0.8.5 version: 0.9.0
appVersion: 0.0.1 appVersion: 0.0.1
kubeVersion: "^1.10.0-0" kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs." description: "Loki: like Prometheus, but for logs."

@ -1,22 +0,0 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ template "loki.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
annotations:
{{- toYaml .Values.persistence.annotations | nindent 4 }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}

@ -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 }}

@ -1,5 +1,5 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: StatefulSet
metadata: metadata:
name: {{ template "loki.fullname" . }} name: {{ template "loki.fullname" . }}
labels: labels:
@ -10,17 +10,15 @@ metadata:
annotations: annotations:
{{- toYaml .Values.annotations | nindent 4 }} {{- toYaml .Values.annotations | nindent 4 }}
spec: spec:
podManagementPolicy: {{ .Values.podManagementPolicy }}
replicas: {{ .Values.replicas }} replicas: {{ .Values.replicas }}
minReadySeconds: {{ .Values.minReadySeconds }}
selector: selector:
matchLabels: matchLabels:
app: {{ template "loki.name" . }} app: {{ template "loki.name" . }}
release: {{ .Release.Name }} release: {{ .Release.Name }}
strategy: serviceName: {{ template "loki.fullname" . }}-headless
type: {{ .Values.deploymentStrategy }} updateStrategy:
{{- if ne .Values.deploymentStrategy "RollingUpdate" }} {{- toYaml .Values.updateStrategy | nindent 4 }}
rollingUpdate: null
{{- end }}
template: template:
metadata: metadata:
labels: labels:
@ -29,7 +27,7 @@ spec:
release: {{ .Release.Name }} release: {{ .Release.Name }}
{{- with .Values.podLabels }} {{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
annotations: annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }} {{- with .Values.podAnnotations }}
@ -50,7 +48,7 @@ spec:
- "-config.file=/etc/loki/loki.yaml" - "-config.file=/etc/loki/loki.yaml"
{{- range $key, $value := .Values.extraArgs }} {{- range $key, $value := .Values.extraArgs }}
- "-{{ $key }}={{ $value }}" - "-{{ $key }}={{ $value }}"
{{- end }} {{- end }}
volumeMounts: volumeMounts:
- name: config - name: config
mountPath: /etc/loki mountPath: /etc/loki
@ -85,11 +83,25 @@ spec:
- name: config - name: config
secret: secret:
secretName: {{ template "loki.fullname" . }} secretName: {{ template "loki.fullname" . }}
{{- if not .Values.persistence.enabled }}
- name: storage - name: storage
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "loki.fullname" .) }}
{{- else }}
emptyDir: {} 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 }}

@ -11,7 +11,7 @@ affinity: {}
# - loki # - loki
# topologyKey: "kubernetes.io/hostname" # topologyKey: "kubernetes.io/hostname"
## Deployment annotations ## StatefulSet annotations
annotations: {} annotations: {}
# enable tracing for debug, need install jaeger and specify right jaeger_agent_host # enable tracing for debug, need install jaeger and specify right jaeger_agent_host
@ -20,7 +20,6 @@ tracing:
config: config:
auth_enabled: false auth_enabled: false
ingester: ingester:
chunk_idle_period: 15m chunk_idle_period: 15m
chunk_block_size: 262144 chunk_block_size: 262144
@ -63,8 +62,6 @@ config:
retention_deletes_enabled: false retention_deletes_enabled: false
retention_period: 0 retention_period: 0
deploymentStrategy: RollingUpdate
image: image:
repository: grafana/loki repository: grafana/loki
tag: latest tag: latest
@ -80,8 +77,6 @@ livenessProbe:
port: http-metrics port: http-metrics
initialDelaySeconds: 45 initialDelaySeconds: 45
minReadySeconds: 0
## Enable persistence using Persistent Volume Claims ## Enable persistence using Persistent Volume Claims
networkPolicy: networkPolicy:
enabled: false enabled: false
@ -111,6 +106,8 @@ podAnnotations:
prometheus.io/scrape: "true" prometheus.io/scrape: "true"
prometheus.io/port: "http-metrics" prometheus.io/port: "http-metrics"
podManagementPolicy: OrderedReady
## Assign a PriorityClassName to pods if set ## Assign a PriorityClassName to pods if set
# priorityClassName: # priorityClassName:
@ -162,3 +159,6 @@ tolerations: []
podDisruptionBudget: {} podDisruptionBudget: {}
# minAvailable: 1 # minAvailable: 1
# maxUnavailable: 1 # maxUnavailable: 1
updateStrategy:
type: RollingUpdate

Loading…
Cancel
Save