Sobes.tech
Middle+

What are the rules that prohibit launching a specific node in the system?

sobes.tech AI

Answer from AI

The following are the main mechanisms:

  • Taints and Tolerations (T/T):

    • Taints: Applied to nodes. They allow a node to " repel " pods that do not have the corresponding toleration.
    • Tolerations: Applied to pods. They allow a pod to be scheduled on a node with a matching taint.

    Types of Taint effects:

    • NoSchedule - the pod will not be scheduled on the node if it does not have the matching toleration.
    • PreferNoSchedule - the scheduler will try not to schedule the pod on this node but can do so if no other options are available.
    • NoExecute - the pod will not be scheduled on the node, and existing pods without the matching toleration will be evicted.
  • Node Affinity:

    • requiredDuringSchedulingIgnoredDuringExecution: The scheduler must place the pod on a node that meets the specified affinity criteria. If no suitable nodes are available, the pod remains in Pending.
    • preferredDuringSchedulingIgnoredDuringExecution: The scheduler will try to place the pod on a node that meets the affinity criteria. If no suitable nodes are available, the pod may be scheduled on other nodes.
  • Kubelet Configuration:

    You can use kubelet settings to restrict the types of pods that can run on a specific node, for example, through static pods or manifests. However, this approach is less flexible for dynamic management.

# Example Taint
apiVersion: v1
kind: Node
metadata:
  name: node1
spec:
  taints:
  - key: special
    value: true
    effect: NoSchedule
# Example Toleration
apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  tolerations:
  - key: special
    operator: Equal
    value: true
    effect: NoSchedule
  containers:
  - name: my-container
    image: nginx
# Example Node Affinity
apiVersion: v1
kind: Pod
metadata:
  name: my-pod-with-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - node1
            - node2
  containers:
  - name: my-container
    image: nginx