Home > Net >  Install Kubernetes-embedded pods run only specific node
Install Kubernetes-embedded pods run only specific node

Time:01-21

I have a Kubernetes cluster, and running 3 nodes. But I want to run my app on only two nodes. So I want to ask, Can I run other pods (Kubernetes extensions) in the Kubernetes cluster only on a single node?

  1. node = Only Kubernetes pods
  2. node = my app
  3. node = my app

CodePudding user response:

Yes, you can run the application POD on only two nodes and other extension Kubernetes POD on a single node.

When you say Kubernetes extension POD by that consider some external third-party PODs like Nginx ingress controller and other not default system POD like kube-proxy, kubelet, etc those should require to run each available node.

Option 1

You can use the Node affinity to schedule PODs on specific nodes.

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/hostname
            operator: In
            values:
            - node-1
            - node-2
  containers:
  - name: with-node-affinity
    image: nginx

Option 2

You can use the taint & toleration to schedule the PODs on specific nodes.

CodePudding user response:

Certain kube-system pods like kube-proxy, the CNI pods (cilium/flannel) and other daemonSet must run on each of the worker node, you can not stop them. If that is not the case for you, a node can be taint to noSchedule using below command.

kubectl taint nodes type=<a_node_label>:NoSchedule

The further enhancement you can explore https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

  • Related