CodexBloom - Programming Q&A Platform

Kubernetes Pod Resource Limits Causing High Memory Usage and OOM Killed Errors in 1.24

👀 Views: 82 💬 Answers: 1 📅 Created: 2025-06-13
kubernetes gke resource-limits oom-killed YAML

I need some guidance on I'm trying to configure I'm running a Kubernetes cluster on GKE with version 1.24, and I've been experiencing issues where my pods are getting OOM killed despite having resource limits set... My deployment config specifies resource requests and limits as follows: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: app-container image: my-app-image:latest resources: requests: memory: "256Mi" cpu: "500m" limits: memory: "512Mi" cpu: "1" ``` Despite these limits, I see in the logs that around 2-3 minutes after starting, some pods start logging "Killed process due to OOM". The logs don't indicate excessive memory usage leading up to the OOM event; instead, they show a sudden spike right before termination. I've tried increasing the memory limits to 1Gi, but it didn’t fix the scenario, and I still see OOM errors shortly after. I also tried enabling the Kubernetes metrics server to gain insights into memory usage, and I've observed that while the containers are under the limit, there are important spikes in memory usage (up to 700Mi). I'm also using a memory leak detection library within my application to test if there are leaks, but it hasn't shown any important issues yet. Is it possible that the resource limits are being ignored or that there is a misconfiguration? How can I troubleshoot this further? Any insights into optimizing the memory usage or adjustments to settings in GKE that could help prevent these OOM kills would be greatly appreciated. Hoping someone can shed some light on this. The project is a microservice built with Yaml.