Readd a deleted node to kubernetes

8/28/2017

I'm implementing a function which can make a node offline/online from kubernetes cluster.

When I run kubectl delete node $nodename, how can I read this node to the cluster?

It's said that if use API POST /api/v1/nodes will cause the node state Not ready. Is there a way to read the deleted node to cluster?

-- bay1ts
kubernetes

3 Answers

7/23/2019

Seams that kubectl delete node only delete resource yaml file.

So for me worked out:

kubectl apply -f node.yaml

--- node.yaml ---

{
  "kind": "Node",
  "apiVersion": "v1",
  "metadata": {
    "name": "minion-0",
    "labels": {
      "name": "fixed"
    }
  }
}
-- Janis Karklins
Source: StackOverflow

8/28/2017

The way to (re)create a node depends on your cluster setup and Kubernetes version.

  • kubeadm: run kubeadm reset and kubeadm join ... again on the node (you might need to create a new token if the original one was short-lived, see the linked doc)
  • most clouds: delete the VM. It will be recreated and will rejoin the cluster
  • others: see self registration and manual registration for details.
-- Janos Lenart
Source: StackOverflow

2/9/2018

To add a previously deleted node on kubernetes > 1.8x for me it works restarting kubelet service on the node. It is registering then again in the cluster. But kubernetes has a possibility to make a node "online/offlilne":

> kubectl cordon -h 
Mark node as unschedulable.

Examples:
  # Mark node "foo" as unschedulable.
  kubectl cordon foo

Usage:
  kubectl cordon NODE [options]

and

> kubectl uncordon -h 
Mark node as schedulable.

Examples:
  # Mark node "foo" as schedulable.
  $ kubectl uncordon foo

Usage:
  kubectl uncordon NODE [options]
-- Imagho
Source: StackOverflow