Install Kubectl on Ubuntu, CentOS, Amazon Linux

A kubectl is an official Kubernetes command-line tool, used to run commands on Kubernetes clusters.

As the kubectl is distributed as a standalone binary it can be easily downloaded from official sources and installed on any Linux system, including Ubuntu.

In this post I will show you how to download and install the latest stable version of the kubectl on Ubuntu, although similar steps can be performed on any Linux system including CentOS, Amazon Linux, Debian, Linux Mint, etc. (more…)

Kubectl: Get Logs From All Pods

Pod logs are a vital component of any Kubernetes cluster as they contain a detailed record of activities and events that occur inside containers.

During some maintenance or troubleshooting you might want to get logs from all Pods using a kubectl or to watch/follow them in a real-time.

This note shows how to get the logs from all the Pods using the kubectl command and how to monitor them in the real-time. (more…)

Kubectl: Dry Run – Client | Server – Command Examples

A kubectl command can be used to create, delete or updated resources on a Kubernetes cluster.

With the --dry-run=(client|server) flag, the kubectl command can be used to only preview an object, without really submitting it to the Kubernetes cluster.

The dry-run mode is useful to see what will the kubectl command do without actually changing anything.

This short note shows different examples of how to run the kubectl command in the dry-run mode. (more…)

Kubectl: Get Pod Containers

According to best practices you should always try to have one container per Pod, and this is the most common Kubernetes use case.

However, a Pod can contain multiple containers and the primary reason for this is to support helper applications that assist a primary application.

Typical examples of helper applications are data pullers, data pushers and proxies.

This short note shows how to get Pod containers using a kubectl command, and also how to get logs and log into the particular container running inside the Pod. (more…)

Kubectl: Get Events & Sort By Time

Kubernetes events are automatically created when resources have state changes, errors or other messages that should be broadcasted to the system.

These events (logs) are very helpful for debugging issues in a Kubernetes cluster.

Unfortunately, a kubectl get events command, by default, returns an unsorted list of the events that is not easy to search through.

This note shows how to get the events using the kubectl command and sort them by time. (more…)

Kubectl: Run Pod With Command & Exec Into

Unless for very specific reasons, you should never run a Pod with a long-running application on its own, but use a Deployment for this.

Nevertheless, if you want to quickly run some container image on Kubernetes resources, you can use a kubectl run command.

For example, i often need to run the Pod on a Kubernetes cluster that starts a container from a wbitt/network-multitool image for container/network testing and troubleshooting.

This note shows how to run the Pod with the kubectl run command and how to log into the running Pod and start an interactive bash or sh session using the kubectl exec command. (more…)