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

feat: Add extra labels on serviceMonitor + allow toleration configuration on helm chart #303

Open
wants to merge 4 commits into
base: dev
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
19 changes: 14 additions & 5 deletions docs_src/tutorials/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ to be installed from the source code.
### Parameters
#### Service monitor parameters

| Name | Description | Value |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `serviceMonitor.enabled` | Create ServiceMonitor Resource for scraping metrics using PrometheusOperator | `false` |
| `serviceMonitor.namespace` | The namespace in which the ServiceMonitor will be created (if not set, default to namespace on which this chart is installed) | `""` |
| `serviceMonitor.interval` | The interval at which metrics should be scraped | `1m` |
| Name | Description | Value |
| ------------------------- -----| ----------------------------------------------------------------------------------------------| ------------------------- |
| `serviceMonitor.enabled` | Create ServiceMonitor Resource for scraping metrics using PrometheusOperator | `false` |
| `serviceMonitor.namespace` | The namespace in which the ServiceMonitor will be created (if not set, default to namespace on which this chart is installed) | `""` |
| `serviceMonitor.interval` | The interval at which metrics should be scraped | `1m` |
| `serviceMonitor.labels` | Extra labels for the ServiceMonitor | `{}` |
| `serviceMonitor.scrapeTimeout` | Specify the timeout after which the scrape is ended | `30s` |
| `serviceMonitor.relabelings` | Allow to add extra labels to metrics | Add node metrics |

#### Other parameters
| Name | Description | Value |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------| ------------------------- |
| `affinity` | Pod scheduling preference. Can be used for instance when some node does not support scaphandre. | `{}` |
| `tolerations` | Tolerations for pod assignment. Evaluated as a template. | `- operator: "Exists"` |

## Install Prometheus

Expand Down
2 changes: 1 addition & 1 deletion helm/scaphandre/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ appVersion: 0.1.1
description: A Helm chart for Scaphandre electrical power consumption agent
home: https://github.com/hubblo-org/scaphandre
name: scaphandre
version: 0.1.0
version: 0.1.1
9 changes: 7 additions & 2 deletions helm/scaphandre/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ spec:
runAsUser: {{ .Values.userID }}
runAsGroup: {{ .Values.userGroup }}
serviceAccountName: {{ template "scaphandre.name" . }}
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
# Tolerate all taints for observability
- operator: "Exists"
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- hostPath:
path: /proc
Expand Down
11 changes: 9 additions & 2 deletions helm/scaphandre/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ metadata:
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
app.kubernetes.io/name: {{ template "scaphandre.name" . }}
{{- include "labels.common" . | nindent 4 }}
{{- if .Values.serviceMonitor.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
spec:
endpoints:
- path: /metrics
Expand All @@ -18,7 +21,11 @@ spec:
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
scrapeTimeout: 30s
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
Expand Down
20 changes: 19 additions & 1 deletion helm/scaphandre/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scaphandre:
command: prometheus
args: {}
extraArgs:
containers:
containers: null
# rustBacktrace: '1'

# Run as root user to get proper permissions
Expand All @@ -28,3 +28,21 @@ serviceMonitor:
interval: 1m
# Specifies namespace, where ServiceMonitor should be installed
# namespace: monitoring

# Extra labels for the ServiceMonitor
labels: {}

# Specify the timeout after which the scrape is ended
scrapeTimeout: 30s

relabelings:
- action: replace
sourceLabels:
- __meta_kubernetes_pod_node_name
targetLabel: node

affinity: {}

tolerations:
# Tolerate all taints for observability
- operator: "Exists"
Loading