From 409bff5796f2e84c2731f970240959e5fec4a418 Mon Sep 17 00:00:00 2001 From: granular-ryanbonham <41303664+granular-ryanbonham@users.noreply.github.com> Date: Tue, 19 Mar 2019 10:23:48 -0500 Subject: [PATCH] Support AWS Storage w/ HELM template (#337) * Migrate config from configmap to secret. Add support for AWS Storage Config. * Add checksome for secret as pod annoation to ensure pod rotates if we update secret. * Move aws_storage_configs to storage_configs. Move local storage options under a local_storage key. * Allow specification of storage_config directly as yaml in values.yaml * Fix syntax for _helpers.tpl --- production/helm/templates/loki/_helpers.tpl | 37 ++++++++++++++ production/helm/templates/loki/configmap.yaml | 49 ------------------- .../helm/templates/loki/deployment.yaml | 7 +-- production/helm/templates/loki/secret.yaml | 11 +++++ production/helm/values.yaml | 6 +-- 5 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 production/helm/templates/loki/configmap.yaml create mode 100644 production/helm/templates/loki/secret.yaml diff --git a/production/helm/templates/loki/_helpers.tpl b/production/helm/templates/loki/_helpers.tpl index 71fca849..d57dffe4 100644 --- a/production/helm/templates/loki/_helpers.tpl +++ b/production/helm/templates/loki/_helpers.tpl @@ -41,3 +41,40 @@ Create the name of the service account {{ default "default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} + +{{- define "configSecret" }} +auth_enabled: {{ .Values.loki.config.auth_enabled }} + +server: + http_listen_port: {{ .Values.loki.service.port }} + +limits_config: + enforce_metric_name: false + +ingester: + lifecycler: + ring: + store: {{ .Values.loki.config.ingester.lifecycler.ring.store }} + replication_factor: {{ .Values.loki.config.ingester.lifecycler.ring.replication_factor }} + chunk_idle_period: 15m + +{{- if .Values.loki.config.schema_configs }} +schema_config: + configs: +{{- range .Values.loki.config.schema_configs }} + - from: {{ .from }} + store: {{ .store }} + object_store: {{ .object_store }} + schema: {{ .schema }} + index: + prefix: {{ .index.prefix }} + period: {{ .index.period }} +{{- end -}} +{{- end -}} + +{{- with .Values.loki.config.storage_config }} +storage_config: +{{ toYaml . | indent 2 }} +{{- end }} + +{{- end}} \ No newline at end of file diff --git a/production/helm/templates/loki/configmap.yaml b/production/helm/templates/loki/configmap.yaml deleted file mode 100644 index 5b93c3f6..00000000 --- a/production/helm/templates/loki/configmap.yaml +++ /dev/null @@ -1,49 +0,0 @@ -{{- if .Values.loki.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ template "loki.fullname" . }} - labels: - app: {{ template "loki.name" . }} - chart: {{ template "loki.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -data: - loki.yaml: | - auth_enabled: {{ .Values.loki.config.auth_enabled }} - - server: - http_listen_port: {{ .Values.loki.service.port }} - - limits_config: - enforce_metric_name: false - - ingester: - lifecycler: - ring: - store: {{ .Values.loki.config.ingester.lifecycler.ring.store }} - replication_factor: {{ .Values.loki.config.ingester.lifecycler.ring.replication_factor }} - chunk_idle_period: 15m - -{{- if .Values.loki.config.schema_configs }} - schema_config: - configs: - {{- range .Values.loki.config.schema_configs }} - - from: {{ .from }} - store: {{ .store }} - object_store: {{ .object_store }} - schema: {{ .schema }} - index: - prefix: {{ .index.prefix }} - period: {{ .index.period }} - {{- end }} -{{- end }} - -{{- if .Values.loki.config.storage_configs }} - storage_config: - {{- range .Values.loki.config.storage_configs }} - {{ .name }}: - directory: {{ .directory }} - {{- end }} -{{- end }} -{{- end }} diff --git a/production/helm/templates/loki/deployment.yaml b/production/helm/templates/loki/deployment.yaml index 05edf136..404301c2 100644 --- a/production/helm/templates/loki/deployment.yaml +++ b/production/helm/templates/loki/deployment.yaml @@ -30,8 +30,9 @@ spec: app: {{ template "loki.name" . }} name: {{ template "loki.name" . }} release: {{ .Release.Name }} -{{- with .Values.loki.podAnnotations }} annotations: + checksum/config: {{ include (print $.Template.BasePath "/loki/secret.yaml") . | sha256sum }} +{{- with .Values.loki.podAnnotations }} {{ toYaml . | indent 8 }} {{- end }} spec: @@ -82,8 +83,8 @@ spec: terminationGracePeriodSeconds: {{ .Values.loki.terminationGracePeriodSeconds }} volumes: - name: config - configMap: - name: {{ template "loki.fullname" . }} + secret: + secretName: {{ template "loki.fullname" . }} - name: storage {{- if .Values.loki.persistence.enabled }} persistentVolumeClaim: diff --git a/production/helm/templates/loki/secret.yaml b/production/helm/templates/loki/secret.yaml new file mode 100644 index 00000000..66819067 --- /dev/null +++ b/production/helm/templates/loki/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "loki.fullname" . }} + labels: + app: {{ template "loki.name" . }} + chart: {{ template "loki.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + loki.yaml: {{ include "configSecret" . | b64enc}} \ No newline at end of file diff --git a/production/helm/values.yaml b/production/helm/values.yaml index e669d762..c47889d8 100644 --- a/production/helm/values.yaml +++ b/production/helm/values.yaml @@ -106,10 +106,10 @@ loki: index: prefix: index_ period: 168h - storage_configs: - - name: boltdb + storage_config: + boltdb: directory: /data/loki/index - - name: filesystem + filesystem: directory: /data/loki/chunks promtail: -- GitLab