forked from mtusi2026/mtusi2026lab6
125 lines
5.0 KiB
YAML
125 lines
5.0 KiB
YAML
{{- if .Values.observability.enabled }}
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: messenger-observability
|
|
labels: {app: messenger-observability}
|
|
data:
|
|
{{- range $path, $_ := .Files.Glob "files/observability/*" }}
|
|
{{ base $path }}: |
|
|
{{ $.Files.Get $path | indent 4 }}
|
|
{{- end }}
|
|
{{- $components := list
|
|
(dict "name" "collector" "image" .Values.observability.collectorImage "port" 4318 "args" (list "--config=/config/collector.yaml") "memory" "256Mi" "uid" 10001)
|
|
(dict "name" "prometheus" "image" .Values.observability.prometheusImage "port" 9090 "args" (list "--config.file=/config/prometheus.yaml" "--storage.tsdb.path=/data" "--storage.tsdb.retention.time=24h" "--storage.tsdb.retention.size=1GB") "memory" "384Mi" "uid" 65534)
|
|
(dict "name" "loki" "image" .Values.observability.lokiImage "port" 3100 "args" (list "-config.file=/config/loki.yaml") "memory" "384Mi" "uid" 10001)
|
|
(dict "name" "tempo" "image" .Values.observability.tempoImage "port" 3200 "args" (list "-config.file=/config/tempo.yaml") "memory" "384Mi" "uid" 10001)
|
|
(dict "name" "grafana" "image" .Values.observability.grafanaImage "port" 3000 "args" list "memory" "256Mi" "uid" 472)
|
|
}}
|
|
{{- range $component := $components }}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: messenger-{{ $component.name }}
|
|
spec:
|
|
selector: {app: 'messenger-{{ $component.name }}'}
|
|
ports:
|
|
- {name: http, port: {{ $component.port }}, targetPort: {{ $component.port }}}
|
|
{{- if eq $component.name "collector" }}
|
|
- {name: metrics, port: 8889, targetPort: 8889}
|
|
- {name: self-metrics, port: 8888, targetPort: 8888}
|
|
{{- end }}
|
|
{{- if eq $component.name "tempo" }}
|
|
- {name: otlp, port: 4318, targetPort: 4318}
|
|
{{- end }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: messenger-{{ $component.name }}
|
|
spec:
|
|
serviceName: messenger-{{ $component.name }}
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {app: 'messenger-{{ $component.name }}'}
|
|
template:
|
|
metadata:
|
|
labels: {app: 'messenger-{{ $component.name }}'}
|
|
annotations:
|
|
checksum/config: {{ ($.Files.Glob "files/observability/*").AsConfig | sha256sum }}
|
|
spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: {{ $component.uid }}
|
|
fsGroup: {{ $component.uid }}
|
|
containers:
|
|
- name: {{ $component.name }}
|
|
image: {{ $component.image }}
|
|
args: {{ $component.args | toJson }}
|
|
ports:
|
|
- {containerPort: {{ $component.port }}}
|
|
resources:
|
|
requests: {cpu: 50m, memory: 96Mi}
|
|
limits: {cpu: '1', memory: {{ $component.memory }}}
|
|
readinessProbe:
|
|
tcpSocket: {port: {{ $component.port }}}
|
|
{{- if eq $component.name "grafana" }}
|
|
env:
|
|
- {name: GF_PATHS_DATA, value: /data}
|
|
- {name: GF_AUTH_ANONYMOUS_ENABLED, value: 'false'}
|
|
- {name: GF_USERS_ALLOW_SIGN_UP, value: 'false'}
|
|
- {name: GF_ANALYTICS_REPORTING_ENABLED, value: 'false'}
|
|
- name: GF_SECURITY_ADMIN_USER
|
|
valueFrom:
|
|
secretKeyRef: {name: {{ $.Values.observability.secret }}, key: username}
|
|
- name: GF_SECURITY_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef: {name: {{ $.Values.observability.secret }}, key: password}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- {name: data, mountPath: /data}
|
|
- {name: config, mountPath: /config, readOnly: true}
|
|
{{- if eq $component.name "grafana" }}
|
|
- {name: config, mountPath: /etc/grafana/provisioning/datasources/datasources.yaml, subPath: datasources.yaml, readOnly: true}
|
|
- {name: config, mountPath: /etc/grafana/provisioning/dashboards/dashboards.yaml, subPath: dashboards.yaml, readOnly: true}
|
|
- {name: config, mountPath: /dashboards/messenger.json, subPath: messenger.json, readOnly: true}
|
|
{{- end }}
|
|
volumes:
|
|
- name: config
|
|
configMap: {name: messenger-observability}
|
|
volumeClaimTemplates:
|
|
- metadata: {name: data}
|
|
spec:
|
|
accessModes: [ReadWriteOnce]
|
|
{{- if $.Values.storageClass }}
|
|
storageClassName: {{ $.Values.storageClass | quote }}
|
|
{{- end }}
|
|
resources:
|
|
requests: {storage: 2Gi}
|
|
{{- end }}
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: private-observability
|
|
spec:
|
|
podSelector:
|
|
matchExpressions:
|
|
- {key: app, operator: In, values: [messenger-collector, messenger-prometheus, messenger-loki, messenger-tempo, messenger-grafana]}
|
|
policyTypes: [Ingress]
|
|
ingress:
|
|
- from:
|
|
- podSelector:
|
|
matchExpressions:
|
|
- {key: app, operator: In, values: [api, worker, messenger-collector, messenger-prometheus, messenger-loki, messenger-tempo, messenger-grafana]}
|
|
ports:
|
|
- {protocol: TCP, port: 4318}
|
|
- {protocol: TCP, port: 8888}
|
|
- {protocol: TCP, port: 8889}
|
|
- {protocol: TCP, port: 9090}
|
|
- {protocol: TCP, port: 3100}
|
|
- {protocol: TCP, port: 3200}
|
|
- {protocol: TCP, port: 3000}
|
|
{{- end }}
|