Created the yaml file below and launched the kubectl command, then got the error.
Could someone lent me a couple of fresh eyes and let me kow if are indentations or something else? I have tried with different clusters and same output error.
kubectl apply -f C:\Users\jmlp1\Documents\holy-api.yaml
Error from server (BadRequest): error when creating "C:\Users\jmlp1\Documents\holy-api.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field ObjectMeta.spec.template.metadata.labels of type map[string]string
kind: Deployment
apiVersion: apps/v1
metadata:
name: holy-api
namespace: pluto
spec:
replicas: 3
selector:
matchLables:
id:holy-api
template:
metadata:
labels:
id:holy-api
spec:
containers:
- env:
- name: CACHE_KEY_1
value: "b&MTCi0=[T66RXm!jO@"
- name: CACHE_KEY_2
value: "PCAILGej5Ld@Q%{Q1=#"
- name: CACHE_KEY_3
value: "2qz-]2OJlWDSTn_;RFQ"
image: nginx:1.17.3-alpine
name: holy-api-container
volumeMounts:
- mountPath: /cache1
name: cache-volume1
- mountPath: /cache2
name: cache-volume2
- mountPath: /cache3
name: cache-volume3
volumes:
- name: cache-volume1
emptyDir: {}
- name: cache-volume2
emptyDir: {}
- name: cache-volume3
emptyDir: {}
You need a space after the colon between the label name and the label value in spec.template.metadata
:
kind: Deployment
apiVersion: apps/v1
metadata:
name: holy-api
namespace: pluto
spec:
replicas: 3
selector:
matchLables:
id: holy-api
template:
metadata:
labels:
id: holy-api
...