ValidationError: missing required field "selector" in io.k8s.api.v1.DeploymentSpec

You need to fix your deployment yaml file. As you can see from your error message, the Deployment.spec.selector field can't be empty.

Update the yaml (i.e. add spec.selector) as shown in below:

  spec:
    replicas: 1
    selector:
      matchLabels:
        app.kubernetes.io/name: sawtooth-0
    template:
      metadata:
        labels:
          app.kubernetes.io/name: sawtooth-0
  • Why selector field is important?

The selector field defines how the Deployment finds which Pods to manage. In this case, you simply select a label that is defined in the Pod template (app.kubernetes.io/name: sawtooth-0). However, more sophisticated selection rules are possible, as long as the Pod template itself satisfies the rule.

  • Reference

Update:

The apiVersion for k8s service is v1:

- apiVersion: v1 # Update here
  kind: Service
  metadata:
    app.kubernetes.io/name: sawtooth-0
  spec:
    type: ClusterIP
    selector:
      app.kubernetes.io/name: sawtooth-0
    ... ... ...