Error: error validating "fin12.yaml": error validating data: [ValidationError(Po . . .

Shivesh:
error: error validating “fin12.yaml”: error validating data: [ValidationError(Pod.spec.containers[0].env): invalid type for io.k8s.api.core.v1.Container.env: got “map”, expected “array”, ValidationError(Pod.spec.containers[0]): unknown field “initialDelaySeconds” in io.k8s.api.core.v1.Container, ValidationError(Pod.spec.containers[0]): unknown field “periodSeconds” in io.k8s.api.core.v1.Container]; if you choose to ignore these errors, turn validation off with --validate=false

R Banerjee:
Map vs Array in the manifest.yml is basically how the data structure in the manifest file begins and is defined.
• Maps are Key-Value dictionaries. Each Key has to be unique. However, you can have multiple maps, so a key can be individual in a dict but repeated in different dicts
• Arrays are basically Lists.
When we use the manifest file, for example

spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx

Above all are Maps. NOTE there is no -

Below is an example of a List

containers:
      - name: nginx
        image: nginx:1.7.9
      - name: metrics-server
        image: metrics-server:0.0.1

Since a pod can have multiple containers, therefore containers is mentioned as a LIST, and each element of the list starts with a -

In your question, it is written as invalid type for io.k8s.api.core.v1.Container.env: got "map", expected "array",
This means that you may have written

env:
  name: MESSAGE
  value: "hello world"

The above is a Map. It shows a Key value pair. There is no -, so Validation believes this is a Map
If you change it to

env:
- name: MESSAGE
  value: "hello world"

then it would resolve your issue. This is because env is an Array, it expects all elements in the array to begin with -

Shivesh:
Thanks R.Banarjee, I saved that yaml file in my notepad to check later - It is as given below -

Shivesh:
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: simple-webapp-1
spec:
containers:

  • name: simple-webapp-1
    image: kodekloud/webapp-delayed-start
    livenessProbe:
    httpGet:
    path: /live
    port: 8080
    initialDelaySeconds: 80
    periodSeconds: 1

Shivesh:
second file -
++++++++++++++
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: simple-webapp-2
spec:
containers:

  • name: simple-webapp-2
    image: kodekloud/webapp-delayed-start
    livenessProbe:
    httpGet:
    path: /ready
    port: 8080
    initialDelaySeconds: 80
    periodSeconds: 1

Shivesh:
I found the mistake by checking answers
+++++++++++++
++++++++++++
apiVersion: v1
kind: Pod
metadata:
labels:
name: simple-webapp
name: simple-webapp-1
namespace: default
spec:
containers:

  • env:
    • name: APP_START_DELAY
      value: “80”
      image: kodekloud/webapp-delayed-start
      imagePullPolicy: Always
      name: simple-webapp
      ports:
    • containerPort: 8080
      protocol: TCP
      readinessProbe:
      httpGet:
      path: /ready
      port: 8080
      livenessProbe:
      httpGet:
      path: /live
      port: 8080
      periodSeconds: 1
      initialDelaySeconds: 80
      =++++++++++++++

apiVersion: v1
kind: Pod
metadata:
labels:
name: simple-webapp
name: simple-webapp-2
namespace: default
spec:
containers:

  • env:
    • name: APP_START_DELAY
      value: “80”
      image: kodekloud/webapp-delayed-start
      imagePullPolicy: Always
      name: simple-webapp
      ports:
    • containerPort: 8080
      protocol: TCP
      readinessProbe:
      httpGet:
      path: /ready
      port: 8080
      livenessProbe:
      httpGet:
      path: /live
      port: 8080
      periodSeconds: 1
      initialDelaySeconds: 80

++++++++++++++++

Shivesh:
Thanks again as your explanation is making things clear to me !! Regards