Skip to content

Commit

Permalink
[prometheus-node-exporter] Add support for custom service labels (#4807)
Browse files Browse the repository at this point in the history
* [prometheus-node-exporter] Allow setting service labels

- Allow setting service labels
- Add comments on service fields

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

* Bump chart version

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

* Support service labels

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

* Add CI test case for service labels

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

* Correct indent in a comment and a typo

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

* Add CI test case for servicePort

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>

---------

Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com>
  • Loading branch information
zeritti authored Aug 22, 2024
1 parent 4f5ed8e commit a6913a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-node-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- prometheus
- exporter
type: application
version: 4.38.0
version: 4.39.0
appVersion: 1.8.2
home: https://github.com/prometheus/node_exporter/
sources:
Expand Down
5 changes: 5 additions & 0 deletions charts/prometheus-node-exporter/ci/service-labels-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
service:
labels:
foo: bar
baz: quux
3 changes: 3 additions & 0 deletions charts/prometheus-node-exporter/ci/serviceport-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
service:
servicePort: 80
3 changes: 3 additions & 0 deletions charts/prometheus-node-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ metadata:
namespace: {{ include "prometheus-node-exporter.namespace" . }}
labels:
{{- include "prometheus-node-exporter.labels" $ | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
31 changes: 27 additions & 4 deletions charts/prometheus-node-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,49 @@ kubeRBACProxy:
# limits:
# cpu: 100m
# memory: 64Mi
# requests:
# cpu: 10m
# memory: 32Mi
# requests:
# cpu: 10m
# memory: 32Mi

## Service configuration
service:
## Creating a service is enabled by default
enabled: true

## Service type
type: ClusterIP
## IP address for type ClusterIP
clusterIP: ""
## Default service port. Sets the port of the exposed container as well (NE or kubeRBACProxy).
## Use "servicePort" below if changing the service port only is desired.
port: 9100
## Service port. Use this field if you wish to set a different service port
## without changing the container port ("port" above).
servicePort: ""
## Targeted port in the pod. Must refer to an open container port ("port" or "portName").
## (IntOrString)
targetPort: 9100
nodePort:
## Name of the service port. Sets the port name of the main container (NE) as well.
portName: metrics
## Port number for service type NodePort
nodePort: null

## If true, node exporter will listen on all interfaces
listenOnAllInterfaces: true

## Additional annotations and labels for the service
annotations:
prometheus.io/scrape: "true"
labels: {}

## Dual stack settings for the service
## https://kubernetes.io/docs/concepts/services-networking/dual-stack/#services
ipDualStack:
enabled: false
ipFamilies: ["IPv6", "IPv4"]
ipFamilyPolicy: "PreferDualStack"

## External traffic policy setting (Cluster, Local)
externalTrafficPolicy: ""

# Set a NetworkPolicy with:
Expand Down

0 comments on commit a6913a3

Please sign in to comment.