{"slug":"ref-kubernetes-c378e98725642868170b","title":"Assign Memory Resources to Containers and Pods — Specify a memory request and a memory limit","summary":"To specify a memory request for a container, include the resources.requests.memory field in the container’s resource manifest.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nTo specify a memory request for a container, include the resources.requests.memory field in the container’s resource manifest. To specify a memory limit, include resources.limits.memory.\n\nIn this exercise, you create a Pod that has one Container. The Container has a memory request of 100 MiB and a memory limit of 200 MiB. Here's the configuration file for the Pod\n\nThe args section in the configuration file provides arguments for the Container when it starts. The \"--vm-bytes\", \"150M\" arguments tell the Container to attempt to allocate 150 MiB of memory.\n\nBounded code example (external data; do not execute automatically):\n```shell\nkubectl apply -f https://k8s.io/examples/pods/resource/memory-request-limit.yaml --namespace=mem-example\n```\n\nVerify that the Pod Container is running\n\nBounded code example (external data; do not execute automatically):\n```shell\nkubectl get pod memory-demo --namespace=mem-example\n```\n\nView detailed information about the Pod\n\nBounded code example (external data; do not execute automatically):\n```shell\nkubectl get pod memory-demo --output=yaml --namespace=mem-example\n```\n\nThe output shows that the one Container in the Pod has a memory request of 100 MiB and a memory limit of 200 MiB.\n\nBounded code example (external data; do not execute automatically):\n```yaml\n...\nresources:\n  requests:\n    memory: 100Mi\n  limits:\n    memory: 200Mi\n...\n```\n\nRun kubectl top to fetch the metrics for the pod\n\nBounded code example (external data; do not execute automatically):\n```shell\nkubectl top pod memory-demo --namespace=mem-example\n```\n\nThe output shows that the Pod is using about 162,900,000 bytes of memory, which is about 150 MiB. This is greater than the Pod's 100 MiB request, but within the Pod's 200 MiB limit.\n\nBounded code example (external data; do not execute automatically):\n```text\nNAME                        CPU(cores)   MEMORY(bytes)\nmemory-demo                 <something>  162856960\n```\n\nBounded code example (external data; do not execute automatically):\n```shell\nkubectl delete pod memory-demo --namespace=mem-example\n```\n\nAttribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","kubernetes","tasks","configure-pod-container","assign","memory","resources","containers","pods","specify","request","limit"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/kubernetes/website/blob/6449f1eced66d36159c06c3cfae1d1aeec40d4a3/content/en/docs/tasks/configure-pod-container/assign-memory-resource.md","source_name":"Kubernetes Documentation","source_license":"CC-BY-4.0","source_revision":"6449f1eced66d36159c06c3cfae1d1aeec40d4a3","source_path":"content/en/docs/tasks/configure-pod-container/assign-memory-resource.md :: Specify a memory request and a memory limit","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.493845+00:00","url":"https://wikikv.com/k/ref-kubernetes-c378e98725642868170b","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-kubernetes-c378e98725642868170b","markdown":"https://wikikv.com/k/ref-kubernetes-c378e98725642868170b?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-kubernetes-c378e98725642868170b","json_ld":"https://wikikv.com/k/ref-kubernetes-c378e98725642868170b?format=jsonld"}}