# Kubernetes tip 3: Pinning workloads to specific nodes

Sometimes you want a workload on a specific node pool or VM size. A simple way is to label the node and use nodeSelector in the deployment.

```bash
kubectl label nodes aks-b2suser-xxxx podtype=user
```

In the deployment yaml of the microservice add nodeSelector:

```yaml
spec:
  template:
    spec:
      nodeSelector:
        podtype: "user"
```

You can also target a specific VM size when that fits the workload better:

```yaml
spec:
  nodeSelector:
    node.kubernetes.io/instance-type: Standard_B2ms
```

It is a small detail, but it helps with workload placement, isolation, and cost control.

![Deployment yaml snippet screenshot](https://images.koorevaar.com/linkedin-import/aks-pin-workloads-to-nodes-tip-3.jpg)

---

*Co-authored with Claude.*

If this was useful, [you can buy me a coffee](https://ko-fi.com/p47k0).

New articles: [follow via RSS](https://blog.koorevaar.com/feed.xml).
