Skip to content

Commit

Permalink
feat(application-template): promethus metric 지원 추가 (#14)
Browse files Browse the repository at this point in the history
* feat(application-template): prometheus metric, operator를 지원하도록 service, serviceMonitor 수정

* feat: pod에서 prometheus metrics port 노출

* feat: default value 수정

* refactor: indent를 nindent로 변경

* fix: 기본 포트 변경

* fix: prometheus container targetPort 수정할 수 있게 하기

* feat: servicemonitor 기본으로 켜기

* feat: chart 버전 올리기

* fix: deployment에서 target port 지원하기
  • Loading branch information
atobaum authored Feb 1, 2024
1 parent 296c584 commit c7ceddf
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/application-template/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ maintainers:
- name: modusign
url: https://github.com/modusign
name: application-template
version: 1.3.2
version: 1.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ spec:
containerPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
- name: metrics
containerPort: {{ default .Values.global.observability.prometheus.port .Values.global.observability.prometheus.targetPort }}
protocol: TCP
{{- end }}
{{- with .Values.scheduler.livenessProbe }}
livenessProbe:
httpGet:
Expand Down
10 changes: 10 additions & 0 deletions charts/application-template/templates/scheduler/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ spec:
port: {{ .port }}
targetPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
{{- with .Values.global.observability.prometheus }}
- name: metrics
port: {{ .port }}
{{- if .targetPort }}
targetPort: {{ .targetPort }}
{{- end }}
protocol: TCP
{{- end }}
{{- end }}
selector:
{{- include "application.scheduler.selectorLabels" . | nindent 4 }}
Expand Down
5 changes: 5 additions & 0 deletions charts/application-template/templates/server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ spec:
containerPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
- name: metrics
containerPort: {{ default .Values.global.observability.prometheus.port .Values.global.observability.prometheus.targetPort }}
protocol: TCP
{{- end }}
{{- with .Values.server.livenessProbe }}
livenessProbe:
httpGet:
Expand Down
10 changes: 10 additions & 0 deletions charts/application-template/templates/server/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ spec:
port: {{ .port }}
targetPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
{{- with .Values.global.observability.prometheus }}
- name: metrics
port: {{ .port }}
{{- if .targetPort }}
targetPort: {{ .targetPort }}
{{- end }}
protocol: TCP
{{- end }}
{{- end }}
selector:
{{- include "application.server.selectorLabels" . | nindent 4 }}
Expand Down
18 changes: 18 additions & 0 deletions charts/application-template/templates/service_monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and .Values.global.observability.prometheus.enabled .Values.global.observability.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "application.name" . }}
labels:
{{- include "application.commonLabels" . | nindent 4 }}
spec:
endpoints:
- path: {{ .Values.global.observability.prometheus.path }}
port: metrics
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "application.commonLabels" . | nindent 6}}
{{- end }}
5 changes: 5 additions & 0 deletions charts/application-template/templates/worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ spec:
containerPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
- name: metrics
containerPort: {{ default .Values.global.observability.prometheus.port .Values.global.observability.prometheus.targetPort }}
protocol: TCP
{{- end }}
{{- with .Values.worker.livenessProbe }}
livenessProbe:
httpGet:
Expand Down
10 changes: 10 additions & 0 deletions charts/application-template/templates/worker/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ spec:
port: {{ .port }}
targetPort: {{ .targetPort }}
protocol: TCP
{{- end }}
{{- if .Values.global.observability.prometheus.enabled }}
{{- with .Values.global.observability.prometheus }}
- name: metrics
port: {{ .port }}
{{- if .targetPort }}
targetPort: {{ .targetPort }}
{{- end }}
protocol: TCP
{{- end }}
{{- end }}
selector:
{{- include "application.worker.selectorLabels" . | nindent 4 }}
Expand Down
12 changes: 9 additions & 3 deletions charts/application-template/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ global:
datadog:
admissionController:
enabled: false
# -- inject grafana
# grafana:
# enabled: false
# -- set up additional service port and setup
prometheus:
enabled: false
port: 9100
# targetPort: 9100
path: /metrics
# -- create Prometheus Operator ServiceMonitorCR
serviceMonitor:
enabled: true

## Server
server:
Expand Down

0 comments on commit c7ceddf

Please sign in to comment.