Fix Observability Issues and Startup Probe Failure #70

Closed
devitq wants to merge 2 commits from fix-observability-issues-17959231904052988380 into feat/setup-observability-in-k8s
10 changed files with 139 additions and 12 deletions
Showing only changes of commit 2d6012866b - Show all commits
@@ -62,6 +62,10 @@ spec:
{{- if .Values.observability.enabled }}
- name: MANAGEMENT_METRICS_TAGS_APPLICATION
value: {{ .Values.observability.metrics.applicationTag | quote }}
{{- if .Values.observability.jsonLogging }}
- name: SPRING_PROFILES_ACTIVE
value: json-logging
{{- end }}
{{- end }}
{{- if $postgresEnv }}
{{- $postgresEnv | nindent 12 }}
@@ -0,0 +1,27 @@
{{- if and .Values.observability.enabled .Values.observability.vmagent.enabled (not .Values.observability.victoriaMetrics.operator.enabled) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "movienight.vmagentName" . }}
labels:
{{- include "movienight.componentLabels" (dict "root" . "component" "vmagent") | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["pods", "nodes", "nodes/proxy", "services", "endpoints"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "movienight.vmagentName" . }}
labels:
{{- include "movienight.componentLabels" (dict "root" . "component" "vmagent") | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "movienight.vmagentName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "movienight.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
@@ -1,4 +1,4 @@
{{- if and .Values.observability.enabled .Values.observability.victoriaMetrics.enabled }}
{{- if and .Values.observability.enabled .Values.observability.victoriaMetrics.enabled (not .Values.observability.victoriaMetrics.operator.enabled) }}
{{- if .Values.observability.victoriaMetrics.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
@@ -0,0 +1,22 @@
{{- if and .Values.observability.enabled .Values.observability.vmagent.enabled .Values.observability.victoriaMetrics.operator.enabled }}
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAgent
metadata:
name: {{ include "movienight.vmagentName" . }}
labels:
{{- include "movienight.componentLabels" (dict "root" . "component" "vmagent") | nindent 4 }}
spec:
scrapeInterval: {{ .Values.observability.vmagent.scrapeInterval }}
remoteWrite:
- url: {{ include "movienight.vmagentRemoteWriteURL" . }}
{{- with .Values.observability.vmagent.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{- end }}
serviceScrapeSelector:
matchLabels:
{{- include "movienight.labels" . | nindent 6 }}
podScrapeSelector:
matchLabels:
{{- include "movienight.labels" . | nindent 6 }}
{{- end }}
@@ -1,4 +1,4 @@
{{- if and .Values.observability.enabled .Values.observability.vmagent.enabled }}
{{- if and .Values.observability.enabled .Values.observability.vmagent.enabled (not .Values.observability.victoriaMetrics.operator.enabled) }}
apiVersion: v1
kind: ConfigMap
metadata:
@@ -19,13 +19,26 @@ data:
{{- if .Values.backend.enabled }}
- job_name: {{ .Values.observability.vmagent.backendJobName | quote }}
metrics_path: /actuator/prometheus
static_configs:
- targets:
- {{ include "movienight.backendMetricsTarget" . | quote }}
labels:
app: {{ include "movienight.name" . | quote }}
release: {{ .Release.Name | quote }}
namespace: {{ .Release.Namespace | quote }}
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
action: keep
regex: backend
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_instance]
action: keep
regex: {{ .Release.Name | quote }}
- source_labels: [__meta_kubernetes_pod_container_port_name]
action: keep
regex: management
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
{{- end }}
- job_name: {{ printf "%s-vmagent" (include "movienight.name" .) | quote }}
static_configs:
@@ -0,0 +1,20 @@
{{- if and .Values.observability.enabled .Values.observability.victoriaMetrics.enabled .Values.observability.victoriaMetrics.operator.enabled }}
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
name: {{ include "movienight.fullname" . }}-backend
labels:
{{- include "movienight.componentLabels" (dict "root" . "component" "backend") | nindent 4 }}
spec:
podMetricsEndpoints:
- port: management
path: /actuator/prometheus
{{- if .Values.observability.metrics.httpServerRequestsHistogram }}
relabelConfigs:
- targetLabel: application
replacement: {{ .Values.observability.metrics.applicationTag | quote }}
{{- end }}
selector:
matchLabels:
{{- include "movienight.componentSelectorLabels" (dict "root" . "component" "backend") | nindent 6 }}
{{- end }}
@@ -0,0 +1,25 @@
{{- if and .Values.observability.enabled .Values.observability.victoriaMetrics.enabled .Values.observability.victoriaMetrics.operator.enabled }}
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMSingle
metadata:
name: {{ include "movienight.victoriaMetricsName" . }}
labels:
{{- include "movienight.componentLabels" (dict "root" . "component" "victoriametrics") | nindent 4 }}
spec:
retentionPeriod: {{ .Values.observability.victoriaMetrics.retentionPeriod }}
{{- if .Values.observability.victoriaMetrics.persistence.enabled }}
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.observability.victoriaMetrics.persistence.size }}
{{- with .Values.observability.victoriaMetrics.persistence.storageClass }}
storageClassName: {{ . | quote }}
{{- end }}
{{- end }}
{{- with .Values.observability.victoriaMetrics.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
+5 -2
View File
@@ -93,10 +93,10 @@ backend:
httpGet:
path: /actuator/health
port: management
initialDelaySeconds: 5
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 24
failureThreshold: 12
gateway:
enabled: false
@@ -125,8 +125,11 @@ observability:
metrics:
applicationTag: movienight
httpServerRequestsHistogram: true
jsonLogging: true
victoriaMetrics:
enabled: true
operator:
enabled: false
image:
repository: docker.io/victoriametrics/victoria-metrics
tag: v1.134.0
+3
View File
@@ -58,9 +58,12 @@ spring:
user-name-attribute: response
server:
port: ${SERVER_PORT:8080}
shutdown: graceful
management:
server:
port: ${MANAGEMENT_SERVER_PORT:8081}
endpoints:
web:
base-path: /actuator
+11 -1
View File
@@ -5,12 +5,22 @@
</encoder>
</appender>
<springProfile name="!file-logging">
<appender name="JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<springProfile name="!file-logging &amp; !json-logging">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="json-logging">
<root level="INFO">
<appender-ref ref="JSON_CONSOLE"/>
</root>
</springProfile>
<springProfile name="file-logging">
<appender name="JSON_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/app.json</file>