Skip to content

Commit

Permalink
Add ServiceMonitor for cloudflared (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
z0rc authored Oct 23, 2024
1 parent 2d1b5f2 commit 92546fe
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
# Go workspace file
go.work

cloudflare-tunnel-ingress-controller
!image/cloudflare-tunnel-ingress-controller
/cloudflare-tunnel-ingress-controller
hack/dev/cloudflare-api.yaml

# go test coverage report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ apiVersion: v1
kind: Service
metadata:
name: controlled-cloudflared-connector-headless
labels:
app.kubernetes.io/component: controlled-cloudflared
{{- include "cloudflare-tunnel-ingress-controller.labels" . | nindent 4 }}
annotations:
{{- if not .Values.cloudflaredServiceMonitor.create }}
prometheus.io/scrape: "true"
prometheus.io/port: "44483"
{{- end }}
spec:
ports:
ports:
- name: metrics
port: 44483
protocol: TCP
clusterIP: None
selector:
"app": "controlled-cloudflared-connector"
"strrl.dev/cloudflare-tunnel-ingress-controller": "controlled-cloudflared-connector"
clusterIP: None
selector:
app: controlled-cloudflared-connector
strrl.dev/cloudflare-tunnel-ingress-controller: controlled-cloudflared-connector
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.cloudflaredServiceMonitor.create }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "cloudflare-tunnel-ingress-controller.fullname" . }}-controlled-cloudflared
labels:
{{- include "cloudflare-tunnel-ingress-controller.labels" . | nindent 4 }}
spec:
{{- if .Values.cloudflaredServiceMonitor.jobLabel }}
jobLabel: {{ .Values.cloudflaredServiceMonitor.jobLabel }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/component: controlled-cloudflared
{{- include "cloudflare-tunnel-ingress-controller.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
path: /metrics
scheme: {{ .Values.cloudflaredServiceMonitor.scheme }}
{{- if .Values.cloudflaredServiceMonitor.interval }}
interval: {{ .Values.cloudflaredServiceMonitor.interval }}
{{- end }}
{{- if .Values.cloudflaredServiceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.cloudflaredServiceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.cloudflaredServiceMonitor.honorLabels }}
honorLabels: {{ .Values.cloudflaredServiceMonitor.honorLabels }}
{{- end }}
{{- if .Values.cloudflaredServiceMonitor.metricRelabelings }}
metricRelabelings: {{ .Values.cloudflaredServiceMonitor.metricRelabelings }}
{{- end }}
{{- if .Values.cloudflaredServiceMonitor.relabelings }}
relabelings: {{ .Values.cloudflaredServiceMonitor.relabelings }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
11 changes: 11 additions & 0 deletions helm/cloudflare-tunnel-ingress-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@ cloudflared:
tag: latest
replicaCount: 1
protocol: quic

cloudflaredServiceMonitor:
create: false
jobLabel: ""
interval: ""
scrapeTimeout: ""
honorLabels: false
metricRelabelings: []
relabelings: []
labels: {}
scheme: http

0 comments on commit 92546fe

Please sign in to comment.