Skip to content

Commit

Permalink
feat: Add pod monitor for pulling metrics
Browse files Browse the repository at this point in the history
- Add network policy for allowing traffic from prometheus
- Add Pod monitor to pull metrics
  • Loading branch information
murillio4 committed Oct 20, 2024
1 parent 454442d commit 05c2c19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
9 changes: 5 additions & 4 deletions charts/flaiserator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ spec:
template:
metadata:
annotations:
prometheus.io/scrape: "false"
prometheus.io/port: "8080"
prometheus.io/path: "/metrics"
{{- with .Values.podLabels }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand All @@ -37,6 +34,10 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
ports:
- name: metrics
containerPort: 8080
protocol: TCP
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.volumeMounts }}
Expand Down
20 changes: 20 additions & 0 deletions charts/flaiserator/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "flaiserator.fullname" . }}-prometheus
labels:
{{- include "flaiserator.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "flaiserator.selectorLabels" . | nindent 6 }}
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Release.Namespace }}
- podSelector:
matchLabels:
app.kubernetes.io/name: prometheus
policyTypes:
- Ingress
13 changes: 13 additions & 0 deletions charts/flaiserator/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
labels:
{{- include "flaiserator.labels" . | nindent 4 }}
name: {{ include "flaiserator.fullname" . }}
spec:
selector:
matchLabels:
{{- include "flaiserator.selectorLabels" . | nindent 6 }}
podMetricsEndpoints:
- port: metrics
path: /metrics

0 comments on commit 05c2c19

Please sign in to comment.