diff --git a/charts/deployment-operator/templates/_helpers.tpl b/charts/deployment-operator/templates/_helpers.tpl index b9a52a53..db082e34 100644 --- a/charts/deployment-operator/templates/_helpers.tpl +++ b/charts/deployment-operator/templates/_helpers.tpl @@ -67,7 +67,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "agentk.fullname" -}} -{{- include "deployment-operator.fullname"}}-agentk +{{- include "deployment-operator.fullname" . }}-agentk {{- end }} {{/* diff --git a/charts/deployment-operator/templates/deployment.yaml b/charts/deployment-operator/templates/deployment.yaml index 9f3ca7a6..0488ce84 100644 --- a/charts/deployment-operator/templates/deployment.yaml +++ b/charts/deployment-operator/templates/deployment.yaml @@ -16,6 +16,11 @@ spec: {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} + {{- if .Values.monitoring.enabled }} + {{- with .Values.monitoring.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} labels: {{- include "deployment-operator.selectorLabels" . | nindent 8 }} {{- with .Values.podLabels }} @@ -53,6 +58,12 @@ spec: - name: http containerPort: {{ .Values.service.port }} protocol: TCP + {{- if .Values.monitoring.enabled }} + - name: observability + containerPort: {{ .Values.monitoring.metricsPort }} + - name: metrics + containerPort: 8080 + {{- end }} livenessProbe: httpGet: path: /healthz diff --git a/charts/deployment-operator/templates/podmonitor.yaml b/charts/deployment-operator/templates/podmonitor.yaml new file mode 100644 index 00000000..2ff37c76 --- /dev/null +++ b/charts/deployment-operator/templates/podmonitor.yaml @@ -0,0 +1,22 @@ +{{ if .Values.monitoring.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "deployment-operator.fullname" . }}-podmonitor + labels: +{{ include "deployment-operator.labels" . | indent 4 }} +spec: + podMetricsEndpoints: + - port: metrics + path: '/metrics' + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "deployment-operator.fullname" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + podTargetLabels: + - app.kubernetes.io/name + - app.kubernetes.io/instance +{{ end }} \ No newline at end of file diff --git a/charts/deployment-operator/templates/servicemonitor.yaml b/charts/deployment-operator/templates/servicemonitor.yaml index 842eb45e..e9634ade 100644 --- a/charts/deployment-operator/templates/servicemonitor.yaml +++ b/charts/deployment-operator/templates/servicemonitor.yaml @@ -1,4 +1,4 @@ -{{- if (.Values.agentk.serviceMonitor).enabled }} +{{- if .Values.monitoring.enabled }} apiVersion: v1 kind: Service metadata: @@ -8,7 +8,7 @@ metadata: spec: type: ClusterIP ports: - - port: 8080 + - port: {{ .Values.monitoring.metricsPort }} protocol: TCP name: observability selector: @@ -29,6 +29,6 @@ spec: - {{ .Release.Namespace | quote }} endpoints: - port: observability - interval: 30s - scrapeTimeout: 25s + interval: 10s + scrapeTimeout: 9s {{- end }} diff --git a/charts/deployment-operator/values.yaml b/charts/deployment-operator/values.yaml index 1770bfa2..6cb8d71a 100644 --- a/charts/deployment-operator/values.yaml +++ b/charts/deployment-operator/values.yaml @@ -42,9 +42,6 @@ rbac: podLabels: {} podAnnotations: {} -# prometheus.io/scrape: "true" -# prometheus.io/path: "/metrics" -# prometheus.io/port: "8080" podSecurityContext: {} # fsGroup: 2000 @@ -57,6 +54,15 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 +monitoring: + enabled: false + prometheus: "k8s" + metricsPort: 8000 + podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/path: "/metrics" + prometheus.io/port: "8000" + service: type: ClusterIP port: 9001 @@ -135,6 +141,3 @@ agentk: # requests: # cpu: 100m # memory: 128Mi - serviceMonitor: - # Specifies whether to create a ServiceMonitor resource for collecting Prometheus metrics - enabled: false