KubeCost¶
Configuration¶
Prerequisites¶
CRD Configuration¶
KubeCost has exposed Metrics, and all that is needed is for DataKit to discover these Metrics and report them.
- Create
kubecost-serverMonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: kubecost-metrics
labels:
app.kubernetes.io/name: cost-analyzer
namespace: kubecost
spec:
selector:
matchLabels:
app.kubernetes.io/name: cost-analyzer
endpoints:
- port: metrics
- Execute
kubectl apply -f
kubecost-serverMonitor.yaml
DataKit Configuration¶
If already enabled, please ignore
- Enable DataKit Service Monitor auto-discovery
Add env : ENV_INPUT_CONTAINER_ENABLE_AUTO_DISCOVERY_OF_PROMETHEUS_SERVICE_MONITORS
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: daemonset-datakit
name: datakit
namespace: datakit
spec:
...
template:
...
spec:
...
containers:
- env:
...
- name: ENV_INPUT_CONTAINER_ENABLE_AUTO_DISCOVERY_OF_PROMETHEUS_SERVICE_MONITORS
value: "true"
...
- Restart DataKit
Metrics¶
kubecost-cost-analyzer
¶
Metric | Description |
---|---|
container_cpu_allocation | Container CPU allocation |
container_gpu_allocation | Container GPU allocation |
container_memory_allocation_bytes | Container memory allocation |
pv_hourly_cost | PersistentVolume hourly cost |
node_total_hourly_cost | Node total hourly cost |
node_cpu_hourly_cost | Node CPU hourly cost |
node_ram_hourly_cost | Node RAM hourly cost |
node_gpu_hourly_cost | Node GPU hourly cost |