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/)

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: memory-demo
  5. namespace: default
  6. spec:
  7. containers:
  8. - name: memory-demo-ctr
  9. image: polinux/stress
  10. resources:
  11. limits:
  12. memory: "200Mi"
  13. requests:
  14. memory: "100Mi"
  15. command: ["stress"]
  16. 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)

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: memory-demo
  5. namespace: default
  6. spec:
  7. containers:
  8. - name: memory-demo-ctr
  9. image: polinux/stress
  10. resources:
  11. limits:
  12. memory: "200Mi"
  13. requests:
  14. memory: "100Mi"
  15. command: ["stress"]
  16. args:
  17. - -vm
  18. - "1"
  19. - -vm-bytes
  20. - "150M"
  21. - -vm-hang
  22. - "1"

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

  1. .............
  2. memory: "200Mi"
  3. args: ["--cpus", "2", "--mem-total", "350Mi", "--mem-alloc-size", "100Mi", "--mem-alloc-sleep", "1s"]
  4. #- -cpus
  5. #- "2" # set 1 cpu to the container
  6. #- -mem-total
  7. #- "350Mi"
  8. #- -mem-alloc-size
  9. #- "100Mi"
  10. #- -mem-alloc-sleep
  11. #- "1s"
  12. terminationMessagePath: /dev/termination-log
  13. .....................

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 ?

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: memory-demo
  5. namespace: default
  6. spec:
  7. containers:
  8. - name: memory-demo-ctr
  9. image: polinux/stress
  10. resources:
  11. limits:
  12. cpu: "2"
  13. memory: "200Mi"
  14. requests:
  15. cpu: "1"
  16. memory: "100Mi"
  17. command: ["stress"]
  18. 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.

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: cpu-demo
  5. namespace: default
  6. spec:
  7. containers:
  8. - name: cpu-demo-ctr
  9. image: vish/stress
  10. resources:
  11. limits:
  12. cpu: "2"
  13. requests:
  14. cpu: "0.5"
  15. args: ["--cpus", "1", "--mem-total", "350Mi", "--mem-alloc-size", "100Mi", "--mem-alloc-sleep", "1s"]
  16. #- -cpus
  17. #- "2"
  18. #- -mem-total
  19. #- "350Mi"
  20. #- -mem-alloc-size
  21. #- "100Mi"
  22. #- -mem-alloc-sleep
  23. #- "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 ?

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: cpu-demo
  5. namespace: default
  6. spec:
  7. containers:
  8. - name: cpu-demo-ctr
  9. image: vish/stress
  10. resources:
  11. limits:
  12. cpu: "2"
  13. requests:
  14. cpu: "0.5"
  15. 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

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training