> For the complete documentation index, see [llms.txt](https://docs.openg2p.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openg2p.org/operations/deployment/deployment-guide/adding-and-removing-nodes-in-cluster.md).

# Adding and Removing Nodes in Cluster

## Adding Nodes to Cluster

Below are the steps to add new nodes to an existing Kubernetes cluster.

* From [kubernetes/rke2](https://github.com/OpenG2P/openg2p-deployment/tree/main/kubernetes/rke2) directory, use the `rke2-server.conf.subsequent.template` or `rke2-agent.conf.template` based on whether the new node is control plane node or worker node. Copy this file to `/etc/rancher/rke2/config.yaml` in the new node.
* Configure the config.yaml with relevant values.
* Run the following to set the RKE2 version. Make sure this version is the same across all the nodes. (Refer to [RKE2 Releases](https://github.com/rancher/rke2/releases). Use `rke2 --version` on an existing node to get the version.)

  <a class="button secondary">Copy</a>

  ```
  export INSTALL_RKE2_VERSION="v1.28.9+rke2r1"
  ```
* Run the below command to download RKE2.

  <a class="button secondary">Copy</a>

  ```
  curl -sfL https://get.rke2.io | sh -
  ```
* Run the below commands to start RKE2 node.

  <a class="button secondary">Copy</a>

  ```
  systemctl enable rke2-server
  systemctl start rke2-server
  ```

## Deleting Nodes from Cluster

Follow the steps below to remove a node from the Kubernetes cluster.

* Before you delete the node, make sure the **PodDisruptionBudget** is set to "**0**" on deleting node. Click [here](https://kubernetes.io/docs/tasks/run-application/configure-pdb/) for more information.
* To drain the node from the cluster, run the command below.

  <a class="button secondary">Copy</a>

  ```
  kubectl drain <nodename> --ignore-daemonsets --delete-emptydir-data
  ```
* Once done draining the node, run the command below to delete it from the cluster.

  <a class="button secondary">Copy</a>

  ```
  kubectl delete node <nodename>
  ```
* After deleting the node, check your Kubernetes cluster to ensure the node has been deleted.
* Make sure the node IP is removed from the LoadBalancer/NGINX to avoid intermittent issues in the environment.

[<br>](https://docs.openg2p.org/1.3/deployment/base-infrastructure/openg2p-cluster/cluster-setup/adding-nodes-to-cluster)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.openg2p.org/operations/deployment/deployment-guide/adding-and-removing-nodes-in-cluster.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
