What is the main problem in the YAML file?

5/9/2019

When I want to run the following YAML file, I get the following error:

error: error parsing pod2.yaml: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context

---
apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
name: wp
    image: wordpress
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
-- HamiBU
kubernetes

1 Answer

5/9/2019

You need to fix indentation and also containers is a list:

---
apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
  - name: wp
    image: wordpress
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
-- Vasily Angapov
Source: StackOverflow