How to Install and Use Kubectl to Manage a VKE Cluster

Updated on 13 May, 2025
Guide
Learn how to install and use Kubectl for managing Vultr Kubernetes Engine clusters, including deployment, scaling, and resource management.
How to Install and Use Kubectl to Manage a VKE Cluster header image

kubectl, or Kube Control, is a command-line tool for interacting with Kubernetes clusters. It allows system administrators and developers to deploy, manage, and monitor applications within a Kubernetes cluster. kubectl uses the Kubernetes API to communicate with a Kubernetes cluster's control plane and perform various management actions. Using kubectl, you can create, update, and delete resources such as pods, services, and deployments through a command-line interface.

This guide explains how to install and use kubectl to manage a Vultr Kubernetes Engine (VKE) cluster.

Prerequisites

Before you begin:

Install kubectl

kubectl tool is available on major operating systems such as Windows, Linux, and macOS. In this section, you will install kubectl to connect and manage your Kubernetes clusters.

Install kubectl on Linux

kubectl is unavailable in the apt or dnf package repositories of Debian/Ubuntu and CentOS/RHEL based distributions. You can install kubectl using the snap package manager or manually add the latest binary to your system.

Install kubectl Using snap

Install the kubectl using the snap package manager on your Linux machine.

console
$ sudo snap install kubectl --classic

Install kubectl Binary

  1. To manually install kubectl, download the latest kubectl binary using the following command.

    console
    $ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    
  2. Grant execute permissions on the binary.

    console
    $ chmod +x kubectl
    
  3. To activate kubectl as a system-wide command, move the downloaded binary to the /usr/local/bin directory.

    console
    $ sudo cp kubectl /usr/local/bin/
    

Verify the kubectl Installation

When kubectl is available as a system-wide command on your management machine, verify the installed version to confirm that it works correctly.

console
$ kubectl version

You should see the client version of your kubectl installation.

Connect to a VKE Cluster Using kubectl

To connect to a VKE cluster using kubectl, download your cluster configuration file and configure kubectl to use the downloaded YAML file, as described in the steps below.

  1. Log in to the Vultr customer portal and navigate to the Kubernetes section.

    Vultr Kubernetes Cluster

  2. Find and select the Kubernetes cluster you intend to access

    Vultr Kubernetes Configuration

  3. On the cluster dashboard, click Download Configuration to download a copy of the cluster YAML file to your computer

  4. Open a new terminal session and switch to the directory where you downloaded the VKE configuration file. For example /Downloads.

    console
    $ cd ~/Downloads
    
  5. Create a .kube directory in your user home directory if it does not exist.

    console
    $ mkdir ~/.kube
    
  6. Back up the original config file

  7. Copy your downloaded VKE configuration file to the .kube directory and rename it to config.

    console
    $ cp ~/Downloads/vke.yaml ~/.kube/config
    
  8. View your VKE cluster nodes to verify that kubectl connects to the cluster correctly.

    console
    $ kubectl get nodes
    

    You should see your nodes listed in the output.

  9. Use the cluster-info parameter to display information about the Kubernetes cluster, including the endpoints of the control plane components.

    console
    $ kubectl cluster-info
    

    The above command should print detailed information about your Vultr Kubernetes Engine cluster.

Use kubectl To Manage a VKE Cluster

Using kubectl ensures that your interactions with the VKE cluster are secure, authenticated, and aligned with the best practices for Kubernetes cluster management. In this section, apply basic kubectl commands to manage your VKE cluster and carry out essential tasks like retrieving information, managing resources, scaling applications, checking resource status, and viewing the cluster logs.

Conclusion

In this guide, you have installed kubectl on your local machine and configured it to interact with the Vultr Kubernetes engine. Then, you learned how to use kubectl to manage resources, scale applications, check status, and view logs in a Kubernetes cluster. Using kubectl effectively is essential for system administrators working with the Kubernetes cluster.

Tags:

Comments

No comments yet.