diff --git a/deploy/kubernetes/helm/sloth/templates/deployment.yaml b/deploy/kubernetes/helm/sloth/templates/deployment.yaml index f4b75491..0e598809 100644 --- a/deploy/kubernetes/helm/sloth/templates/deployment.yaml +++ b/deploy/kubernetes/helm/sloth/templates/deployment.yaml @@ -1,4 +1,3 @@ - --- apiVersion: apps/v1 kind: Deployment @@ -63,7 +62,7 @@ spec: {{- if .Values.sloth.debug.enabled }} - --debug {{- end}} - {{- if .Values.metrics.enabled }} + {{- if or (eq .Values.podMonitor.enabled true) (eq .Values.serviceMonitor.enabled true) }} ports: - containerPort: 8081 name: metrics @@ -126,4 +125,3 @@ spec: name: {{ include "sloth.fullname" . }} {{- end }} {{- end }} - diff --git a/deploy/kubernetes/helm/sloth/templates/pod-monitor.yaml b/deploy/kubernetes/helm/sloth/templates/pod-monitor.yaml index 722114d5..fc990613 100644 --- a/deploy/kubernetes/helm/sloth/templates/pod-monitor.yaml +++ b/deploy/kubernetes/helm/sloth/templates/pod-monitor.yaml @@ -1,4 +1,4 @@ -{{- if .Values.metrics.enabled }} +{{- if .Values.podMonitor.enabled }} --- apiVersion: monitoring.coreos.com/v1 kind: PodMonitor @@ -7,7 +7,7 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "sloth.labels" . | nindent 4 }} - {{- with .Values.metrics.prometheusLabels }} + {{- with .Values.podMonitor.prometheusLabels }} {{- toYaml . | nindent 4 }} {{- end }} spec: @@ -16,7 +16,7 @@ spec: {{- include "sloth.selectorLabels" . | nindent 6 }} podMetricsEndpoints: - port: metrics - {{- with .Values.metrics.scrapeInterval }} + {{- with .Values.podMonitor.scrapeInterval }} interval: {{.}} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/deploy/kubernetes/helm/sloth/templates/service.yaml b/deploy/kubernetes/helm/sloth/templates/service.yaml new file mode 100644 index 00000000..138ec754 --- /dev/null +++ b/deploy/kubernetes/helm/sloth/templates/service.yaml @@ -0,0 +1,22 @@ +{{- if .Values.service.enabled }} +--- +kind: Service +apiVersion: v1 +metadata: + name: {{ include "sloth.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "sloth.labels" . | nindent 4 }} + {{- if .Values.service.annotations }} + annotations: + {{- toYaml .Values.service.annotations | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - name: metrics + port: {{ .Values.service.httpPort }} + protocol: TCP + selector: + {{- include "sloth.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/deploy/kubernetes/helm/sloth/templates/servicemonitor.yaml b/deploy/kubernetes/helm/sloth/templates/servicemonitor.yaml new file mode 100644 index 00000000..24cf09a2 --- /dev/null +++ b/deploy/kubernetes/helm/sloth/templates/servicemonitor.yaml @@ -0,0 +1,35 @@ +{{- if .Values.serviceMonitor.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "sloth.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "sloth.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.additionalLabels }} + {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + {{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + {{- end }} + honorLabels: {{ .Values.serviceMonitor.honorLabels }} + honorTimestamps: {{ .Values.serviceMonitor.honorTimestamps }} + {{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml .Values.serviceMonitor.metricRelabelings | nindent 4 }} + {{- end }} + {{- if .Values.serviceMonitor.relabelings }} + relabelings: + {{- toYaml .Values.serviceMonitor.relabelings | nindent 4 }} + {{- end }} + selector: + matchLabels: + {{- include "sloth.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/deploy/kubernetes/helm/sloth/values.yaml b/deploy/kubernetes/helm/sloth/values.yaml index 8c8b309d..d4d17785 100644 --- a/deploy/kubernetes/helm/sloth/values.yaml +++ b/deploy/kubernetes/helm/sloth/values.yaml @@ -46,11 +46,6 @@ commonPlugins: cpu: 5m memory: 50Mi -metrics: - enabled: true - #scrapeInterval: 30s - prometheusLabels: {} - customSloConfig: enabled: false path: /windows @@ -67,6 +62,11 @@ customSloConfig: # value: spot # effect: NoSchedule +podMonitor: + enabled: true + #scrapeInterval: 30s + prometheusLabels: {} + securityContext: pod: null # fsGroup: 100 @@ -75,3 +75,28 @@ securityContext: # runAsUser: 100 container: null # allowPrivilegeEscalation: false + +service: + enabled: false + type: ClusterIP + httpPort: 8081 + annotations: {} + +# Enable this if you're using https://github.com/coreos/prometheus-operator +serviceMonitor: + enabled: false + # additionalLabels is the set of additional labels to add to the ServiceMonitor + additionalLabels: {} + # How long until a scrape request times out. + scrapeTimeout: '30s' + # fallback to the prometheus default unless specified + # interval: 30s + ## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/helm/charts/tree/master/stable/prometheus-operator#tldr) + honorLabels: true + ## Whether Prometheus should use the timestamps of the metrics exposed + honorTimestamps: true + # MetricRelabelConfigs to apply to samples before ingestion https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig + metricRelabelings: [] + # RelabelConfigs to apply to samples before scraping. https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig + relabelings: [] + \ No newline at end of file