I am new to kubernetes I am writing a yml file to create a deployment. I am crating deployment by running this command "kubectl create -f backend-deployment.yml" but I keep getting this error: "error: error parsing backend-deployment.yml: error converting YAML to JSON: yaml: line 16: did not find expected '-' indicator"
line 16 is - name: django-react-ecommerce-master_backend_1
following is my backend-deployment.yml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name : backend-deployment
spec:
replicas: 1
selector:
matchLabels:
component: backend
template:
metadata:
labels:
component: backend
spec:
containers:
- name: django-react-ecommerce-master_backend_1
ports:
- containerPort: 8000
The hyphen should have no indentation:
spec:
containers:
- name: django-react-ecommerce-master_backend_1
ports:
- containerPort: 8000
The problem comes from the line below, you have an indentation problem there. ports
should be at the same level than name
.
# indent the port bloc
spec:
containers:
- name: django-react-ecommerce-master_backend_1
ports:
- containerPort: 8000