Working with the Civo CLI
How to Create a Kubernetes Cluster using Civo CLI
With Civo Academy, learn how to install, access and use the Civo CLI to create a Kubernetes cluster.
You can also use the Civo CLI to create your Civo Kubernetes cluster. It's available across various operating systems because you can find the latest release in the GitHub repository, which is open source. If you're using Homebrew on Mac OS, you can install it as follows, as we'll be doing now.
Installing the Civo CLI
You can use the command
brew tap civo/tools; brew install civo to install. If you run this command and you don't have the Civo CLI already installed, it will install it for you. You can also use curl. You can use the
curl -sL https://civo.com/get | sh command. This will also install the latest release, which will fetch from GitHub. To check if it's already installed, write civo, and you will get all the information.
All the available commands and everything will be mentioned.
Accessing your account using Civo CLI
The next thing you need to do is make sure that you have access to your account using this CLI. To do that, you have to set an API key. Now, your Civo account will already have one created for you if you already have a Civo account. You can find that under "civo.com/api#authentication". If you go over there, there'll be an authentication section with your Civo API key.
You just run the command called “civo apikey add” to add that key. Then you have to add the name followed by the key and run it. For example, you can write the command as
civo apikey add Demo_Test_Key, and then you just add this particular key. Next, you need to set this as your current key. For example, if you had Demo_Test_Key created previously, you can run the
civo apikey current Demo_Test_Key '' command to set it as your default key.
Creating Kubernetes cluster using Civo CLI
Now the next step is to create a Kubernetes cluster using Civo. For that, I can write the command
civo kubernetes create academy_kunal. I can provide the size by mentioning the size as g3.k3s.medium. Also, I can provide the nodes.
Initially, I will take two nodes and also some other flags. Hence, the complete command will be
civo kubernetes create academy_kunal -size=g3.k3s.medium -nodes=2 -wait. Now, if you want to learn more and list all the command options for cluster creation, you can do that via this particular command,
civo kubernetes help create. With this, you can get all the specific commands for creating a Kubernetes cluster using the Civo CLI.
It is creating a cluster right now, and it will take around one minute. But if you want to view the cluster information already, there is a particular command for that. As you can see, I have a few clusters being created already. Hence, I will run the command
civo kubernetes show kube_academy_kunal. Now, you can see it has all the particular information about my Kubernetes cluster over here. For example, it has the region as London, the name, ID, nodes, size, status, API endpoints, and external API. All these things are available over here.
Exploring other commands and Deleting the cluster
One last thing, you can also use all the other commands that were available over there to scale up your cluster, or if you want to add some applications from the Civo marketplace as such. To get a list of all the available applications, run the
civo kubernetes applications list command. We're adding more and more via the community demands because the Civo marketplace is open-sourced. Moreover, you can see our cluster was created in under two minutes, approximately one minute and 45 seconds, which is very fast. You can now explore, scale your cluster, recycle the nodes, and delete your cluster. For example, if I run the command
civo kubernetes remove kube_academy_kunal, it will delete my Kubernetes cluster. When prompted, click yes, and you can see that it has been deleted. Thanks a lot for watching.