How to fix the error in YAML file converting yaml to JSON? mapping values are not allowed in this context"
10,921
This was a weird one. Turns out your hyphens were the wrong type :) all your instances of - were actually – (see the difference? one's longer).
Here's a working file:
apiVersion: v1
kind: Service
metadata:
name: feedback
labels:
run: feedback
spec:
ports:
- port: 80
targetPort: 3000
protocol: TCP
type: NodePort
selector:
run: feedback
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: feedback
spec:
replicas: 1
template:
metadata:
labels:
run: feedback
spec:
containers:
- name: feedback
image: username/feedback
ports:
– containerPort: 8888
---
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
run: mongo
spec:
ports:
- port: 27017
targetPort: 27017
protocol: TCP
selector:
run: mongo
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mongo
spec:
template:
metadata:
labels:
run: mongo
spec:
containers:
- name: mongo
image: mongo
ports:
- containerPort: 27017
Side note: this is definitely not node.js – please tag as kubernetes
Author by
Debjani
Updated on June 18, 2022Comments
-
Debjani almost 2 years
I have been breaking my head trying to understand what the issue is, it shows the following error message:
error parsing feedback.yaml: error converting YAML to JSON: yaml: line 10: mapping values are not allowed in this context
apiVersion: v1 kind: Service metadata: name: feedback labels: run: feedback spec: ports: – port: 80 targetPort: 3000 protocol: TCP type: NodePort selector: run: feedback --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: feedback spec: replicas: 1 template: metadata: labels: run: feedback spec: containers: – name: feedback image: username/feedback ports: – containerPort: 8888 --- apiVersion: v1 kind: Service metadata: name: mongo labels: run: mongo spec: ports: – port: 27017 targetPort: 27017 protocol: TCP selector: run: mongo --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: mongo spec: template: metadata: labels: run: mongo spec: containers: – name: mongo image: mongo ports: – containerPort: 27017
I have checked it using a yaml validator and also checked the spacing, am I missing something?