Skip to content

Commit afba1e0

Browse files
authored
support runtime configuration (#209)
* support runtime configuration Signed-off-by: Tom Hayward <[email protected]> * support managing the runtime config cm outside helm, support annotations Signed-off-by: Tom Hayward <[email protected]>
1 parent 2564694 commit afba1e0

16 files changed

+93
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master / unreleased
44

5+
* [FEATURE] Support runtime configuration #209
56
* [FEATURE] Add autoscaler for queriers #190
67
* [FEATURE] Add autoscaler for distributors #189
78
* [FEATURE] Add autoscaler for ingesters #182

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ Kubernetes: `^1.19.0-0`
340340
| config.&ZeroWidthSpace;ruler.&ZeroWidthSpace;enable_alertmanager_discovery | bool | `false` | |
341341
| config.&ZeroWidthSpace;ruler.&ZeroWidthSpace;enable_api | bool | `false` | Enable the experimental ruler config api. |
342342
| config.&ZeroWidthSpace;ruler.&ZeroWidthSpace;storage | object | `{}` | Method to use for backend rule storage (configdb, azure, gcs, s3, swift, local) refer to https://cortexmetrics.io/docs/configuration/configuration-file/#ruler_config |
343+
| config.&ZeroWidthSpace;runtime_config.&ZeroWidthSpace;file | string | `"/etc/cortex-runtime-config/runtime_config.yaml"` | |
343344
| config.&ZeroWidthSpace;schema.&ZeroWidthSpace;configs[0].&ZeroWidthSpace;chunks.&ZeroWidthSpace;period | string | `"168h"` | |
344345
| config.&ZeroWidthSpace;schema.&ZeroWidthSpace;configs[0].&ZeroWidthSpace;chunks.&ZeroWidthSpace;prefix | string | `"chunks_"` | |
345346
| config.&ZeroWidthSpace;schema.&ZeroWidthSpace;configs[0].&ZeroWidthSpace;from | string | `"2020-11-01"` | |
@@ -777,6 +778,9 @@ Kubernetes: `^1.19.0-0`
777778
| ruler.&ZeroWidthSpace;strategy.&ZeroWidthSpace;type | string | `"RollingUpdate"` | |
778779
| ruler.&ZeroWidthSpace;terminationGracePeriodSeconds | int | `180` | |
779780
| ruler.&ZeroWidthSpace;tolerations | list | `[]` | |
781+
| runtimeconfigmap.&ZeroWidthSpace;annotations | object | `{}` | |
782+
| runtimeconfigmap.&ZeroWidthSpace;create | bool | `true` | If true, a configmap for the `runtime_config` will be created. If false, the configmap _must_ exist already on the cluster or pods will fail to create. |
783+
| runtimeconfigmap.&ZeroWidthSpace;runtime_config | object | `{}` | https://cortexmetrics.io/docs/configuration/arguments/#runtime-configuration-file |
780784
| serviceAccount.&ZeroWidthSpace;annotations | object | `{}` | |
781785
| serviceAccount.&ZeroWidthSpace;automountServiceAccountToken | bool | `true` | |
782786
| serviceAccount.&ZeroWidthSpace;create | bool | `true` | |

templates/alertmanager/alertmanager-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ spec:
116116
{{- end }}
117117
- name: config
118118
mountPath: /etc/cortex
119+
- name: runtime-config
120+
mountPath: /etc/cortex-runtime-config
119121
- name: storage
120122
mountPath: "/data"
121123
subPath: {{ .Values.alertmanager.persistence.subPath }}
@@ -162,6 +164,9 @@ spec:
162164
{{- if .Values.alertmanager.extraVolumes }}
163165
{{ toYaml .Values.alertmanager.extraVolumes | indent 8}}
164166
{{- end }}
167+
- name: runtime-config
168+
configMap:
169+
name: {{ template "cortex.fullname" . }}-runtime-config
165170
- name: storage
166171
emptyDir: {}
167172
{{- end -}}

templates/alertmanager/alertmanager-statefulset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ spec:
8989
{{- else }}
9090
secretName: {{ template "cortex.fullname" . }}
9191
{{- end }}
92+
- name: runtime-config
93+
configMap:
94+
name: {{ template "cortex.fullname" . }}-runtime-config
9295
{{- if not .Values.alertmanager.persistentVolume.enabled }}
9396
- name: storage
9497
emptyDir: {}
@@ -170,6 +173,8 @@ spec:
170173
{{- end }}
171174
- name: config
172175
mountPath: /etc/cortex
176+
- name: runtime-config
177+
mountPath: /etc/cortex-runtime-config
173178
- name: storage
174179
mountPath: "/data"
175180
{{- if .Values.alertmanager.persistentVolume.subPath }}

templates/compactor/compactor-statefulset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ spec:
8888
{{- else }}
8989
secretName: {{ template "cortex.fullname" . }}
9090
{{- end }}
91+
- name: runtime-config
92+
configMap:
93+
name: {{ template "cortex.fullname" . }}-runtime-config
9194
{{- if not .Values.compactor.persistentVolume.enabled }}
9295
- name: storage
9396
emptyDir: {}
@@ -115,6 +118,8 @@ spec:
115118
{{- end }}
116119
- name: config
117120
mountPath: /etc/cortex
121+
- name: runtime-config
122+
mountPath: /etc/cortex-runtime-config
118123
- name: storage
119124
mountPath: "/data"
120125
{{- if .Values.compactor.persistentVolume.subPath }}

templates/configs/configs-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ spec:
6868
- name: config
6969
mountPath: /etc/cortex
7070
subPath: {{ .Values.configs.persistence.subPath }}
71+
- name: runtime-config
72+
mountPath: /etc/cortex-runtime-config
7173
{{- if .Values.configsdb_postgresql.enabled }}
7274
- name: postgres-password
7375
mountPath: /etc/postgresql
@@ -123,6 +125,9 @@ spec:
123125
- key: {{ if .Values.configsdb_postgresql.auth.existing_secret.name }}{{ .Values.configsdb_postgresql.auth.existing_secret.key }}{{ else }}postgresql-password{{ end }}
124126
path: password
125127
{{- end }}
128+
- name: runtime-config
129+
configMap:
130+
name: {{ template "cortex.fullname" . }}-runtime-config
126131
{{- if .Values.configs.extraVolumes }}
127132
{{ toYaml .Values.configs.extraVolumes | indent 8}}
128133
{{- end }}

templates/distributor/distributor-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
{{- end }}
6767
- name: config
6868
mountPath: /etc/cortex
69+
- name: runtime-config
70+
mountPath: /etc/cortex-runtime-config
6971
- name: storage
7072
mountPath: "/data"
7173
subPath: {{ .Values.distributor.persistence.subPath }}
@@ -112,6 +114,9 @@ spec:
112114
{{- else }}
113115
secretName: {{ template "cortex.fullname" . }}
114116
{{- end }}
117+
- name: runtime-config
118+
configMap:
119+
name: {{ template "cortex.fullname" . }}-runtime-config
115120
{{- if .Values.distributor.extraVolumes }}
116121
{{ toYaml .Values.distributor.extraVolumes | indent 8}}
117122
{{- end }}

templates/ingester/ingester-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ spec:
6868
{{- end }}
6969
- name: config
7070
mountPath: /etc/cortex
71+
- name: runtime-config
72+
mountPath: /etc/cortex-runtime-config
7173
- name: storage
7274
mountPath: "/data"
7375
{{- if .Values.ingester.persistentVolume.subPath }}
@@ -125,6 +127,9 @@ spec:
125127
{{- else }}
126128
secretName: {{ template "cortex.fullname" . }}
127129
{{- end }}
130+
- name: runtime-config
131+
configMap:
132+
name: {{ template "cortex.fullname" . }}-runtime-config
128133
{{- if .Values.ingester.extraVolumes }}
129134
{{ toYaml .Values.ingester.extraVolumes | nindent 8}}
130135
{{- end }}

templates/ingester/ingester-statefulset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ spec:
9090
{{- else }}
9191
secretName: {{ template "cortex.fullname" . }}
9292
{{- end }}
93+
- name: runtime-config
94+
configMap:
95+
name: {{ template "cortex.fullname" . }}-runtime-config
9396
{{- if not .Values.ingester.persistentVolume.enabled }}
9497
- name: storage
9598
emptyDir: {}
@@ -117,6 +120,8 @@ spec:
117120
{{- end }}
118121
- name: config
119122
mountPath: /etc/cortex
123+
- name: runtime-config
124+
mountPath: /etc/cortex-runtime-config
120125
- name: storage
121126
mountPath: "/data"
122127
{{- if .Values.ingester.persistentVolume.subPath }}

templates/querier/querier-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
{{- end }}
6767
- name: config
6868
mountPath: /etc/cortex
69+
- name: runtime-config
70+
mountPath: /etc/cortex-runtime-config
6971
- name: storage
7072
mountPath: "/data"
7173
subPath: {{ .Values.querier.persistence.subPath }}
@@ -106,6 +108,9 @@ spec:
106108
{{- else }}
107109
secretName: {{ template "cortex.fullname" . }}
108110
{{- end }}
111+
- name: runtime-config
112+
configMap:
113+
name: {{ template "cortex.fullname" . }}-runtime-config
109114
{{- if .Values.querier.extraVolumes }}
110115
{{ toYaml .Values.querier.extraVolumes | indent 8}}
111116
{{- end }}

templates/query-frontend/query-frontend-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ spec:
6363
{{- end }}
6464
- name: config
6565
mountPath: /etc/cortex
66+
- name: runtime-config
67+
mountPath: /etc/cortex-runtime-config
6668
ports:
6769
- name: http-metrics
6870
containerPort: {{ .Values.config.server.http_listen_port }}
@@ -103,6 +105,9 @@ spec:
103105
{{- else }}
104106
secretName: {{ template "cortex.fullname" . }}
105107
{{- end }}
108+
- name: runtime-config
109+
configMap:
110+
name: {{ template "cortex.fullname" . }}-runtime-config
106111
{{- if .Values.query_frontend.extraVolumes }}
107112
{{ toYaml .Values.query_frontend.extraVolumes | indent 8}}
108113
{{- end }}

templates/ruler/ruler-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ spec:
127127
{{ end }}
128128
- name: config
129129
mountPath: /etc/cortex
130+
- name: runtime-config
131+
mountPath: /etc/cortex-runtime-config
130132
- name: storage
131133
mountPath: /data
132134
subPath: {{ .Values.ruler.persistence.subPath }}
@@ -176,6 +178,9 @@ spec:
176178
{{- else }}
177179
secretName: {{ template "cortex.fullname" . }}
178180
{{- end }}
181+
- name: runtime-config
182+
configMap:
183+
name: {{ template "cortex.fullname" . }}-runtime-config
179184
- name: tmp
180185
emptyDir: {}
181186
{{- range $dir, $_ := .Values.ruler.directories }}

templates/runtime-configmap.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- with .Values.runtimeconfigmap }}
2+
{{- if .create }}
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ template "cortex.fullname" $ }}-runtime-config
7+
namespace: {{ $.Release.Namespace }}
8+
labels:
9+
{{- include "cortex.labels" $ | nindent 4 }}
10+
{{- with .annotations -}}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
data:
15+
runtime_config.yaml: |
16+
{{- tpl (toYaml .runtime_config) $ | nindent 4 }}
17+
{{- end }}
18+
{{- end }}

templates/store-gateway/store-gateway-statefulset.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ spec:
8787
{{- else }}
8888
secretName: {{ template "cortex.fullname" . }}
8989
{{- end }}
90+
- name: runtime-config
91+
configMap:
92+
name: {{ template "cortex.fullname" . }}-runtime-config
9093
{{- if not .Values.store_gateway.persistentVolume.enabled }}
9194
- name: storage
9295
emptyDir: {}
@@ -114,6 +117,8 @@ spec:
114117
{{- end }}
115118
- name: config
116119
mountPath: /etc/cortex
120+
- name: runtime-config
121+
mountPath: /etc/cortex-runtime-config
117122
- name: storage
118123
mountPath: "/data"
119124
{{- if .Values.store_gateway.persistentVolume.subPath }}

templates/table-manager/table-manager-dep.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ spec:
6363
{{- end }}
6464
- name: config
6565
mountPath: /etc/cortex
66+
- name: runtime-config
67+
mountPath: /etc/cortex-runtime-config
6668
- name: storage
6769
mountPath: "/data"
6870
subPath: {{ .Values.table_manager.persistence.subPath }}
@@ -103,6 +105,9 @@ spec:
103105
{{- else }}
104106
secretName: {{ template "cortex.fullname" . }}
105107
{{- end }}
108+
- name: runtime-config
109+
configMap:
110+
name: {{ template "cortex.fullname" . }}-runtime-config
106111
{{- if .Values.table_manager.extraVolumes }}
107112
{{ toYaml .Values.table_manager.extraVolumes | indent 8}}
108113
{{- end }}

values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ config:
177177
enable_api: false
178178
# -- Method to use for backend rule storage (configdb, azure, gcs, s3, swift, local) refer to https://cortexmetrics.io/docs/configuration/configuration-file/#ruler_config
179179
storage: {}
180+
runtime_config:
181+
file: /etc/cortex-runtime-config/runtime_config.yaml
180182
alertmanager:
181183
# -- Enable the experimental alertmanager config api.
182184
enable_api: false
@@ -187,6 +189,14 @@ config:
187189
# max_outstanding_per_tenant: 1000
188190
log_queries_longer_than: 10s
189191

192+
runtimeconfigmap:
193+
# -- If true, a configmap for the `runtime_config` will be created.
194+
# If false, the configmap _must_ exist already on the cluster or pods will fail to create.
195+
create: true
196+
annotations: {}
197+
# -- https://cortexmetrics.io/docs/configuration/arguments/#runtime-configuration-file
198+
runtime_config: {}
199+
190200
alertmanager:
191201
enabled: true
192202
replicas: 1

0 commit comments

Comments
 (0)