Kubernetes Cost Optimization in Practice: From Resource Governance to FinOps

Overview Kubernetes has become the standard runtime platform for cloud-native applications, but its elasticity and flexibility also bring significant cost management challenges. According to the Flexera 2024 State of the Cloud report, enterprises waste an average of 32% of their cloud spending, and resource waste in Kubernetes clusters is particularly pronounced — an ungoverned K8s cluster often has resource utilization below 30%. Kubernetes cost optimization is not a one-time configuration adjustment, but a systematic engineering effort spanning resource governance, autoscaling, instance type selection, and FinOps culture building....

November 22, 2024 · 23 mins · 4737 words · XuBaojin

cgroup v2 Complete Guide: From Architecture Principles to Production Practices

Overview In today’s era of cloud-native and containerized technologies, Linux cgroups (control groups) serve as the kernel-level foundation for resource isolation and limiting. From Docker container memory limits to Kubernetes Pod CPU Requests/Limits, the underlying mechanism relies on cgroups. However, cgroup v1’s multi-hierarchy architecture, inconsistent controller behavior, and confusing thread model have caused numerous operational headaches in production. cgroup v2, as a complete reimagining of v1, adopts a unified hierarchy architecture that fundamentally addresses v1’s design flaws....

July 23, 2024 · 23 mins · 4791 words · XuBaojin

Kubernetes Resource Management: Requests and Limits

Semantics of Requests and Limits In Kubernetes, each container can be configured with CPU and Memory requests and limits. Many developers fail to distinguish between the two, leading to frequent Pod evictions or OOMKilled events. apiVersion: v1 kind: Pod metadata: name: api-server spec: containers: - name: app image: myapp:latest resources: requests: cpu: "250m" # 0.25 core memory: "256Mi" limits: cpu: "500m" # 0.5 core memory: "512Mi" Core Differences Dimension Requests Limits Phase At scheduling time At runtime Meaning Minimum guaranteed resources for the Pod Maximum resource cap for the Pod Scheduler behavior Scheduler uses requests to determine if a node has sufficient resources Scheduler ignores limits Runtime behavior Guaranteed share in cgroups CPU is throttled; Memory triggers OOMKilled Overcommit allowed Yes (sum of all Pod limits on a node can exceed node capacity) Memory overcommit is not recommended In simple terms:...

February 2, 2024 · 9 mins · 1862 words · XuBaojin