In the pod creation yaml files or in the deployment yaml files in kubernetes, why Containers key has a list value - name: memory-demo-ctr
rather than we can simply provide the map value name: memory-demo-ctr
(why we're providing -
symbol)?
I tried looking at over the web but couldn't find a solution.
apiVersion: v1
kind: Pod
metadata:
name: memory-demo
namespace: mem-example
spec:
containers:
- name: memory-demo-ctr
image: polinux/stress
Pod is capable of running multiple containers. That's the reason containers
object is a list instead of map.
kind: Pod
...
spec:
containers:
- name: busybox
image: busybox:latest
- name: nginx
image: nginx:1.7.9
- name: redis
image: redis:latest
If containers
is a map object, you cannot write a configuration file to run multiple containers inside a pod. I hope this answer solved your doubt.