Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Readd a deleted node to kubernetes

Tags:

kubernetes

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?

like image 547
bay1ts Avatar asked Aug 28 '17 06:08

bay1ts


2 Answers

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.
like image 93
Janos Lenart Avatar answered Oct 23 '22 10:10

Janos Lenart


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]
like image 43
Imagho Avatar answered Oct 23 '22 09:10

Imagho