forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: messenger
|
||||
description: Учебный мессенджер с PostgreSQL и шардированным Valkey
|
||||
version: 0.1.0
|
||||
appVersion: lab6
|
||||
type: application
|
||||
@@ -0,0 +1,38 @@
|
||||
groups:
|
||||
- name: messenger-slo
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: messenger:api_error_ratio:1m
|
||||
expr: sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics",status_class="5xx"}[1m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics"}[1m])), 0.001)
|
||||
- record: messenger:api_error_ratio:5m
|
||||
expr: sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics",status_class="5xx"}[5m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~"/health/.*|/metrics"}[5m])), 0.001)
|
||||
- alert: MessengerAPIBurnRate
|
||||
expr: (messenger:api_error_ratio:1m > 0.05) and (messenger:api_error_ratio:5m > 0.05)
|
||||
for: 30s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: API consumes the 99% availability budget at more than 5x in both windows
|
||||
runbook: REPORT.md#диагностика
|
||||
- alert: MessengerReadyBurnRate
|
||||
expr: ((sum(rate(messenger_ready_duration_seconds_count[1m])) - sum(rate(messenger_ready_duration_seconds_bucket{le=~"60|60.0"}[1m]))) / clamp_min(sum(rate(messenger_ready_duration_seconds_count[1m])), 0.001) > 0.25) and ((sum(rate(messenger_ready_duration_seconds_count[5m])) - sum(rate(messenger_ready_duration_seconds_bucket{le=~"60|60.0"}[5m]))) / clamp_min(sum(rate(messenger_ready_duration_seconds_count[5m])), 0.001) > 0.25)
|
||||
for: 30s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: More than 25% of completed jobs missed 60s in both windows (5x burn of 95% SLO)
|
||||
runbook: REPORT.md#диагностика
|
||||
- alert: MessengerQueueLag
|
||||
expr: max(messenger_queue_oldest_seconds) > 60 and max(messenger_queue_depth) > 0
|
||||
for: 15s
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Accepted work has been waiting for over 60 seconds
|
||||
runbook: REPORT.md#диагностика
|
||||
- alert: MessengerTelemetryDrops
|
||||
expr: sum(increase(otelcol_exporter_send_failed_spans_total[1m])) > 0
|
||||
labels:
|
||||
severity: info
|
||||
annotations:
|
||||
summary: Trace backend delivery is failing; inspect bounded collector queues
|
||||
@@ -0,0 +1,71 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 192
|
||||
spike_limit_mib: 48
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 128
|
||||
send_batch_max_size: 256
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
otlphttp/tempo:
|
||||
endpoint: http://messenger-tempo:4318
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
queue_size: 256
|
||||
num_consumers: 2
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
otlphttp/loki:
|
||||
endpoint: http://messenger-loki:3100/otlp
|
||||
timeout: 2s
|
||||
sending_queue:
|
||||
enabled: true
|
||||
queue_size: 256
|
||||
num_consumers: 2
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
service:
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
extensions: [health_check]
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: messenger
|
||||
orgId: 1
|
||||
folder: Highload applications
|
||||
type: file
|
||||
disableDeletion: true
|
||||
editable: false
|
||||
options:
|
||||
path: /dashboards
|
||||
@@ -0,0 +1,35 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://messenger-prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://messenger-loki:3100
|
||||
editable: false
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- name: TraceID
|
||||
matcherType: label
|
||||
matcherRegex: trace_id
|
||||
datasourceUid: tempo
|
||||
url: '$${__value.raw}'
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://messenger-tempo:3200
|
||||
editable: false
|
||||
jsonData:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
filterByTraceID: true
|
||||
spanStartTimeShift: '-1m'
|
||||
spanEndTimeShift: '1m'
|
||||
tags: [{key: service.name, value: service_name}]
|
||||
@@ -0,0 +1,41 @@
|
||||
auth_enabled: false
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
common:
|
||||
path_prefix: /data
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /data/chunks
|
||||
rules_directory: /data/rules
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
limits_config:
|
||||
allow_structured_metadata: true
|
||||
retention_period: 24h
|
||||
ingestion_rate_mb: 2
|
||||
ingestion_burst_size_mb: 4
|
||||
otlp_config:
|
||||
resource_attributes:
|
||||
ignore_defaults: true
|
||||
attributes_config:
|
||||
- action: index_label
|
||||
attributes: [service.name, deployment.environment.name]
|
||||
- action: structured_metadata
|
||||
attributes: [service.instance.id, service.version]
|
||||
compactor:
|
||||
working_directory: /data/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
analytics:
|
||||
reporting_enabled: false
|
||||
@@ -0,0 +1,519 @@
|
||||
{
|
||||
"uid": "messenger",
|
||||
"title": "Messenger: API, worker and SLO",
|
||||
"schemaVersion": 41,
|
||||
"version": 1,
|
||||
"refresh": "5s",
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "HTTP RPS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (route) (rate(messenger_http_requests_total{route!~\"/health/.*|/metrics\"}[1m]))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API 5xx ratio",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(rate(messenger_http_requests_total{status_class=\"5xx\",route!~\"/health/.*|/metrics\"}[1m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~\"/health/.*|/metrics\"}[1m])),0.001)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "HTTP latency p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket{route!~\"/health/.*|/metrics\"}[1m])))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Jobs by outcome",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (outcome) (rate(messenger_jobs_total[1m]))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Job duration p95",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Time to ready p95",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_ready_duration_seconds_bucket[1m])))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Queue depth",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_depth)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Oldest accepted job",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 24,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_oldest_seconds)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "DB pool used/waiting",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(messenger_db_pool_used)"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum(messenger_db_pool_waiting)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 32,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(messenger_worker_busy) / clamp_min(sum(messenger_worker_capacity),1)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "Process CPU",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (service_name) (rate(messenger_process_cpu_seconds_total[1m]))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "cores"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "Process peak RSS",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 40,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max by (service_name) (messenger_process_peak_rss_bytes)"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "Collector queue and failed exports",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(otelcol_exporter_queue_size)"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[1m]))"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"title": "Active alerts",
|
||||
"type": "timeseries",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 48,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "ALERTS{alertstate=\"firing\"}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": [
|
||||
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
rule_files:
|
||||
- /config/alerts.yaml
|
||||
scrape_configs:
|
||||
- job_name: messenger
|
||||
static_configs:
|
||||
- targets: ['messenger-collector:8889']
|
||||
- job_name: collector
|
||||
static_configs:
|
||||
- targets: ['messenger-collector:8888']
|
||||
@@ -0,0 +1,24 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
wal:
|
||||
path: /data/wal
|
||||
local:
|
||||
path: /data/blocks
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 24h
|
||||
ingester:
|
||||
max_block_duration: 5m
|
||||
usage_report:
|
||||
reporting_enabled: false
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- define "messenger.shards" -}}
|
||||
{{- $nodes := list -}}
|
||||
{{- range $i := until (int .Values.valkey.shards) -}}
|
||||
{{- $nodes = append $nodes (printf "shard%d=valkey-%d.valkey:6379" $i $i) -}}
|
||||
{{- end -}}
|
||||
{{- join "," $nodes -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,140 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: messenger-config
|
||||
namespace: {{ .Release.Namespace }}
|
||||
data:
|
||||
APP_PORT: '8080'
|
||||
{{- if .Values.observability.enabled }}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://messenger-collector:4318
|
||||
OTEL_SAMPLE_RATIO: '1'
|
||||
APP_VERSION: lab6
|
||||
{{- end }}
|
||||
VALKEY_COORDINATOR: shard0
|
||||
VALKEY_SHARDS: {{ include "messenger.shards" . | quote }}
|
||||
{{- range $key, $value := .Values.api.env }}
|
||||
{{ $key }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: api
|
||||
name: api
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
selector:
|
||||
app: api
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
{{- if not .Values.autoscaling.enabled }}
|
||||
replicas: {{ .Values.api.replicas }}
|
||||
{{- end }}
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 0
|
||||
maxSurge: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
checksum/config: {{ printf "%s%s" (include "messenger.shards" .) (toJson .Values.api.env) | sha256sum }}
|
||||
labels:
|
||||
app: api
|
||||
spec:
|
||||
{{- with .Values.api.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
imagePullSecrets:
|
||||
- name: {{ .Values.imagePullSecret }}
|
||||
terminationGracePeriodSeconds: 20
|
||||
topologySpreadConstraints:
|
||||
- maxSkew: 1
|
||||
topologyKey: kubernetes.io/hostname
|
||||
whenUnsatisfiable: ScheduleAnyway
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app: api
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65532
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: api
|
||||
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: messenger-config
|
||||
env:
|
||||
- name: S3_ENDPOINT
|
||||
value: s3:9000
|
||||
- name: S3_BUCKET
|
||||
value: {{ .Values.s3.bucket }}
|
||||
- name: S3_TLS
|
||||
value: "false"
|
||||
- name: S3_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: access-key}
|
||||
- name: S3_SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: secret-key}
|
||||
- name: INSTANCE_ID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: CURSOR_SIGNING_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.databaseSecret }}
|
||||
key: cursor-key
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.databaseSecret }}
|
||||
key: database-url
|
||||
resources:
|
||||
{{- toYaml .Values.api.resources | nindent 12 }}
|
||||
lifecycle:
|
||||
preStop:
|
||||
sleep:
|
||||
seconds: 3
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /health/ready
|
||||
port: 8080
|
||||
periodSeconds: 2
|
||||
failureThreshold: 30
|
||||
readinessProbe:
|
||||
timeoutSeconds: {{ .Values.api.readiness.timeoutSeconds }}
|
||||
failureThreshold: {{ .Values.api.readiness.failureThreshold }}
|
||||
httpGet:
|
||||
path: /health/ready
|
||||
port: 8080
|
||||
periodSeconds: 2
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health/live
|
||||
port: 8080
|
||||
periodSeconds: 5
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- $live := lookup "v1" "ConfigMap" .Release.Namespace "messenger-config" -}}
|
||||
{{- if and $live (ne (index $live.data "VALKEY_SHARDS") (include "messenger.shards" .)) -}}
|
||||
{{- $api := lookup "apps/v1" "Deployment" .Release.Namespace "api" -}}
|
||||
{{- if or (gt (int .Values.api.replicas) 0) (and $api (gt (int $api.spec.replicas) 0)) -}}
|
||||
{{- fail "Changing shards requires drained API: use make reshard SHARDS=2 or SHARDS=3" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,33 @@
|
||||
{{- if .Values.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: api
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: api
|
||||
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.cpuPercent }}
|
||||
behavior:
|
||||
scaleUp:
|
||||
stabilizationWindowSeconds: 15
|
||||
policies:
|
||||
- type: Pods
|
||||
value: 1
|
||||
periodSeconds: 30
|
||||
scaleDown:
|
||||
stabilizationWindowSeconds: 120
|
||||
policies:
|
||||
- type: Pods
|
||||
value: 1
|
||||
periodSeconds: 60
|
||||
{{- end }}
|
||||
@@ -0,0 +1,23 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: messenger
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer | quote }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ .Values.ingress.host | quote }}
|
||||
secretName: messenger-tls
|
||||
rules:
|
||||
- host: {{ .Values.ingress.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: api
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,39 @@
|
||||
{{- if .Values.load.enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: load-{{ .Values.load.run }}
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
activeDeadlineSeconds: 300
|
||||
ttlSecondsAfterFinished: 86400
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: load
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: k6
|
||||
image: grafana/k6:1.3.0
|
||||
args: [run, --quiet, /scripts/{{ .Values.load.script }}]
|
||||
env:
|
||||
- name: BASE_URL
|
||||
value: "https://{{ .Values.ingress.host }}"
|
||||
- name: TARGET_INSTANCE_ID
|
||||
value: {{ .Values.load.target | default "" | quote }}
|
||||
- name: DURATION
|
||||
value: {{ .Values.load.duration | quote }}
|
||||
- name: VUS
|
||||
value: {{ .Values.load.vus | quote }}
|
||||
resources:
|
||||
requests: {cpu: 250m, memory: 128Mi}
|
||||
limits: {cpu: '2', memory: 256Mi}
|
||||
volumeMounts:
|
||||
- name: scripts
|
||||
mountPath: /scripts
|
||||
volumes:
|
||||
- name: scripts
|
||||
configMap:
|
||||
name: load-scripts
|
||||
{{- end }}
|
||||
@@ -0,0 +1,32 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: migrate-{{ .Release.Revision }}
|
||||
spec:
|
||||
activeDeadlineSeconds: 180
|
||||
backoffLimit: 3
|
||||
ttlSecondsAfterFinished: 86400
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: migrate
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
imagePullSecrets:
|
||||
- name: {{ .Values.imagePullSecret }}
|
||||
containers:
|
||||
- name: migrate
|
||||
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
|
||||
args: [migrate]
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: messenger-config
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.databaseSecret }}
|
||||
key: database-url
|
||||
resources:
|
||||
requests: {cpu: 50m, memory: 32Mi}
|
||||
limits: {cpu: 500m, memory: 128Mi}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{- if .Values.monitoring.serviceMonitor }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: api
|
||||
labels:
|
||||
app: api
|
||||
spec:
|
||||
namespaceSelector:
|
||||
matchNames: [{{ .Release.Namespace }}]
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api
|
||||
endpoints:
|
||||
- port: http
|
||||
path: /metrics
|
||||
interval: 15s
|
||||
scrapeTimeout: 3s
|
||||
{{- end }}
|
||||
@@ -0,0 +1,59 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: private-databases
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values: [postgres, valkey]
|
||||
policyTypes: [Ingress]
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels: {app: worker}
|
||||
ports:
|
||||
- {protocol: TCP, port: 5432}
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: api
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 5432
|
||||
- protocol: TCP
|
||||
port: 6379
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: migrate
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 5432
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: private-api
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: api
|
||||
policyTypes: [Ingress]
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: traefik
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: monitoring
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8080
|
||||
@@ -0,0 +1,124 @@
|
||||
{{- 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 }}
|
||||
@@ -0,0 +1,66 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: postgres
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
serviceName: postgres
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 30
|
||||
containers:
|
||||
- name: postgres
|
||||
image: {{ .Values.postgres.image | quote }}
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: messenger
|
||||
- name: POSTGRES_USER
|
||||
value: messenger
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.databaseSecret }}
|
||||
key: postgres-password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
resources:
|
||||
{{- toYaml .Values.postgres.resources | nindent 12 }}
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: [pg_isready, -U, messenger, -d, messenger]
|
||||
initialDelaySeconds: 3
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
{{- if .Values.storageClass }}
|
||||
storageClassName: {{ .Values.storageClass | quote }}
|
||||
{{- end }}
|
||||
accessModes: [ReadWriteOnce]
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.postgres.storage }}
|
||||
@@ -0,0 +1,97 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: s3
|
||||
spec:
|
||||
selector: {app: s3}
|
||||
ports:
|
||||
- {name: s3, port: 9000, targetPort: 9000}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: s3
|
||||
spec:
|
||||
serviceName: s3
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: s3}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: s3}
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsNonRoot: true
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: s3
|
||||
image: {{ .Values.s3.image }}
|
||||
args: [server, -dir=/data, -s3, -s3.port=9000, -s3.config=/identity/identities.json, -master.volumeSizeLimitMB=100, -volume.max=32]
|
||||
ports: [{containerPort: 9000}]
|
||||
readinessProbe:
|
||||
tcpSocket: {port: 9000}
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 256Mi}
|
||||
limits: {cpu: '1', memory: 512Mi}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: {drop: [ALL]}
|
||||
volumeMounts:
|
||||
- {name: objects, mountPath: /data}
|
||||
- {name: identity, mountPath: /identity, readOnly: true}
|
||||
volumes:
|
||||
- name: identity
|
||||
secret: {secretName: {{ .Values.s3.secret }}, items: [{key: identities.json, path: identities.json}]}
|
||||
volumeClaimTemplates:
|
||||
- metadata: {name: objects}
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
resources:
|
||||
requests: {storage: {{ .Values.s3.storage }}}
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: s3-bootstrap-{{ .Release.Revision }}
|
||||
spec:
|
||||
ttlSecondsAfterFinished: 3600
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: s3-bootstrap}
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
imagePullSecrets: [{name: {{ .Values.imagePullSecret }}}]
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
|
||||
args: [s3-bootstrap]
|
||||
env:
|
||||
- {name: S3_ENDPOINT, value: 's3:9000'}
|
||||
- {name: S3_TLS, value: 'false'}
|
||||
- {name: S3_BUCKET, value: {{ .Values.s3.bucket }}}
|
||||
- name: S3_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: root-user}
|
||||
- name: S3_SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: root-password}
|
||||
resources:
|
||||
requests: {cpu: 50m, memory: 64Mi}
|
||||
limits: {cpu: 200m, memory: 128Mi}
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: private-s3
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: {app: s3}
|
||||
policyTypes: [Ingress]
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchExpressions:
|
||||
- {key: app, operator: In, values: [api, worker, s3-bootstrap, reconcile]}
|
||||
ports: [{protocol: TCP, port: 9000}]
|
||||
@@ -0,0 +1,57 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: valkey
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: valkey
|
||||
ports:
|
||||
- port: 6379
|
||||
targetPort: 6379
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: valkey
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
serviceName: valkey
|
||||
replicas: {{ .Values.valkey.shards }}
|
||||
podManagementPolicy: Parallel
|
||||
selector:
|
||||
matchLabels:
|
||||
app: valkey
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: valkey
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 30
|
||||
containers:
|
||||
- name: valkey
|
||||
image: {{ .Values.valkey.image | quote }}
|
||||
args: [valkey-server, --appendonly, 'yes', --appendfsync, always, --maxmemory, {{ .Values.valkey.maxmemory | quote }}, --maxmemory-policy, noeviction]
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
resources:
|
||||
{{- toYaml .Values.valkey.resources | nindent 12 }}
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: [valkey-cli, ping]
|
||||
initialDelaySeconds: 2
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
{{- if .Values.storageClass }}
|
||||
storageClassName: {{ .Values.storageClass | quote }}
|
||||
{{- end }}
|
||||
accessModes: [ReadWriteOnce]
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.valkey.storage }}
|
||||
@@ -0,0 +1,111 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: worker
|
||||
spec:
|
||||
replicas: {{ .Values.worker.replicas }}
|
||||
selector:
|
||||
matchLabels: {app: worker}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: worker}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: {{ .Values.imagePullSecret }}
|
||||
terminationGracePeriodSeconds: 60
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65532
|
||||
seccompProfile: {type: RuntimeDefault}
|
||||
containers:
|
||||
- name: worker
|
||||
image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}"
|
||||
args: [worker]
|
||||
resources:
|
||||
requests: {cpu: 250m, memory: 256Mi}
|
||||
limits: {cpu: '1', memory: 1Gi}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities: {drop: [ALL]}
|
||||
envFrom:
|
||||
- configMapRef: {name: messenger-config}
|
||||
env:
|
||||
- {name: GOMEMLIMIT, value: 768MiB}
|
||||
- {name: BROKER_ADDRESS, value: 'broker:6379'}
|
||||
- {name: S3_ENDPOINT, value: 's3:9000'}
|
||||
- {name: S3_TLS, value: 'false'}
|
||||
- name: S3_BUCKET
|
||||
value: {{ .Values.s3.bucket }}
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.databaseSecret }}, key: database-url}
|
||||
- name: CURSOR_SIGNING_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.databaseSecret }}, key: cursor-key}
|
||||
- name: S3_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: access-key}
|
||||
- name: S3_SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef: {name: {{ .Values.s3.secret }}, key: secret-key}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: broker
|
||||
spec:
|
||||
selector: {app: broker}
|
||||
ports:
|
||||
- {name: streams, port: 6379}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: broker
|
||||
spec:
|
||||
serviceName: broker
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: broker}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: broker}
|
||||
spec:
|
||||
containers:
|
||||
- name: broker
|
||||
image: {{ .Values.valkey.image }}
|
||||
args: [valkey-server, --appendonly, 'yes', --appendfsync, always, --maxmemory, 128mb, --maxmemory-policy, noeviction]
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 160Mi}
|
||||
limits: {cpu: '1', memory: 256Mi}
|
||||
ports:
|
||||
- {containerPort: 6379}
|
||||
readinessProbe:
|
||||
exec: {command: [valkey-cli, ping]}
|
||||
volumeMounts:
|
||||
- {name: data, mountPath: /data}
|
||||
volumeClaimTemplates:
|
||||
- metadata: {name: data}
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
{{- if .Values.storageClass }}
|
||||
storageClassName: {{ .Values.storageClass | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests: {storage: 1Gi}
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: private-broker
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: {app: broker}
|
||||
policyTypes: [Ingress]
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels: {app: worker}
|
||||
ports:
|
||||
- {protocol: TCP, port: 6379}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"valkey": {"type": "object", "properties": {"shards": {"type": "integer", "minimum": 2, "maximum": 3}}},
|
||||
"api": {"type": "object", "properties": {"replicas": {"type": "integer", "minimum": 0}}},
|
||||
"image": {"type": "object", "properties": {"digest": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"}}}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
# Existing lab2 release; shared persistent stores and credentials.
|
||||
image:
|
||||
repository: asisti.registry.twcstorage.ru/mtusi2026lab6
|
||||
digest: sha256:04a28492ad5645ed56c58d51a95214a758426adc2b0271fc184e8f204c3fa7cc
|
||||
imagePullSecret: registry-pull
|
||||
databaseSecret: messenger-secrets
|
||||
api:
|
||||
readiness:
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 2
|
||||
replicas: 2
|
||||
resources:
|
||||
requests: {cpu: 250m, memory: 128Mi}
|
||||
limits: {cpu: '1', memory: 768Mi}
|
||||
env:
|
||||
SESSION_TTL_SECONDS: '3600'
|
||||
DEPENDENCY_TIMEOUT_MS: '2000'
|
||||
DEPENDENCY_POOL_SIZE: '8'
|
||||
REQUEST_TIMEOUT_SECONDS: '4'
|
||||
SHUTDOWN_TIMEOUT_SECONDS: '5'
|
||||
GOMEMLIMIT: 640MiB
|
||||
MAX_CONNECTIONS: '16'
|
||||
MAX_BODY_BYTES: '10485760'
|
||||
postgres:
|
||||
image: postgres:17.6-alpine
|
||||
storage: 2Gi
|
||||
resources:
|
||||
requests: {cpu: 250m, memory: 256Mi}
|
||||
limits: {cpu: '1', memory: 512Mi}
|
||||
valkey:
|
||||
image: valkey/valkey:8.1.3-alpine
|
||||
shards: 3
|
||||
storage: 1Gi
|
||||
maxmemory: 64mb
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 96Mi}
|
||||
limits: {cpu: 500m, memory: 128Mi}
|
||||
# Пустое значение использует default StorageClass. Задать до первой установки.
|
||||
storageClass: ''
|
||||
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 2
|
||||
maxReplicas: 4
|
||||
cpuPercent: 60
|
||||
monitoring:
|
||||
serviceMonitor: false
|
||||
load:
|
||||
enabled: false
|
||||
run: manual
|
||||
script: scaling.js
|
||||
duration: 30
|
||||
vus: 32
|
||||
|
||||
ingress:
|
||||
host: hl.agapov.space
|
||||
className: traefik
|
||||
clusterIssuer: letsencrypt-prod
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:3.85@sha256:49312939c00c01e5ee6afbd7d728b18027821d3764c35a797a72acd4fdf3296a
|
||||
secret: messenger-s3
|
||||
bucket: attachments
|
||||
storage: 5Gi
|
||||
|
||||
worker:
|
||||
replicas: 1
|
||||
|
||||
observability:
|
||||
enabled: true
|
||||
collectorImage: otel/opentelemetry-collector-contrib:0.135.0@sha256:89107a3a8f4636a396927edf7025bb9614b8da2d92f4cc3f43109e8d115736e2
|
||||
prometheusImage: prom/prometheus:v3.5.0@sha256:63805ebb8d2b3920190daf1cb14a60871b16fd38bed42b857a3182bc621f4996
|
||||
lokiImage: grafana/loki:3.5.5@sha256:31628519045e7f28692a7ae73b4a3fd293dccb425585ed5d16ceea3b5c9592e6
|
||||
tempoImage: grafana/tempo:2.8.2@sha256:0ef775495967cd5d7a6b2e146b6ea695d624803c8db8349fb8ce4164f719f9b7
|
||||
grafanaImage: grafana/grafana:12.1.1@sha256:a1701c2180249361737a99a01bc770db39381640e4d631825d38ff4535efa47d
|
||||
secret: messenger-grafana
|
||||
Reference in New Issue
Block a user