Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Overrides-Exporter #360

Merged
merged 8 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master / unreleased

* [FEATURE] Add Overrides-Exporter #360

## 1.5.1 / 2022-05-25

* [BUGFIX] Fix mounting cortex config when using configmap #355
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,48 @@ Kubernetes: `^1.19.0-0`
| nginx.​terminationGracePeriodSeconds | int | `10` | |
| nginx.​tolerations | list | `[]` | |
| nginx.​topologySpreadConstraints | list | `[]` | |
| overrides_exporter.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​key | string | `"app.kubernetes.io/component"` | |
| overrides_exporter.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​operator | string | `"In"` | |
| overrides_exporter.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​values[0] | string | `"query-scheduler"` | |
| overrides_exporter.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​topologyKey | string | `"kubernetes.io/hostname"` | |
| overrides_exporter.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​weight | int | `100` | |
| overrides_exporter.​annotations | object | `{}` | |
| overrides_exporter.​containerSecurityContext.​enabled | bool | `true` | |
| overrides_exporter.​containerSecurityContext.​readOnlyRootFilesystem | bool | `true` | |
| overrides_exporter.​enabled | bool | `false` | https://cortexmetrics.io/docs/guides/overrides-exporter/ |
| overrides_exporter.​env | list | `[]` | |
| overrides_exporter.​extraArgs | object | `{}` | Additional Cortex container arguments, e.g. log.level (debug, info, warn, error) |
| overrides_exporter.​extraContainers | list | `[]` | |
| overrides_exporter.​extraPorts | list | `[]` | |
| overrides_exporter.​extraVolumeMounts | list | `[]` | |
| overrides_exporter.​extraVolumes | list | `[]` | |
| overrides_exporter.​initContainers | list | `[]` | |
| overrides_exporter.​lifecycle | object | `{}` | |
| overrides_exporter.​livenessProbe.​httpGet.​path | string | `"/ready"` | |
| overrides_exporter.​livenessProbe.​httpGet.​port | string | `"http-metrics"` | |
| overrides_exporter.​nodeSelector | object | `{}` | |
| overrides_exporter.​podAnnotations | object | `{"prometheus.io/port":"http-metrics","prometheus.io/scrape":"true"}` | Pod Annotations |
| overrides_exporter.​podLabels | object | `{}` | Pod Labels |
| overrides_exporter.​readinessProbe.​httpGet.​path | string | `"/ready"` | |
| overrides_exporter.​readinessProbe.​httpGet.​port | string | `"http-metrics"` | |
| overrides_exporter.​resources | object | `{}` | |
| overrides_exporter.​securityContext | object | `{}` | |
| overrides_exporter.​service.​annotations | object | `{}` | |
| overrides_exporter.​service.​labels | object | `{}` | |
| overrides_exporter.​serviceMonitor.​additionalLabels | object | `{}` | |
| overrides_exporter.​serviceMonitor.​enabled | bool | `false` | |
| overrides_exporter.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint |
| overrides_exporter.​serviceMonitor.​metricRelabelings | list | `[]` | |
| overrides_exporter.​serviceMonitor.​relabelings | list | `[]` | |
| overrides_exporter.​startupProbe.​failureThreshold | int | `10` | |
| overrides_exporter.​startupProbe.​httpGet.​path | string | `"/ready"` | |
| overrides_exporter.​startupProbe.​httpGet.​port | string | `"http-metrics"` | |
| overrides_exporter.​strategy.​rollingUpdate.​maxSurge | int | `0` | |
| overrides_exporter.​strategy.​rollingUpdate.​maxUnavailable | int | `1` | |
| overrides_exporter.​strategy.​type | string | `"RollingUpdate"` | |
| overrides_exporter.​terminationGracePeriodSeconds | int | `180` | |
| overrides_exporter.​tolerations | list | `[]` | |
| overrides_exporter.​topologySpreadConstraints | list | `[]` | |
| querier.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​key | string | `"app.kubernetes.io/component"` | |
| querier.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​operator | string | `"In"` | |
| querier.​affinity.​podAntiAffinity.​preferredDuringSchedulingIgnoredDuringExecution[0].​podAffinityTerm.​labelSelector.​matchExpressions[0].​values[0] | string | `"querier"` | |
Expand Down
23 changes: 23 additions & 0 deletions templates/overrides-exporter/_helpers-overrides-exporter.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

{{/*
overrides-exporter fullname
*/}}
{{- define "cortex.overridesExporterFullname" -}}
{{ include "cortex.fullname" . }}-overrides-exporter
{{- end }}

{{/*
overrides-exporter common labels
*/}}
{{- define "cortex.overridesExporterLabels" -}}
{{ include "cortex.labels" . }}
app.kubernetes.io/component: overrides-exporter
{{- end }}

{{/*
overrides-exporter selector labels
*/}}
{{- define "cortex.overridesExporterSelectorLabels" -}}
{{ include "cortex.selectorLabels" . }}
app.kubernetes.io/component: overrides-exporter
{{- end }}
113 changes: 113 additions & 0 deletions templates/overrides-exporter/overrides-exporter-dep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{{- if .Values.overrides_exporter.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cortex.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cortex.overridesExporterLabels" . | nindent 4 }}
annotations:
{{- toYaml .Values.overrides_exporter.annotations | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "cortex.overridesExporterSelectorLabels" . | nindent 6 }}
strategy:
{{- toYaml .Values.overrides_exporter.strategy | nindent 4 }}
template:
metadata:
labels:
{{- include "cortex.overridesExporterLabels" . | nindent 8 }}
{{- with .Values.overrides_exporter.podLabels }}
{{- 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.overrides_exporter.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "cortex.serviceAccountName" . }}
{{- if .Values.overrides_exporter.priorityClassName }}
priorityClassName: {{ .Values.overrides_exporter.priorityClassName }}
{{- end }}
{{- if .Values.overrides_exporter.securityContext.enabled }}
securityContext: {{- omit .Values.overrides_exporter.securityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- toYaml .Values.overrides_exporter.initContainers | nindent 8 }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: overrides-exporter
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "-target=overrides-exporter"
- "-config.file=/etc/cortex/cortex.yaml"
{{- range $key, $value := .Values.overrides_exporter.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
volumeMounts:
{{- if .Values.overrides_exporter.extraVolumeMounts }}
{{- toYaml .Values.overrides_exporter.extraVolumeMounts | nindent 12 }}
{{- end }}
- name: config
mountPath: /etc/cortex
- name: runtime-config
mountPath: /etc/cortex-runtime-config
ports:
- name: http-metrics
containerPort: {{ .Values.config.server.http_listen_port }}
protocol: TCP
startupProbe:
{{- toYaml .Values.overrides_exporter.startupProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.overrides_exporter.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.overrides_exporter.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.overrides_exporter.resources | nindent 12 }}
{{- if .Values.overrides_exporter.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.overrides_exporter.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.overrides_exporter.env }}
env:
{{- toYaml .Values.overrides_exporter.env | nindent 12 }}
{{- end }}
{{- with .Values.overrides_exporter.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.overrides_exporter.extraContainers }}
{{- toYaml .Values.overrides_exporter.extraContainers | nindent 8 }}
{{- end }}
nodeSelector:
{{- toYaml .Values.overrides_exporter.nodeSelector | nindent 8 }}
{{- if .Values.overrides_exporter.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml .Values.overrides_exporter.topologySpreadConstraints | nindent 8}}
{{- end }}
affinity:
{{- toYaml .Values.overrides_exporter.affinity | nindent 8 }}
tolerations:
{{- toYaml .Values.overrides_exporter.tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.overrides_exporter.terminationGracePeriodSeconds }}
volumes:
{{- include "cortex.configVolume" . | nindent 8 }}
- name: runtime-config
configMap:
name: {{ template "cortex.fullname" . }}-runtime-config
{{- if .Values.overrides_exporter.extraVolumes }}
{{- toYaml .Values.overrides_exporter.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if and .Values.overrides_exporter.enabled .Values.overrides_exporter.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "cortex.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cortex.overridesExporterLabels" . | nindent 4 }}
{{- if .Values.overrides_exporter.serviceMonitor.additionalLabels }}
{{ toYaml .Values.overrides_exporter.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.overrides_exporter.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.overrides_exporter.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "cortex.overridesExporterSelectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.overrides_exporter.serviceMonitor.interval }}
interval: {{ .Values.overrides_exporter.serviceMonitor.interval }}
{{- end }}
{{- if .Values.overrides_exporter.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.overrides_exporter.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.overrides_exporter.serviceMonitor.relabelings }}
relabelings:
{{- toYaml .Values.overrides_exporter.serviceMonitor.relabelings | nindent 4 }}
{{- end }}
{{- if .Values.overrides_exporter.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml .Values.overrides_exporter.serviceMonitor.metricRelabelings | nindent 4 }}
{{- end }}
{{- with .Values.overrides_exporter.serviceMonitor.extraEndpointSpec }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions templates/overrides-exporter/overrides-exporter-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.overrides_exporter.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "cortex.overridesExporterFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cortex.overridesExporterLabels" . | nindent 4 }}
{{- with .Values.overrides_exporter.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.overrides_exporter.service.annotations | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.config.server.http_listen_port }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
selector:
{{- include "cortex.overridesExporterSelectorLabels" . | nindent 4 }}
{{- end }}
83 changes: 83 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,89 @@ query_scheduler:
env: []
lifecycle: {}

overrides_exporter:
# -- https://cortexmetrics.io/docs/guides/overrides-exporter/
enabled: false

service:
annotations: {}
labels: {}

serviceMonitor:
enabled: false
additionalLabels: {}
relabelings: []
metricRelabelings: []
# -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint
extraEndpointSpec: {}

resources: {}

# -- Additional Cortex container arguments, e.g. log.level (debug, info, warn, error)
extraArgs: {}

# -- Pod Labels
podLabels: {}

# -- Pod Annotations
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: 'http-metrics'

nodeSelector: {}
topologySpreadConstraints: []
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/component
operator: In
values:
- query-scheduler
topologyKey: 'kubernetes.io/hostname'

annotations: {}

startupProbe:
httpGet:
path: /ready
port: http-metrics
failureThreshold: 10
livenessProbe:
httpGet:
path: /ready
port: http-metrics
readinessProbe:
httpGet:
path: /ready
port: http-metrics

securityContext: {}
containerSecurityContext:
enabled: true
readOnlyRootFilesystem: true

strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1

terminationGracePeriodSeconds: 180

tolerations: []

initContainers: []
extraContainers: []
extraVolumes: []
extraVolumeMounts: []
extraPorts: []
env: []
lifecycle: {}

table_manager:
replicas: 1

Expand Down