Home > front end >  How to merge mutiples nodes into a single big node in kubernetes
How to merge mutiples nodes into a single big node in kubernetes

Time:10-22

Have an application running in multithreading and requires many cores on a SINGLE instance. Just wondering how to merge mutiple pod (ie containers) into a single big node, so application can run on this big node. for example : 64 pods into a single one (ie 64 cores)

This is not for production or HA service, just computation. Application cannot be re-written.

Have this reference, a bit outdated: How to make all distributed nodes RAM available to a single node?

CodePudding user response:

First of all, running multiple pods on a single node couldn't be called "merging", assigning or scheduling are better verbs I guess.

you just need to label your node, then schedule your pods to be spawned on nodes with that label:

  1. Run: kubectl get nodes , note the node name.

  2. kubectl label nodes <node-name> bignode=yes

  3. verify your node is labelled currectly:

    kubectl get nodes --show-labels

  4. then in your pod definition, define a node selector:

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
      labels:
        env: test
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
      nodeSelector:
        bignode: yes <----------- 

More info in Kubernetes docs: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

Update: the other way is to set your CPU requests as high as you need, so kubernetes will schedule your pods with sufficient CPU cores.

it could be like:

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
      labels:
        env: test
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
    resources:
      requests:
        memory: "2048Mi"
        cpu: "60"

more info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

if your concern is only number of cpu cores, second solution is more reliable, if its important to have all pods on a single node, you can read about affinity rules too.

CodePudding user response:

You can't do this with Kubernetes alone. K8s can't merge nodes into a single computational unit.

If you have 1 node, with 60 CPU cores, you can assign 60 cores to your application.
If you have 2 nodes, with 30 CPU cores each, you can only assign 30 CPU cores for your application, on each node.

Solutions in the post you linked are the way to go in your case.

  • Related