Introduction

You can manage Kubernetes clusters on Civo using the Kubernetes subcommands.

List clusters

To see your created clusters, call civo kubernetes list:

$ civo kubernetes list
+--------------------------------------+----------------+--------+-------+-------+--------+
| ID                                   | Name           | Region | Nodes | Pools | Status |
+--------------------------------------+----------------+--------+-------+-------+--------+
| 5604340f-caa3-4ac1-adb7-40c863fe5639 | falling-sunset | NYC1   |     2 |     1 | ACTIVE |
+--------------------------------------+----------------+--------+-------+-------+--------+

Listing kubernetes sizes

You can list all kubernetes sizes by running civo kubernetes size.

$ civo kubernetes size
+----------------+-------------+------------+-----+-------+-----+------------+
| Name           | Description | Type       | CPU | RAM   | SSD | Selectable |
+----------------+-------------+------------+-----+-------+-----+------------+
| g3.k3s.xsmall  | Extra Small | Kubernetes |   1 |  1024 |  15 | Yes        |
| g3.k3s.small   | Small       | Kubernetes |   1 |  2048 |  15 | Yes        |
| g3.k3s.medium  | Medium      | Kubernetes |   2 |  4096 |  15 | Yes        |
| g3.k3s.large   | Large       | Kubernetes |   4 |  8192 |  15 | Yes        |
| g3.k3s.xlarge  | Extra Large | Kubernetes |   6 | 16384 |  15 | Yes        |
| g3.k3s.2xlarge | 2X Large    | Kubernetes |   8 | 32768 |  15 | Yes        |
+----------------+-------------+------------+-----+-------+-----+------------+

Create a cluster

You can create a cluster by running civo kubernetes create with a cluster name parameter, as well as any options you provide:

  -a, --applications string          optional, use names shown by running 'civo kubernetes applications ls'
  -c, --create-firewall string       optional, comma-separated list of ports to open - leave blank for default (80,443,6443) or you can use "all"
  -e, --existing-firewall string     optional, ID of existing firewall to use
  -h, --help                         help for create
  -m, --merge                        merge the config with existing kubeconfig if it already exists.
  -t, --network string               the name of the network to use in the creation (default "default")
  -n, --nodes int                    the number of nodes to create (the master also acts as a node). (default 3)
  -r, --remove-applications string   optional, remove default application names shown by running  'civo kubernetes applications ls'
      --save                         save the config
  -s, --size string                  the size of nodes to create. (default "g3.k3s.medium")
      --switch                       switch context to newly-created cluster
  -v, --version string               the k3s version to use on the cluster. Defaults to the latest. (default "latest")
  -w, --wait                         a simple flag (e.g. --wait) that will cause the CLI to spin and wait for the cluster to be ACTIVE

Note * The '--create-firewall' and '--existing-firewall' flags are mutually exclusive. You can't use them together. * The '--create-firewall' flag can accept: * an optional end port using 'startport-endport' format (e.g. 8000-8100) * an optional CIDR notation (e.g. 0.0.0.0/0) * When no CIDR notation is provided, the port will get 0.0.0.0/0 as default CIDR notation * When a CIDR notation is provided without slash notation, it will default to /32 * So the following would all be valid: * 443,80,6443:0.0.0.0/0,8080:1.2.3.4 * 443,80,6443:0.0.0.0/0,8080:1.2.3.4,8081:8.8.8.8/32,8082:1.1.1.1/24,5000-5500:1.2.3.4,6000-6500:4.4.4.4/24 * When '--create-firewall' flag is blank, your cluster will be created with the following rules: * 80:0.0.0.0/0,443:0.0.0.0/0,6443:0.0.0.0/0 * To open all ports for public access, "all" can be provided to '--create-firewall' flag (not recommended)

$ civo kubernetes create my-first-cluster
Created Kubernetes cluster my-first-cluster

Adding pools the cluster

You can add more pools to your cluster live (obviously 1 is the minimum) while the cluster is running. It takes the name of the cluster (or the ID), the parameter of --nodes which is the new number of nodes to run and --size which is the size of the pool, if --node and --size are not expecified, the default values will be used.

civo kubernetes node-pool create my-first-cluster
The pool (8064c7) was added to the cluster (my-first-cluster)

Scaling pools in the cluster

You can scale a pool in your cluster, while the cluster is running. 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. You can get the pool ID details form civo k3s show my-first-cluster

civo kubernetes node-pool scale my-first-cluster pool-id --nodes 5

Deleting pools in the cluster

You can delete a pool in your cluster. It takes the name of the cluster (or the ID) and the pool ID

civo kubernetes node-pool delete my-first-cluster pool-id

Recycling nodes in your cluster

If you need to recycle a particular node in your cluster for any reason, you can use the recycle command. This requires the name or ID of the cluster, and the name of the node you wish to recycle preceded by --node=:

$ civo k8s recycle my-first-cluster --node=k3s-my-first-cluster-5ae1561e-node-pool-a56f
The node (k3s-my-first-cluster-5ae1561e-node-pool-a56f) was recycled

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.

Viewing or Saving the cluster configuration

To output a cluster's configuration information, you can invoke civo kubernetes config cluster-name. This will output the kubeconfig file to the screen.

You can save a cluster's configuration to your local ~/.kube/config file. This requires kubectl to be installed. Usage:

civo kubernetes config my-first-cluster -s
Saved config to ~/.kube/config

If you already have a ~/.kube/config file, any cluster configuration that is saved will be overwritten unless you also pass the --merge option. If you have multiple cluster configurations, merging allows you to switch contexts at will. If you prefer to save the configuration in another place, just use the parameter --local-path or -p and the path. If you use --switch the cli will automatically change the kubernetes context to the new cluster.

civo kubernetes config my-first-cluster -s --merge
Merged with main kubernetes config: /root/.kube/config
Saved configuration to: /root/.kube/config

Access your cluster with:
kubectl config use-context my-first-cluster
kubectl get node

Renaming the cluster

Although the name isn't used anywhere except for in the list of clusters (e.g. it's not in any way written in to the cluster), if you wish to rename a cluster you can do so with:

civo kubernetes rename my-first-cluster --name="Production"
Kubernetes cluster my-first-cluster is now named Production

Starting a cluster without default applications

By default, Traefik is bundled in with k3s to act as the ingress controller. If you want to set up a cluster without traefik, you can use the remove-applications option in the creation command to start a cluster without it:

civo kubernetes create --remove-applications=Traefik --nodes=2 --wait

Removing the cluster

If you're completely finished with a cluster you can delete it with:

civo kubernetes remove my-first-cluster