What is the difference between request and args in kubernetes resource config?

4/1/2019

I am trying to set a deployment of containers in Kubernetes. I want the resource utilization to be controlled. I am referring this.

An example config from the docs -

resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"
    command: ["stress"]
    args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]

But I am not able to clearly understand the differences between requests and args fields. limits is somewhat clear that the container should not be using more than the limit amount of resource.

What purpose does args serve exactly. Here, it is stated that this is the resource the container would start with. Then how is it different from requests ?

-- Rajeev Ranjan
kubernetes

2 Answers

4/1/2019

Regards the args, since it's the only thing wasn't answered in the duplicated answer:

Args are not related to the resources definition, it just describes which arguments you pass to your docker container on start.

In the case of the example, the image is probably running java code, which and the user decided to pass some arguments related to memory to it. If the image was using a different image, for example, node, the args could be some arguments to the node code running inside the container.

Hope that it answers your question.

-- Shai Katz
Source: StackOverflow

4/1/2019
resources:
  limits:
    memory: "200Mi"
  requests:
    memory: "100Mi"

Resource has request and limit field.
It means minimum 100Mi memory should be allocated to the container and this values is sufficient to run the container. In case of spike in traffic, it can burst memory consumption upto 200Mi. It is kind of upper bound. If it exceeds more than 200Mi the container will get killed/restarted.

Args are being passed to command(stress container) as command line arguments.

Stress Tool Docs
DockerImageForStress

looks like stress is consuming --vm-bytes=150M memory passed as an arg

I think with the help of stress tool, the docs are trying to indicate the container can consume memory between request and limit values.

-- Ankit Deshpande
Source: StackOverflow