Skip to content

Commit

Permalink
Merge pull request #56 from junotx/node-exporter
Browse files Browse the repository at this point in the history
[prometheus-node-exporter] support to use global.imageRegistry and global.nodeSelector for process-exporter and calico-exporter
  • Loading branch information
benjaminhuo authored Mar 13, 2024
2 parents 6e221ec + 9c023b8 commit 4726cab
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 15 deletions.
4 changes: 2 additions & 2 deletions 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.21.2
version: 4.21.3
appVersion: 1.6.0
home: https://github.com/prometheus/node_exporter/
sources:
Expand All @@ -31,4 +31,4 @@ dependencies:
- condition: CalicoExporter.enabled
name: CalicoExporter
repository: file://charts/calico-exporter
version: 0.2.0
version: 0.2.*
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.2.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# Containers for the calico-exporter daemonset.
*/}}
{{- define "calico-exporter.daemonset.containers" -}}
{{- $imageDict := dict "Values" (dict "image" .Values.CalicoExporter.image "global" .Values.global) }}
- name: calico-exporter
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: "{{ .Values.CalicoExporter.image.repository }}:{{ .Values.CalicoExporter.image.tag }}"
image: '{{ include "calico-exporter.common.image" $imageDict }}'
imagePullPolicy: {{ .Values.CalicoExporter.image.pullPolicy }}
args:
- --web.listen-address=127.0.0.1:{{ .Values.CalicoExporter.service.innerPort }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- define "calico-exporter.common.image" -}}
{{- if .Values.image.digest }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- else if .Values.registry }}
{{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- else }}
{{- printf "%s:%s@%s" .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- end }}
{{- else }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.image.repository .Values.image.tag }}
{{- else if .Values.registry }}
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }}
{{- else }}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }}
{{- end }}
{{- end }}
{{- end }}

{{- define "calico-exporter.kubeRbacProxy.image" }}
{{- $imageDict := dict "Values" (dict "image" .Values.kubeRbacProxy.image "global" .Values.global) }}
{{- include "calico-exporter.common.image" $imageDict }}
{{- end }}

{{- define "calico-exporter.imagePullSecrets" -}}
{{- if .Values.imagePullSecrets }}
{{- toYaml .Values.imagePullSecrets }}
{{- else if and .Values.global .Values.global.imagePullSecrets }}
{{- toYaml .Values.global.imagePullSecrets }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- define "calico-exporter.common.nodeSelectors.nodeSelector" -}}
{{- if and .global .global.nodeSelector }}
{{- $nodeSelector := .global.nodeSelector -}}
{{- if .nodeSelector }}
{{- $nodeSelector = merge .nodeSelector $nodeSelector -}}
{{- end -}}
{{- toYaml $nodeSelector }}
{{- else }}
{{- toYaml .nodeSelector }}
{{- end }}
{{- end -}}

{{- define "calico-exporter.nodeSelector" -}}
{{- $_dict := (dict "nodeSelector" .Values.nodeSelector "global" .Values.global) }}
{{- include "calico-exporter.common.nodeSelectors.nodeSelector" $_dict }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ spec:
securityContext:
{{ toYaml .Values.securityContext | indent 8 }}
{{- end }}
{{- with (include "calico-exporter.imagePullSecrets" .) }}
imagePullSecrets:
{{- . | nindent 6 }}
{{- end }}
containers:
- args:
- --logtostderr
- --secure-listen-address=0.0.0.0:{{ .Values.service.targetPort }}
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
- --upstream=http://127.0.0.1:{{ .Values.service.innerPort }}/
image: "{{ .Values.kubeRbacProxy.image }}:{{ .Values.kubeRbacProxy.tag }}"
image: '{{ include "calico-exporter.kubeRbacProxy.image" . }}'
imagePullPolicy: {{ .Values.kubeRbacProxy.image.pullPolicy }}
name: kube-rbac-proxy
ports:
- containerPort: {{ .Values.service.targetPort }}
Expand All @@ -39,7 +44,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
image: '{{ include "calico-exporter.common.image" . }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --web.listen-address=127.0.0.1:{{ .Values.service.innerPort }}
Expand All @@ -56,10 +61,10 @@ spec:
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
{{- with (include "calico-exporter.nodeSelector" .) }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
Expand Down
12 changes: 10 additions & 2 deletions charts/prometheus-node-exporter/charts/calico-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
registry: ""
repository: kubesphere/calico-exporter
tag: v0.2.0
digest: ""
pullPolicy: IfNotPresent

imagePullSecrets: []

## Creates a Prometheus Operator ServiceMonitor
serviceMonitor:
scrapeTimeout: "30s"
Expand Down Expand Up @@ -93,8 +97,12 @@ tolerations:
operator: Exists

kubeRbacProxy:
image: kubesphere/kube-rbac-proxy
tag: v0.11.0
image:
registry: ""
repository: kubesphere/kube-rbac-proxy
tag: v0.14.0
digest: ""
pullPolicy: IfNotPresent
resources:
limits:
cpu: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.5.0"
description: A Helm chart for prometheus process-exporter
name: ProcessExporter
version: 0.5.4
version: 0.5.5
home: https://github.com/mumoshu/prometheus-process-exporter
sources:
- https://github.com/ncabatoff/process-exporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Containers for the prometheus-process-exporter daemonset.
*/}}
{{- define "prometheus-process-exporter.daemonset.containers" -}}
{{- $imageDict := dict "Values" (dict "image" .Values.ProcessExporter.image "global" .Values.global) }}
- name: process-exporter
image: "{{ .Values.ProcessExporter.image.repository }}:{{ .Values.ProcessExporter.image.tag }}"
image: '{{ include "prometheus-process-exporter.common.image" $imageDict }}'
imagePullPolicy: {{ .Values.ProcessExporter.image.pullPolicy }}
args:
- --procfs=/host/proc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- define "prometheus-process-exporter.common.image" -}}
{{- if .Values.image.digest }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- else if .Values.registry }}
{{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- else }}
{{- printf "%s:%s@%s" .Values.image.repository .Values.image.tag .Values.image.digest }}
{{- end }}
{{- else }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.image.repository .Values.image.tag }}
{{- else if .Values.registry }}
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }}
{{- else }}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
registry: ""
repository: ncabatoff/process-exporter
tag: 0.5.0
digest: ""
pullPolicy: IfNotPresent

## Specify entries of `process_names:` in the process-exporter config
Expand Down
5 changes: 3 additions & 2 deletions charts/prometheus-node-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ CalicoExporter:
operator: Exists

kubeRbacProxy:
image: kubesphere/kube-rbac-proxy
tag: v0.11.0
image:
repository: kubesphere/kube-rbac-proxy
tag: v0.14.0
resources: {}

0 comments on commit 4726cab

Please sign in to comment.