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

Create service and serviceMonitor #467

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions deploy/kubernetes/helm/sloth/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -126,4 +125,3 @@ spec:
name: {{ include "sloth.fullname" . }}
{{- end }}
{{- end }}

8 changes: 4 additions & 4 deletions deploy/kubernetes/helm/sloth/templates/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.metrics.enabled }}
{{- if .Values.podMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
Expand All @@ -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:
Expand All @@ -16,7 +16,7 @@ spec:
{{- include "sloth.selectorLabels" . | nindent 6 }}
podMetricsEndpoints:
- port: metrics
{{- with .Values.metrics.scrapeInterval }}
{{- with .Values.podMonitor.scrapeInterval }}
interval: {{.}}
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions deploy/kubernetes/helm/sloth/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
35 changes: 35 additions & 0 deletions deploy/kubernetes/helm/sloth/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
35 changes: 30 additions & 5 deletions deploy/kubernetes/helm/sloth/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ commonPlugins:
cpu: 5m
memory: 50Mi

metrics:
enabled: true
#scrapeInterval: 30s
prometheusLabels: {}

customSloConfig:
enabled: false
path: /windows
Expand All @@ -67,6 +62,11 @@ customSloConfig:
# value: spot
# effect: NoSchedule

podMonitor:
enabled: true
#scrapeInterval: 30s
prometheusLabels: {}

securityContext:
pod: null
# fsGroup: 100
Expand All @@ -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: []