i'm doing some exercises and trying to wrap my head around how to write yaml build.
spec:
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
envFrom:
- configMapRef:
name: anotherone # the name of the config map
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
VS
containers:
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
resources: {}
env:
- name: option # name of the env variable
valueFrom:
configMapKeyRef:
name: options # name of config map
key: var5 # name of the entity in config map
So my problem here is: When do i use '-' symbol when i make a build in kubernetes ? I do understand that if i apply '-' before a string it makes it an object inside a list, but i don't understand when i need to use a list in a build in kubernetes.
the "-" symbol is because type of field is array of objects, if type of field is string then value comes after ":" symbol. When field is object there is no "-" but list of keys of that object like you see for example in valueFrom
. You will see sepcification of fields when you run kubectl explain
command, for instance:
kubectl explain pod
kubectl explain pod.spec.containers