Let's say you want to scale your cluster, whether as part of a script to add mode nodes based on demand, or to quickly bring the node count down. This can be done on a node pool basis. It's easy to do so from the command line in a single command. It takes the name of the cluster (or the ID), the pool ID, and --nodes which is the new number of nodes in the pool:
$ civo kubernetes node-pool scale kube_demo 5ef83b --nodes 5
Kubernetes cluster kube_demo will now have 3 nodes
By looking into the cluster status, we can see this change immediately starts building a new node, as we increased the count:
$ civo kubernetes show kube_demo
ID : 1718b50e-4e87-4488-9e28-43c9e71f3432
Name : kube_demo
# Nodes : 3
Size : g3.k3s.medium
Status : INSTANCE-CREATE
Version : 0.8.1
API Endpoint : https://91.211.152.88:6443
Nodes:
+------------------+---------------+---------------+
| Name | IP | Status |
+------------------+---------------+---------------+
| kube-master-7868 | 91.211.152.88 | ACTIVE |
| kube-node-7a70 | 91.211.152.97 | ACTIVE |
| kube-node-bc2c | | BUILD_PENDING |
+------------------+---------------+---------------+
Installed marketplace applications:
+----------------+-----------+-----------+--------------+
| Name | Version | Installed | Category |
+----------------+-----------+-----------+--------------+
| Longhorn | 0.5.0 | Yes | storage |
| Traefik | (default) | Yes | architecture |
| PostgreSQL 5GB | 11.5 | Yes | database |
+----------------+-----------+-----------+--------------+
Within seconds, your new node will also be active.
If you want to scale your cluster down, that's easy too: simply specify the number of nodes you want to scale down to, and the CLI will take care of the hard work.
Using the GUI
You can also use the dashboard to scale your nodes up or down, according to your needs with just a few simple clicks.
Click on "Scale Up/Down" :
Select the total number of nodes that you want to have. Here you can also see an estimate of the cost applicable. Click on "Scale pool":
You are done! You can remove individual nodes from the dashboard, and delete the pool as well.
Recycling Nodes
If you need to rebuild nodes for whatever reason, such as a node you can use the recycle method. This takes as arguments your cluster and the specific node you wish to recycle. Recycling a node will delete it entirely, rebuild a new node to match it, and attach that to your cluster.
$ civo kubernetes recycle kube_demo --node kube-node-2f5d
The node (kube-node-2f5d) was recycled
If you were to take a look at your cluster, you would see something like the following, showing the new node being built (excerpted from civo kubernetes show kube_demo
):
Nodes:
+------------------+----+--------+-----------+-----------+------+----------+
| Name | IP | Status | Size | Cpu Cores | Ram | SSD disk |
+------------------+----+--------+-----------+-----------+------+----------+
| kube-master-7868 | | ACTIVE | g2.medium | 2 | 4096 | 50 |
| kube-node-7a70 | | ACTIVE | g2.medium | 2 | 4096 | 50 |
| kube-node-dd79 | | BUILD | g2.medium | 2 | 4096 | 50 |
+------------------+----+--------+-----------+-----------+------+----------+
Note: When a node is recycled, it is fully deleted. The recycle command does not drain a node, it simply deletes it before building a new node and attaching it to a cluster. It is intended for scenarios where the node itself develops an issue and must be replaced with a new one.
Remember, there is contextual help for all commands that you can access by running civo kubernetes help [COMMAND]
at any time.