<p>I'm trying to deploy this yaml in my kubernetes cluster into one of my nodes</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment-1
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
<p>But when I try to deploy it with the command, I get this error message</p>
<pre><code>pi@k8s-master-rasp4:~ $ kubectl apply -f despliegue-nginx.yaml -l kubernetes.io/hostname=k8s-worker-1
error: no objects passed to apply

</code></pre>
<p>Anyone knows where the problem could be?</p>
<p>Thanks</p>

Ángel
<p>You are not allowed to use label selector (<code>-l</code>) with <code>kubectl apply...</code>.</p>
<p>Use <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector" rel="nofollow noreferrer">nodeSelector</a> to assign pods to specific nodes:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment-1
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeSelector:
        kubernetes.io/hostname: k8s-worker-1 # &lt;-- updated here!
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
