I'm using k8s 1.11.2 to build my service, the YAML file looks like this:
Deployment
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-test
namespace: default
labels:
- type: test
spec:
replicas: 1
selector:
matchLabels:
- type: test
template:
metadata:
labels:
- type: test
spec:
containers:
- image: nginx:1.14
name: filebeat
ports:
- containerPort: 80
Service
apiVersion: v1
kind: Service
metadata:
labels:
- type:test
spec:
type: ExternalName
externalName: my.nginx.com
externalIPs:
- 192.168.125.123
clusterIP: 10.240.20.1
ports:
- port: 80
name: tcp
selector:
- type: test
and I get this error:
error validating data: [ValidationError(Service.metadata.labels): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta.labels: got "array", expected "map", ValidationError(Service.spec.selector): invalid type for io.k8s.api.core.v1.ServiceSpec.selector: got "array", expected "map"];
I am sure the format of my YAML file is right, because I used the website http://www.yamllint.com/ to validate it.
Why am I getting this error?