kubernetes

Node deditcated only for specyfic pods


I have a cluster with a node where I only want to run specific pods. I want to make in the way, that pods without any additional configs will not be scheduled on this node. Can and how can I achieve it?


Solution

  • To restrict a node to run only specific pods, you can use taints and tolerations. Start by tainting your node to prevent all pods from scheduling on it unless they have a specific toleration. You can run a command like this command to apply the taint:

    kubectl taint nodes <node-name> dedicated=special-workloads:NoSchedule
    

    Then, in the pod spec for the pods you want to allow on this node, add a matching toleration like this:

    tolerations:
      - key: "dedicated"
        operator: "Equal"
        value: "special-workloads"
        effect: "NoSchedule"
    

    This will ensure that only pods with this toleration will be scheduled on the node, while others will automatically be kept off.

    You can learn more here, in the official K8s docs.