kubernetes converting issue

hello guys 
 
when creating my configmap i followed the instruction to the letter and i keep getting this error 

error: error parsing pod-config.yaml: error converting YAML to JSON: yaml: line 15: did not find expected key

this is my yaml file for the pod-config.yaml 

apiVersion: v1
kind: Pod
metadata:
- name: config-test-pod
spec:
containers:
- name: test-container
image: busybox
command: [ "/bin/sh", "-C", "env" ]
env:
- name: WHAT_SCHOOL
valueFrom:
confgMapKeyRef:
name: my-map
key: school
restartPolicy: Never

guys can you please help 

thanks 

  • post-author-pic
    Will B
    10-05-2018

    I think it's a problem with your whitespace. Yaml files are very particular about indentation. Try this:

    apiVersion: v1
    kind: Pod
    metadata:
    - name: config-test-pod
    spec:
    containers:
    - name: test-container
    image: busybox
    command: [ "/bin/sh", "-C", "env" ]
    env:
    - name: WHAT_SCHOOL
    valueFrom:
    confgMapKeyRef:
    name: my-map
    key: school
    restartPolicy: Never

  • post-author-pic
    Victor C
    10-05-2018

    name in metadata should not have a hyphen.
    confgMapKeyRef is mispelled.
    restartPolicy should be in line with containers.

    apiVersion: v1
    kind: Pod
    metadata:
    name: config-test-pod
    spec:
    containers:
    - name: test-container
    image: busybox
    command: [ "/bin/sh", "-C", "env" ]
    env:
    - name: WHAT_SCHOOL
    valueFrom:
    configMapKeyRef:
    name: my-map
    key: school
    restartPolicy: Never


  • post-author-pic
    Oluwaseun A
    10-06-2018

    hello 

    same things guys 

    apiVersion: v1
    kind: Pod
    metadata:
    name: config-test-pod
    spec:
    containers:
    - name: test-container
    image: busybox
    command: [ "/bin/sh", "-C", "env" ]
    env:
    - name: WHAT_SCHOOL
    valueFrom:
    confgMapKeyRef:
    name: my-map
    key: school
    restartPolicy: Never


    same error 

    error: error parsing pod-config.yaml: error converting YAML to JSON: yaml: line 15: did not find expected key

    even with the spelling correction 

    same result 

  • post-author-pic
    Oluwaseun A
    10-06-2018

    it worked guys thanks. 

    just deleted my yaml file and copied yours into it 
    thanks again 

  • post-author-pic
    Morteza K
    10-06-2018

     @veronica

     you can use https://www.json2yaml.com to double check your yaml files.

Looking For Team Training?

Learn More