Establish clean homelab infrastructure baseline
Reorganize the brownfield repository, remove retired and generated artifacts, harden ignore rules, and record the GitOps/IaC redesign.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# kube-state-metrics — metrics about k8s objects (deployments, pods, nodes, PVCs, ...).
|
||||
# Its chart ships a ServiceMonitor; the VM operator's Prometheus converter turns that
|
||||
# into a VMServiceScrape automatically, so no hand-written scrape CR is needed here.
|
||||
#
|
||||
# Prereq: the Prometheus-operator CRDs (ServiceMonitor, ...) must exist in the cluster
|
||||
# for `serviceMonitor.enabled` to apply. If they don't:
|
||||
# kubectl apply --server-side -f \
|
||||
# https://github.com/prometheus-operator/prometheus-operator/releases/latest/download/bundle.yaml \
|
||||
# # (or just the monitoring.coreos.com CRDs)
|
||||
# Alternatively, disable the ServiceMonitor below and add a VMServiceScrape by hand.
|
||||
set -euo pipefail
|
||||
|
||||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
|
||||
helm repo update prometheus-community
|
||||
|
||||
helm upgrade --install kube-state-metrics prometheus-community/kube-state-metrics \
|
||||
--namespace monitoring \
|
||||
--set prometheus.monitor.enabled=true \
|
||||
--wait
|
||||
@@ -0,0 +1,67 @@
|
||||
# Host metrics (CPU/mem/disk/net/filesystem) for every node. node-exporter has no
|
||||
# ServiceMonitor of its own here, so we scrape it directly with a VMNodeScrape:
|
||||
# vmagent discovers each Node and scrapes its InternalIP:9100.
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
||||
labels:
|
||||
app.kubernetes.io/name: node-exporter
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: node-exporter
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: node-exporter
|
||||
spec:
|
||||
hostNetwork: true # bind 9100 on the node so VMNodeScrape can reach it
|
||||
hostPID: true
|
||||
tolerations:
|
||||
- operator: Exists # run on control-plane / tainted nodes too
|
||||
containers:
|
||||
- name: node-exporter
|
||||
image: quay.io/prometheus/node-exporter:v1.9.1
|
||||
args:
|
||||
- --path.procfs=/host/proc
|
||||
- --path.sysfs=/host/sys
|
||||
- --path.rootfs=/host/root
|
||||
- --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9100
|
||||
hostPort: 9100
|
||||
resources:
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 128Mi
|
||||
volumeMounts:
|
||||
- { name: proc, mountPath: /host/proc, readOnly: true }
|
||||
- { name: sys, mountPath: /host/sys, readOnly: true }
|
||||
- { name: root, mountPath: /host/root, readOnly: true, mountPropagation: HostToContainer }
|
||||
volumes:
|
||||
- { name: proc, hostPath: { path: /proc } }
|
||||
- { name: sys, hostPath: { path: /sys } }
|
||||
- { name: root, hostPath: { path: / } }
|
||||
---
|
||||
apiVersion: operator.victoriametrics.com/v1beta1
|
||||
kind: VMNodeScrape
|
||||
metadata:
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
||||
labels:
|
||||
app.kubernetes.io/part-of: victoria-metrics
|
||||
spec:
|
||||
port: "9100"
|
||||
scheme: http
|
||||
interval: 30s
|
||||
relabelConfigs:
|
||||
- action: labelmap
|
||||
regex: __meta_kubernetes_node_label_(.+)
|
||||
- targetLabel: job
|
||||
replacement: node-exporter
|
||||
Reference in New Issue
Block a user