Welcome to the Linux Foundation Forum!

args:["", ""] to args: - - - fail, and ununderstood behaviour.

Hello,

Question 1

Running this pod from the official doc works (https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/)

apiVersion: v1
kind: Pod
metadata:
  name: memory-demo
  namespace: default
spec:
  containers:
  - name: memory-demo-ctr
    image: polinux/stress
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"
    command: ["stress"]
    args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]

But as soon as i try to write the "args" without the [] the build fail ..?? (i do not copy-paste)

apiVersion: v1
kind: Pod
metadata:
  name: memory-demo
  namespace: default
spec:
  containers:
  - name: memory-demo-ctr
    image: polinux/stress
    resources:
      limits:
        memory: "200Mi"
      requests:
        memory: "100Mi"
    command: ["stress"]
    args:
    - -vm
    - "1"
    - -vm-bytes
    - "150M"
    - -vm-hang
    - "1"

However, the same try using the course yaml sample works.

.............
     memory: "200Mi"
        args: ["--cpus", "2", "--mem-total", "350Mi", "--mem-alloc-size", "100Mi", "--mem-alloc-sleep", "1s"]
        #- -cpus
        #- "2" # set 1 cpu to the container
        #- -mem-total
        #- "350Mi"
        #- -mem-alloc-size
        #- "100Mi"
        #- -mem-alloc-sleep
        #- "1s"
        terminationMessagePath: /dev/termination-log
.....................

Any idea ? kind of weird...

note that if i add some cpus configurations , to pod crash again. Strange again, or maybe on some image the cpus can not be configurate ?

apiVersion: v1
kind: Pod
metadata:
  name: memory-demo
  namespace: default
spec:
  containers:
  - name: memory-demo-ctr
    image: polinux/stress
    resources:
      limits:
        cpu: "2"
        memory: "200Mi"
      requests:
        cpu: "1"
        memory: "100Mi"
    command: ["stress"]
    args: ["--cpus", "1", "--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]

Question 2

i run another pod from the official doc (https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/), i add the memory config from the course. That works (what ever the way i write the args), and the top command monitor the memory consumption, fine.

apiVersion: v1
kind: Pod
metadata:
  name: cpu-demo
  namespace: default
spec:
  containers:
  - name: cpu-demo-ctr
    image: vish/stress
    resources:
      limits:
        cpu: "2"
      requests:
        cpu: "0.5"
    args: ["--cpus", "1", "--mem-total", "350Mi", "--mem-alloc-size", "100Mi", "--mem-alloc-sleep", "1s"]
            #- -cpus
            #- "2"
            #- -mem-total
            #- "350Mi"
            #- -mem-alloc-size
            #- "100Mi"
            #- -mem-alloc-sleep
            #- "1s"

Now i attempt to allocate some memory as they explain in the Official doc (like in the previous test), but surprisly i the pod can not build, it return an error status... why ?

apiVersion: v1
kind: Pod
metadata:
  name: cpu-demo
  namespace: default
spec:
  containers:
  - name: cpu-demo-ctr
    image: vish/stress
    resources:
      limits:
        cpu: "2"
      requests:
        cpu: "0.5"
    args: ["--cpus", "1", "--vm", "1", "--vm-bytes", "350M", "--vm-hang", "1"]

Sorry, it s like many questions. I am trying to understand, but all of that doesn't sound really logic.

Thank you.

Comments

  • Hi @djedje,

    They seem to be two separate applications, each accepting distinct sets of arguments. Attempting to mix in unexpected arguments may cause your containers to crash. In order to understand the differences in behavior, and how arguments should be used in their respective config manifests, I would recommend researching the documentation on each container image.

    Regards,
    -Chris

Categories

Upcoming Training