Skip to content

Commit

Permalink
Supporting externally managed Cortex Config (#31)
Browse files Browse the repository at this point in the history
* enabling option to specify a cortex config created externally to this chart

Signed-off-by: Ken Haines <ken@kenhaines.net>

* updating deployment hash of secret template, to only occur if cortex is using the template managed config.yaml

Signed-off-by: Ken Haines <ken@kenhaines.net>

* updating ignore file

Signed-off-by: Ken Haines <ken@kenhaines.net>

* adding externalConfigVersion property and using it in deployment annotations for change updates

Signed-off-by: Ken Haines <ken@kenhaines.net>
  • Loading branch information
khaines committed Aug 2, 2020
1 parent 965804d commit 93baa61
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
charts
.tgz
cortex
7 changes: 2 additions & 5 deletions Chart.lock
Expand Up @@ -8,8 +8,5 @@ dependencies:
- name: memcached
repository: https://kubernetes-charts.storage.googleapis.com/
version: 3.2.3
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.6.13
digest: sha256:1a40fe2aae73dfcc54eeb47bad91111c91bcb0eeec9b9dd24e5e0bd2e54a3d9c
generated: "2020-04-04T20:29:40.131333Z"
digest: sha256:15343a3a535fa858a532546a47dbb63e1379be1d4081f55b01de56db3d2b7617
generated: "2020-07-02T10:49:04.929498-07:00"
8 changes: 8 additions & 0 deletions templates/alertmanager-dep.yaml
Expand Up @@ -28,7 +28,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.alertmanager.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -96,7 +100,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.alertmanager.extraVolumes }}
{{ toYaml .Values.alertmanager.extraVolumes | indent 8}}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions templates/configs-dep.yaml
Expand Up @@ -28,7 +28,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.configs.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -104,7 +108,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.configsdb_postgresql.enabled }}
- name: postgres-password
secret:
Expand Down
8 changes: 8 additions & 0 deletions templates/distributor-dep.yaml
Expand Up @@ -29,7 +29,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.distributor.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -96,7 +100,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.distributor.extraVolumes }}
{{ toYaml .Values.distributor.extraVolumes | indent 8}}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions templates/ingester-dep.yaml
Expand Up @@ -29,7 +29,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.ingester.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -102,7 +106,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.ingester.extraVolumes }}
{{ toYaml .Values.ingester.extraVolumes | indent 8}}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion templates/nginx-dep.yaml
Expand Up @@ -29,7 +29,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/nginx-config.yaml") . | sha256sum }}
{{- with .Values.nginx.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions templates/querier-dep.yaml
Expand Up @@ -29,7 +29,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.querier.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -103,7 +107,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.querier.extraVolumes }}
{{ toYaml .Values.querier.extraVolumes | indent 8}}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions templates/query-frontend-dep.yaml
Expand Up @@ -29,7 +29,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.query_frontend.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -96,7 +100,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.query_frontend.extraVolumes }}
{{ toYaml .Values.query_frontend.extraVolumes | indent 8}}
{{- end }}
8 changes: 8 additions & 0 deletions templates/ruler-dep.yaml
Expand Up @@ -28,7 +28,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.ruler.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -101,7 +105,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.ruler.extraVolumes }}
{{ toYaml .Values.ruler.extraVolumes | indent 8}}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions templates/secret.yaml
@@ -1,3 +1,4 @@
{{- if not .Values.useExternalConfig }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -10,3 +11,4 @@ metadata:
heritage: {{ .Release.Service }}
data:
cortex.yaml: {{ tpl (toYaml .Values.config) . | b64enc}}
{{- end }}
8 changes: 8 additions & 0 deletions templates/table-manager-dep.yaml
Expand Up @@ -28,7 +28,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.useExternalConfig }}
checksum/config: {{ .Values.externalConfigVersion }}
{{- else }}
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end}}
{{- with .Values.table_manager.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -95,7 +99,11 @@ spec:
volumes:
- name: config
secret:
{{- if eq .Values.useExternalConfig }}
secretName: {{ .Values.externalConfigSecretName }}
{{- else }}
secretName: {{ template "cortex.fullname" . }}
{{- end }}
{{- if .Values.table_manager.extraVolumes }}
{{ toYaml .Values.table_manager.extraVolumes | indent 8}}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions values.yaml
Expand Up @@ -33,6 +33,9 @@ serviceAccount:
annotations: {}


useExternalConfig: false
externalConfigSecretName: "secret-with-config.yaml"
externalConfigVersion: "0"
config:
auth_enabled: false
ingester:
Expand Down

0 comments on commit 93baa61

Please sign in to comment.