What is Kubernetes?
The name Kubernetes has its origins from the original Greek term for helmsman or pilot. Kubernetes, or ‘k8s’ (pronounced “Kate’s”) as it’s sometimes referred to, is an open-source software tool that was originally created by Google and is now being maintained by the Cloud Native Computing Foundation. Kubernetes is used for arranging and coordinating containers that an application needs to run into easy to handle groups.
In order to manage your Kubernetes server cluster effectively, we recommend using kubectl as the command-line tool of choice. Basically, kubectl communicates with the master node (or server) which in turn submits those commands to the worker nodes to manage the cluster.
The Kubernetes cluster consists of two basic 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. You can use kubectl to deploy, explore, review and remove Kubernetes objects (like nodes, images or containers).
Next, let’s look at setting up kubectl.
In order to set up kubectl, we will need the following:
- A working internet connection
- The cURL or wget utilities installed
- Basic knowledge of the Linux command line
On an Ubuntu 16.04 LTS server, here are the commands to use if logged in as root to install kubectl:
root@host:~# apt-get update && sudo apt-get install -y apt-transport-https root@host:~# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - touch /etc/apt/sources.list.d/kubernetes.list root@host:~# echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list root@host:~# apt-get update root@host:~# apt-get install -y kubectl root@host:~# kubectl version --client
Basic Kubectl Commands for Kubernetes
Now that we have kubectl up and running, let’s review a few of the basic commands available. Here are the five most basic commands we will be reviewing along with their fundamental definition:
- kubectl create - the create command constructs a resource from a configuration file or stdin (or standard input). A resource is defined as "something that can be “requested by”, “allocated to”, “or consumed by” a pod or container."
- kubectl get - the get command displays a table of the most relevant information about one or multiple relevant resources.
- kubectl run - the run command will kick off one or more instances of a container in the cluster.
- kubectl expose - the expose command will start to load balance inbound traffic across your running instances. This command can also create a High Availability proxy for the client to access the running containers from outside the server cluster.
- kubectl delete - the delete command removes defined resources by
- resources and names
- resources and label selector
Kubectl App Management
- kubectl edit - Alters the characteristics of a resource on a server using the default editor.
- kubectl apply - Applies a change to a resource from a file or stdin.
- kubectl label - Adds or updates a specific attribute to specifically identify an object
Working with Apps Using Kubectl
- kubectl exec - Runs a command on a container in a pod
- kubectl logs - Prints a container log
- kubectl describe - Displays the status or state of the resources.
Kubectl Cluster Management
- kubectl cluster-info - Displays information about the master and services in the cluster.
- kubectl drain - removes pods in preparation for maintenance
- kubectl certificate - Approves a CSR or certificate signing request
Kubectl Settings and Usage
- kubectl api-resources (e.g. Pods and Services) - Lists all the supported resources and their shortnames, API grouping, if namespaced, and Kind
- kubectl config - Changes or alters kubeconfig files
- kubectl version - Displays the Kubernetes version
These are just some of the basic command examples that are available for use in setting up and maintaining your Kubernetes environment.
The Most Helpful Humans In Hosting™
We pride ourselves on being The Most Helpful Humans In Hosting™! Our support staff is always available to assist with any Dedicated, Cloud, or VPS server issues 24 hours a day, 7 days a week 365 days a year.
We are available, via our ticketing systems at email@example.com, by phone (at 800-580-4986) or via a LiveChat for whatever method you prefer. We work hard for you so you can relax.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.