Kubernetes Deployment file error: Found invalid field selector for v1.PodSpec Kubernetes Deployment file error: Found invalid field selector for v1.PodSpec kubernetes kubernetes

Kubernetes Deployment file error: Found invalid field selector for v1.PodSpec


As the error message states selector is an invalid field for v1.PodSpec - so this field is not valid at .spec.template.spec.selector. I think what you are looking for is a .spec.selector.

That being said, the doc states:

If specified, .spec.selector must match .spec.template.metadata.labels, or it will be rejected by the API.

So you must add role: grid also to your metadata labels (at .spec.template.metadata.labels). Your .yaml file would look sth like that then:

apiVersion: apps/v1beta1kind: Deploymentmetadata: name: zalenium-deploymentspec: selector:  matchLabels:   app: zalenium   role: grid replicas: 1 template:  metadata:   labels:    app: zalenium    role: grid  spec:   serviceAccountName: zalenium   serviceAccount: zalenium   containers:    - name: zalenium-pod      image: dosel/zalenium      ports:      - containerPort: 4444        protocol: TCP      volumeMounts:      - name: zalenium-shared        mountPath: /tmp/mounted      - name: zalenium-videos        mountPath: /home/seluser/videos      resources:       requests:        memory: "250m"        cpu: "500m"       limits:        memory: "1Gi"   volumes:   - name: zalenium-shared     persistentVolumeClaim:      claimName: zalenium-shared-claim   - name: zalenium-videos     persistentVolumeClaim:      claimName: zalenium-videos-claim