Can containers use all resources? Yes, but they should not!
Some reservations are necessary
Capacity must be divided between system, cluster and containers
Reserved for system services
Reserved for cluster components
Allocatable = Capacity - System - Kubernetes
Overview of AWS, Azure and Google Cloud
Larger VMs have less overhead
More VMs provide more availability
Instance calculator for cloud providers
Read reservations from managed cluster
kubelet
flags:
--system-reserved=memory=500Mi,cpu=100m
--kube-reserved=memory=500Mi,cpu=100m
Implementation depends on deployment
For example in kind
:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
system-reserved: memory=12Gi,cpu=2000m
kube-reserved: memory=100Mi,cpu=100m
node-exporter
collects host metrics…
…and exports them for scraping
Metrics include CPU, memory, disk, network and a lot more!
Some are disabled but the defaults are reasonable
Start Kubernetes API proxy and read metrics endpoint:
kubectl proxy
H=localhost:8001
NS=kube-system
SVC=node-exporter-prometheus-node-exporter
curl -s $H/api/v1/namespaces/$NS/services/$SVC:metrics/proxy/metrics \
| grep node_cpu_seconds_total