clawchain/deploy/k8s/monitoring/prometheus.yaml
2026-05-15 19:18:10 +03:00

158 lines
3.8 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
namespace: clawchain
labels:
app.kubernetes.io/name: prometheus
app.kubernetes.io/component: monitoring
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: prometheus
template:
metadata:
labels:
app.kubernetes.io/name: prometheus
spec:
serviceAccountName: prometheus
containers:
- name: prometheus
image: prom/prometheus:v2.48.0
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention.time=30d"
- "--web.enable-lifecycle"
ports:
- name: http
containerPort: 9090
volumeMounts:
- name: config
mountPath: /etc/prometheus
- name: data
mountPath: /prometheus
- name: alert-rules
mountPath: /etc/prometheus/alerts
resources:
requests:
cpu: "250m"
memory: "512Mi"
limits:
cpu: "1"
memory: "2Gi"
volumes:
- name: config
configMap:
name: prometheus-config
- name: data
persistentVolumeClaim:
claimName: prometheus-data
- name: alert-rules
configMap:
name: prometheus-alert-rules
---
apiVersion: v1
kind: Service
metadata:
name: prometheus
namespace: clawchain
spec:
type: ClusterIP
ports:
- name: http
port: 9090
targetPort: 9090
selector:
app.kubernetes.io/name: prometheus
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheus-data
namespace: clawchain
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 50Gi
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
namespace: clawchain
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-clawchain
rules:
- apiGroups: [""]
resources: ["pods", "services", "endpoints"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus-clawchain
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-clawchain
subjects:
- kind: ServiceAccount
name: prometheus
namespace: clawchain
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: clawchain
data:
prometheus.yml: |
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- /etc/prometheus/alerts/*.yml
alerting:
alertmanagers:
- static_configs:
- targets: ["alertmanager:9093"]
scrape_configs:
- job_name: "clawchain-node"
kubernetes_sd_configs:
- role: pod
namespaces:
names: ["clawchain"]
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
regex: clawchain-node
action: keep
- source_labels: [__meta_kubernetes_pod_ip]
target_label: __address__
replacement: "${1}:26660"
- source_labels: [__meta_kubernetes_pod_name]
target_label: instance
- job_name: "gpu-provider"
kubernetes_sd_configs:
- role: pod
namespaces:
names: ["clawchain"]
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
regex: claw-gpu-provider
action: keep
- source_labels: [__meta_kubernetes_pod_ip]
target_label: __address__
replacement: "${1}:9090"
- source_labels: [__meta_kubernetes_pod_name]
target_label: instance