'error parsing loadbalancer.yaml: error converting YAML to JSON: yaml: line 4: found character that cannot start any token
I ran this yaml file using kubectl apply -f loadbalancer.yaml command, but got "error parsing loadbalancer.yaml: error converting YAML to JSON: yaml: line 4: found character that cannot start any token" error. Does anyone know why? FYI For indentations, I used spaces not tabs. Thanks ahead!
apiVersion: v1
kind: Service
metadata:
name: lbservice
spec:
type: LoadBalancer
selector:
app: server
ports:
- name: server-port
port: 3200
targetPort: 3000
- name: client-port
port: 3300
targetPort: 3001
---
apiVersion: v1
kind: Pod
metadata:
name: server-pod
labels:
app: server
spec:
containers:
- name: server-container
image: tyunlee/infinite:v1
imagePullPolicy: Always
ports:
- containerPort: 3000
nodeSelector:
disktype: ssd
---
apiVersion: v1
kind: Pod
metadata:
name: client-pod
labels:
app: server
spec:
containers:
- name: client-container
image: tyunlee/infinite:v1
imagePullPolicy: Always
ports:
- containerPort: 3001
nodeSelector:
disktype: ssd
Solution 1:[1]
A few times ago I faced a similar issue. The solution is that you have to use spaces instead of tabs (exactly two spaces) as YAML does not allow tabs (\t).
See the discussion here, you will get better understanding.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jay Parmar |