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

Service Monitors and Compactor Service #68

Merged
merged 5 commits into from Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -301,7 +301,7 @@ Source code can be found [here](https://cortexmetrics.io/)
| externalConfigVersion | string | `"0"` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"quay.io/cortexproject/cortex"` | |
| image.tag | string | `"v1.1.0"` | |
| image.tag | string | `"v1.4.0"` | |
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"target"` | |
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | |
| ingester.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"ingester"` | |
Expand Down
34 changes: 34 additions & 0 deletions templates/alertmanager-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.alertmanager.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-alertmanager
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.alertmanager.serviceMonitor.additionalLabels }}
{{ toYaml .Values.alertmanager.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.alertmanager.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.alertmanager.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-alertmanager
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.alertmanager.serviceMonitor.interval }}
interval: {{ .Values.alertmanager.serviceMonitor.interval }}
{{- end }}
{{- if .Values.alertmanager.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.alertmanager.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
8 changes: 6 additions & 2 deletions templates/alertmanager-statefulset.yaml
Expand Up @@ -19,7 +19,7 @@ spec:
app: {{ template "cortex.name" . }}-alertmanager
release: {{ .Release.Name }}
updateStrategy:
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
serviceName: {{ template "cortex.fullname" . }}-alertmanager
{{- if .Values.alertmanager.persistentVolume.enabled }}
volumeClaimTemplates:
Expand Down Expand Up @@ -85,6 +85,8 @@ spec:
{{- toYaml .Values.alertmanager.tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }}
volumes:
- emptyDir: {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend avoiding specifying non-cortex path mounts here. I get the intention, but it prevents others from customizing /tmp in this setup. There are overridable settings for volumes and mounts, which allow for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ts-mini - Sorry, should have flagged this earlier, but I think this last item needs correction prior to merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good I'll get to this asap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I remember correctly, it's cause the code inside of cortex writes to tmp no matter what, and it's not customizable, so if you use the default psp the file system is ro, making it fail when it validates configs. I think I should be able to make it customizable, and adjust to tmp in our setup

Copy link
Contributor

@khaines khaines Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that might be fair that cortex uses /tmp in some cases (I'll have to go look where again), but in the PR you've fixed that solution to be an emptyDir. If others are already mapping /tmp to other volume types, this will potentially break their setup.

Also correcting any path mounts should be in its own PR, given the title of this one is adding service monitors. Both valid issues, but it makes it much easier to review, provide feedback and merge when PRs are focused on a single scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I look back at this change and idk what I was thinking. 1) sorry for conflating prs, 2) I totally glossed over the 'extraVolume' and 'extraVolumeMount' options. I am just going to use those going forward - and while I think we could solve this ro-filesystem issue within the chart - the real "problem" imho is this section. I might just attempt to make this change on the cortex side so one could specify the 'tmpDIr' path as a config param.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for being open to the feedback and adjusting the changes :) LGTM now for merging

name: tmp
- name: config
secret:
{{- if .Values.useExternalConfig }}
Expand Down Expand Up @@ -112,7 +114,7 @@ spec:
- "-alertmanager.configs.url=http://{{ template "cortex.fullname" . }}-configs.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.config.server.http_listen_port }}"
{{- if gt (.Values.alertmanager.replicas | int) 1 }}
{{- range $n := until (.Values.alertmanager.replicas |int ) }}
- -cluster.peer={{ template "cortex.fullname" $ }}-alertmanager-{{ $n }}.{{ template "cortex.fullname" $ }}-alertmanager-headless.{{ $.Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ $clusterPort }}
- -cluster.peer={{ template "cortex.fullname" $ }}-alertmanager-{{ $n }}.{{ template "cortex.fullname" $ }}-alertmanager.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }}:{{ $clusterPort }}
{{- end }}
{{- end }}
{{- range $key, $value := .Values.alertmanager.extraArgs }}
Expand All @@ -124,6 +126,8 @@ spec:
{{- end }}
- name: config
mountPath: /etc/cortex
- mountPath: /tmp
name: tmp
- name: storage
mountPath: "/data"
{{- if .Values.alertmanager.persistentVolume.subPath }}
Expand Down
34 changes: 34 additions & 0 deletions templates/compactor-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.compactor.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-compactor
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.compactor.serviceMonitor.additionalLabels }}
{{ toYaml .Values.compactor.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.compactor.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.compactor.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-compactor
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.compactor.serviceMonitor.interval }}
interval: {{ .Values.compactor.serviceMonitor.interval }}
{{- end }}
{{- if .Values.compactor.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.compactor.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions templates/compactor-svc.yaml
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "cortex.fullname" . }}-compactor
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "cortex.name" . }}-compactor
chart: {{ template "cortex.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.compactor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.compactor.service.annotations | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.config.server.http_listen_port }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
selector:
app: {{ template "cortex.name" . }}-compactor
release: {{ .Release.Name }}
34 changes: 34 additions & 0 deletions templates/configs-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.configs.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-configs
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.configs.serviceMonitor.additionalLabels }}
{{ toYaml .Values.configs.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.configs.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.configs.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-configs
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.configs.serviceMonitor.interval }}
interval: {{ .Values.configs.serviceMonitor.interval }}
{{- end }}
{{- if .Values.configs.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.configs.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/distributor-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.distributor.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-distributor
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.distributor.serviceMonitor.additionalLabels }}
{{ toYaml .Values.distributor.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.distributor.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.distributor.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-distributor
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.distributor.serviceMonitor.interval }}
interval: {{ .Values.distributor.serviceMonitor.interval }}
{{- end }}
{{- if .Values.distributor.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.distributor.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/ingester-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.ingester.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-ingester
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.ingester.serviceMonitor.additionalLabels }}
{{ toYaml .Values.ingester.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.ingester.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.ingester.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-ingester
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.ingester.serviceMonitor.interval }}
interval: {{ .Values.ingester.serviceMonitor.interval }}
{{- end }}
{{- if .Values.ingester.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.ingester.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/querier-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.querier.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-querier
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.querier.serviceMonitor.additionalLabels }}
{{ toYaml .Values.querier.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.querier.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.querier.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-querier
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.querier.serviceMonitor.interval }}
interval: {{ .Values.querier.serviceMonitor.interval }}
{{- end }}
{{- if .Values.querier.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.querier.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/query-frontend-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.query_frontend.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-query-frontend
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.query_frontend.serviceMonitor.additionalLabels }}
{{ toYaml .Values.query_frontend.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.query_frontend.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.query_frontend.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-query-frontend
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.query_frontend.serviceMonitor.interval }}
interval: {{ .Values.query_frontend.serviceMonitor.interval }}
{{- end }}
{{- if .Values.query_frontend.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.query_frontend.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/ruler-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.ruler.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-ruler
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.ruler.serviceMonitor.additionalLabels }}
{{ toYaml .Values.ruler.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.ruler.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.ruler.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-ruler
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.ruler.serviceMonitor.interval }}
interval: {{ .Values.ruler.serviceMonitor.interval }}
{{- end }}
{{- if .Values.ruler.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.ruler.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/store-gateway-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.store_gateway.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-store-gateway
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.store_gateway.serviceMonitor.additionalLabels }}
{{ toYaml .Values.store_gateway.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.store_gateway.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.store_gateway.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-store-gateway
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.store_gateway.serviceMonitor.interval }}
interval: {{ .Values.store_gateway.serviceMonitor.interval }}
{{- end }}
{{- if .Values.store_gateway.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.store_gateway.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}