How to Install and Configure Kubectl: A Tutorial

Reading Time: 4 minutes

What is Kubectl?

Kubectl is a command-line tool for Kubernetes. It allows us to execute Kubernetes operations via the API. We can use Kubectl to deploy apps, check logs as well as manage all the other resources of the cluster.

Kubernetes uses an HTTP-based REST API which is the actual Kubernetes user interface employed to manage it. This means that every Kubernetes operation is represented as an API endpoint and can be carried out based on an HTTP-request sent to the endpoint. 

In this article, we will review Kubectl, and outline its installation, configuration, and use. 

What is Kubernetes?

The name Kubernetes has its origins from the original Greek term for helmsman or pilot. Kubernetes, or ‘k8s’ (pronounced “Kate’s”) is an open-source software tool that was created by Google and is used for scaling, deploying and coordinating containerized applications into easy to manage groups. It supports multiple containerization technologies as well as orchestrates hardware virtualization.

To manage a Kubernetes server cluster effectively, we utilize kubectl as the command-line tool of choice. Basically, kubectl communicates with the master Kubernetes node(s) which in turn submits commands to the worker nodes to manage the cluster. A Kubernetes cluster basically consists of two types of resources.

  • Master server – a master server organizes the cluster
  • Node server – Nodes are the workers that contain and run the applications

Each node contains a Kubelet, which is the agent for managing the node and communicating with the master. We can use kubectl to deploy, explore, review and remove Kubernetes objects (like nodes, images or containers).

Initially, Kubernetes was designed and developed by Google engineers to employ and utilize containers for its workload management. Google generates more than 2 billion containers deployments a week which was provided for by their internal platform code-named Borg (the predecessor to Kubernetes). During Borg’s development, the experience gained was one of the main factors that influenced a significant part of Kubernetes current technologies. Currently, Kubernetes is maintained by the Cloud Native Computing Foundation.

How to Install Kubectl? 

The easiest way to install kubectl is to use one of the default package managers for a Linux OS. 


sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2

curl -s | sudo apt-key add -

echo "deb kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list

sudo apt-get update

sudo apt-get install -y kubectl


cat <<EOF > /etc/yum.repos.d/kubernetes.repo

yum install -y kubectl

Linux Source Installation

curl -LO "$(curl -s"

chmod +x ./kubectl

sudo mv ./kubectl /usr/local/bin/kubectl

Verify Kubectl Installation

To verify all install versions, we use the following command.

kubectl version --client

Kubectl Configuration Commands

To check the kubectl configuration (or to gain access to the cluster), a kubeconfig file is needed. This file is created automatically during the creation of the cluster via the script. By default, the cluster configuration file is located in ~/.kube/config.

We use this command to check the state of the cluster and verify that kubectl is correctly configured.

$ kubectl cluster-info

When we see a URL-output, then kubectl is configured correctly to work with the cluster.

If the output contains the following error message, then kubectl is either misconfigured or cannot connect to the cluster.  

The connection to the server <server-name:port> was refused - did you specify the right host or port?

Otherwise, when kube cluster-info command returns URL output, but we still cannot connect to the cluster, we run the following command to check whether it is appropriately configured.

$ kubectl cluster-info dump


The autofill configuration is one of the most important and convenient kubectl commands as it allows us to automatically fill in some parts of a command by simply pressing the Tab key. This feature works for subcommands, options, arguments, and more complicated entries, like resource names. This configuration works for shells like Bash and Zsh. A full tutorial on how to configure that can be found on the official web page


Beginning with version 1.12, kubectl supports plugins which let us expand its functionality. Kubectl plugins are simply executable files using a naming convention which begins with kubectl-*. For example, a plugin called hello, is named kubectl-hello. To install a kubectl plugin, we move the file to any location with our PATH variable and make it executable.  

Kubectl Command Syntax

The syntax of a kubectl commands is as follows.

$ kubectl [command] [TYPE] [NAME] [flags]
  • command – defines the operation carried out on one or more resources, e.g., create, get, or delete.
  • TYPE – characterizes the type of resource. It is case-insensitive and used in a single, plural, or as an abbreviated manner.
  • name – denotes the identity of a resource and is case-sensitive.
  • flags – A flag sets options on a command. 

Basic Kubectl Commands

There are multiple commands that can be used, but we are going to look through some basic ones to have a general understanding and see some examples. We are going to use test.yaml file noted below.

kubectl exec POD_NAME -- bash -c "date && echo 1"

kubectl exec POD_NAME -- bash -c "date && \
      echo 1 && \
      echo 2"
  • $ kubectl create -f test.yamlcreates resource from the file or input.
  • $ kubectl run test.yaml start a deployment.
  • -f – can mention resources with a file or files, e.g., f file1 -f file2.
  • $ kubectl edit -f test.yamlchange the resource thanks to the test.yaml file.
  • $ kubectl describe -f test.yamldetailed description of the state of one or several resources. 
  • $ kubectl delete -f test.yaml delete resources from the file.
  • $ kubectl logs test.yaml print logs. 
  • $ kubectl optionsA list of global parameters of the command line, applied to all commands. 


In this article, we have learned what Kubernetes and kubectl are, how to install and configure kubectl, also we have provided a quick overview of some basic kubectl commands. Kubernetes is an excellent tool with many useful features.

Get Started Today!

Contact us today at 1.800.580.4985 to speak to a knowledgeable Solutions Provider who can get you the info you need, to make an informed decision right away.

Too busy to talk? Click HERE to open a quick chat with us to find out more. Would you like the information in an email you can review at your leisure? Email us today to get solid advice on which product in our lineup would best suit your business needs.

We look forward to hearing from you!

What is a Virtual Machine? A Tutorial

Reading Time: 7 minutes
What is a Virtual Machine?

A virtual machine is a simulated computer system which runs on a physical computer. In other words, a virtual machine is a computer inside a computer. Virtual machines allocate memory, a virtual CPU, disk storage space, and a network interface. This means that we can have a Windows computer that runs multiple virtual machines composed of Ubuntu Linux, macOS, Windows 10, Solaris, and CentOS, and they will all be completely separate from our parent Windows operating system.

Continue reading “What is a Virtual Machine? A Tutorial”

Kubernetes vs. Docker Swarm: A Comparison

Reading Time: 5 minutes

In this tutorial, we will be reviewing what the fundamental similarities and distinctions are between Kubernetes and Docker Swarm. Kubernetes and Docker are two of the major players in container orchestration. Both Kubernetes and Docker Swarm continue to grow in popularity as they are increasingly used by those working with container deployment, orchestration, and management. Across all vertical markets, businesses continue to find new methods of utilization and practice with more uses constantly being discovered.

Continue reading “Kubernetes vs. Docker Swarm: A Comparison”

How Has Containerization Changed the World?

Reading Time: 5 minutes
container port stacked

The arrival of containerized software has drastically changed the landscape of web hosting, and web application provides. The simplification and speed that comes with containers make deploying services like websites so efficient that the traditional model of dedicated servers running specific web-based software is almost obsolete. This being said, there will always be a place for virtual server projects and dedicated servers handling specific tasks like HIPAA compliant hosting services.

Continue reading “How Has Containerization Changed the World?”

How to Install and Use Containerization

Reading Time: 6 minutes

What is Containerization?

Containerization is a form of virtualized operating system developed as a response to the many problems of hardware-level virtualization. Because the latter runs a full-blown guest operating system, it is very resource-intensive and incurs a significant amount of overhead, but containerization is much lighter. Since the containers share the host machine’s kernel, the resources are not wasted on running separate operating system tasks. This allows for a much quicker and lightweight deployment of applications.

Continue reading “How to Install and Use Containerization”

Docker For Beginners

Reading Time: 16 minutes

What is Docker?


Docker is a containerization software that is used for automating the deployment and management of applications within an isolated environment. This software allows us to “pack” and ship an application, along with all of its needed files, libraries, and dependencies, into a “docker container“. That container can then be easily ported to any Linux system that contain cgroups support within the kernel, and provides a container management environment. Docker is one of several containerization implementations (not to be confused with virtualization) based on this cgroups mechanisms built into the Linux kernel.

Continue reading “Docker For Beginners”

How to Install Minikube On CentOS

Reading Time: 5 minutes

What Is Minikube?

Minikube is the name of a software program written in Go, which can build a local Kubernetes cluster on a single host. It uses a meager amount of resources to run a mini Kubernetes deployment. Minikube is mainly used for testing purposes using different scenarios or versions of Kubernetes

Continue reading “How to Install Minikube On CentOS”

How to Install Docker on CentOS 8

Reading Time: 6 minutes

What is Docker?

Before we begin, let’s describe what Docker is. Docker is a set of virtualization tools that allows us to create, test, and deploy containerized applications quickly and easily on a dedicated server. It has become very popular and used almost everywhere in our daily lives. Thanks to containerization, we can quickly launch applications on different private cloud host platforms utilizing small bundles which contain all the needed packages, libraries and configuration file to run an application. These docker packages communicate via established network channels.

Docker Silhouette
Docker Silhouette
Continue reading “How to Install Docker on CentOS 8”

Vagrant: An Overview

Reading Time: 13 minutes

Setting up Development Environment with Vagrant

In this tutorial, we will demonstrate how to install Vagrant on multiple operating systems.

Continue reading “Vagrant: An Overview”

Virtualization vs. Containerization

Reading Time: 6 minutes

With the constant technological development we are witnessing in the world of hosting, it is necessary to familiarize ourselves with the terminology and meaning of the systems we are using. An important distinction that we need to make is between virtual machines and containers, as they are both widely used in the hosting industry, and yet they are often confused.

Continue reading “Virtualization vs. Containerization”