Skip to content

Add Configuration for Monitoring via Prometheus Operator #49

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion charts/cloudflare-tunnel-remote/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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.1.0
version: 0.2.0

# 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
Expand Down
17 changes: 12 additions & 5 deletions charts/cloudflare-tunnel-remote/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
pod: cloudflared
{{- include "cloudflare-tunnel-remote.selectorLabels" . | nindent 6 }}
template:
metadata:
creationTimestamp: null
annotations:
# These are here so the deployment rolls when the config or secret change.
checksum/secret: {{ .Values.cloudflare.tunnel_token | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
pod: cloudflared
{{- include "cloudflare-tunnel-remote.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "cloudflare-tunnel-remote.fullname" . }}
containers:
Expand All @@ -32,7 +35,7 @@ spec:
# In a k8s environment, the metrics server needs to listen outside the pod it runs on.
# The address 0.0.0.0:2000 allows any pod in the namespace.
- --metrics
- 0.0.0.0:2000
- 0.0.0.0:{{ .Values.metrics.port }}
- run
envFrom:
- secretRef:
Expand All @@ -43,7 +46,11 @@ spec:
# Cloudflared has a /ready endpoint which returns 200 if and only if
# it has an active connection to the edge.
path: /ready
port: 2000
port: {{ .Values.metrics.port }}
failureThreshold: 1
initialDelaySeconds: 10
periodSeconds: 10
ports:
- containerPort: {{ .Values.metrics.port }}
name: metrics
protocol: TCP
21 changes: 21 additions & 0 deletions charts/cloudflare-tunnel-remote/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "cloudflare-tunnel-remote.fullname" . }}
{{- with .Values.metrics.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "cloudflare-tunnel-remote.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- protocol: TCP
port: {{ .Values.metrics.port }}
name: metrics
targetPort: {{ .Values.metrics.port }}
selector:
{{- include "cloudflare-tunnel-remote.selectorLabels" . | nindent 4 }}
{{- end }}
29 changes: 29 additions & 0 deletions charts/cloudflare-tunnel-remote/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "cloudflare-tunnel-remote.fullname" . }}
{{- with .Values.metrics.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "cloudflare-tunnel-remote.labels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "cloudflare-tunnel-remote.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
path: /metrics
{{- with .Values.metrics.serviceMonitor.endpointConfig }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/cloudflare-tunnel-remote/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ serviceAccount:
name: ""

podAnnotations: {}
podLabels:
pod: cloudflared

# Security items common to everything in the pod. Here we require that it
# does not run as the user defined in the image, literally named "nonroot".
Expand Down Expand Up @@ -57,3 +59,18 @@ tolerations: []

# Default affinity is to spread out over nodes; use this to override.
affinity: {}

metrics:
# The port on which to expose the metrics and ready endpoints
port: 2000
service:
# Additional annotations for the metrics service
annotations: {}
serviceMonitor:
enabled: false
# Endpoint configuration for the ServiceMonitor
endpointConfig: {}
# Additional annotations for the ServiceMonitor
annotations: {}
# Additional labels for the ServiceMonitor
labels: {}
2 changes: 1 addition & 1 deletion charts/cloudflare-tunnel/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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.3.0
version: 0.4.0

# 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
Expand Down
2 changes: 1 addition & 1 deletion charts/cloudflare-tunnel/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
warp-routing:
enabled: {{ .Values.cloudflare.enableWarp }}
# Serves the metrics server under /metrics and the readiness server under /ready
metrics: 0.0.0.0:2000
metrics: 0.0.0.0:{{ .Values.metrics.port }}
# Autoupdates applied in a k8s pod will be lost when the pod is removed or restarted, so
# autoupdate doesn't make sense in Kubernetes. However, outside of Kubernetes, we strongly
# recommend using autoupdate.
Expand Down
6 changes: 5 additions & 1 deletion charts/cloudflare-tunnel/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ spec:
# Cloudflared has a /ready endpoint which returns 200 if and only if
# it has an active connection to the edge.
path: /ready
port: 2000
port: {{ .Values.metrics.port }}
failureThreshold: 1
initialDelaySeconds: 10
periodSeconds: 10
ports:
- containerPort: {{ .Values.metrics.port }}
name: metrics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: metrics
name: http-metrics

protocol: TCP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant, the default is TCP.

Suggested change
protocol: TCP

volumeMounts:
- name: config
mountPath: /etc/cloudflared/config
Expand Down
21 changes: 21 additions & 0 deletions charts/cloudflare-tunnel/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "cloudflare-tunnel.fullname" . }}
{{- with .Values.metrics.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
labels:
{{- include "cloudflare-tunnel.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- protocol: TCP
port: {{ .Values.metrics.port }}
name: metrics
targetPort: {{ .Values.metrics.port }}
selector:
{{- include "cloudflare-tunnel.selectorLabels" . | nindent 4 }}
{{- end }}
29 changes: 29 additions & 0 deletions charts/cloudflare-tunnel/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "cloudflare-tunnel.fullname" . }}
{{- with .Values.metrics.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "cloudflare-tunnel.labels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "cloudflare-tunnel.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
path: /metrics
{{- with .Values.metrics.serviceMonitor.endpointConfig }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/cloudflare-tunnel/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@ tolerations: []

# Default affinity is to spread out over nodes; use this to override.
affinity: {}

metrics:
# The port on which to expose the metrics and ready endpoints
port: 2000
service:
# Additional annotations for the metrics service
annotations: {}
serviceMonitor:
enabled: false
# Endpoint configuration for the ServiceMonitor
endpointConfig: {}
# Additional annotations for the ServiceMonitor
annotations: {}
# Additional labels for the ServiceMonitor
labels: {}