In the modern day, tech is evolving at a rapid pace. The demands of end users are constantly changing and organizations are compelled to deliver high-quality software rapidly. As requirements keep evolving, the tools and practices of Developers and Operations teams must evolve as well. Sticking to the old tried and tested methods are reliable, but they slow down the efficiency of teams, especially as an organization scales. Developer tooling must change to ensure that processes are more efficient and software can be delivered faster.

DevOps teams are responsible for configuring and deploying applications in production environments. Many organizations prefer deploying their applications onto Kubernetes, as it offers superior scaling, self-healing, and automation capabilities. However, Kubernetes comes with a lot of challenges that can make it difficult to manage, thereby reducing deployment velocity.

In this blog, you will learn about some of the key areas where DevOps teams may run into bottlenecks while working with Kubernetes. You will also learn about an open-source tool, Kubebox, which helps DevOps teams improve operating efficiency while working with Kubernetes clusters.

Challenges while working with Kubernetes

Kubernetes has become the industry’s go-to tool for deploying container-based workloads. It is a highly distributed system with lots of moving components. To understand how Kubernetes works and all the components that act together, please check out this blog where we explain the different components of Kubernetes and how they work.

Due to the distributed nature of Kubernetes, it can become difficult to manage. Even the most experienced operator will struggle with managing a Kubernetes cluster, especially when the scale increases. Kubernetes has many different components which are all essential for running applications. Some of these components include deployments, secrets, config maps, an Ingress resource, services, etc. Whenever there is some issue with an application, it can become difficult to pinpoint which resources to look at.

Many times, you may want to check certain information within a pod and relate it with other pieces of information. For example, you can get a pod’s logs using `kubectl logs <pod-name>` and also check the resource utilization of the pods using `kubectl top`.

One of the biggest issues with this is that you lose the previous context. You would need to open separate terminal windows or tabs to run commands, leading to constant context switching between the two to get the information that you require. This constant context switching adds a cognitive load to DevOps engineers and can lead to reduced efficiency while deploying applications or debugging.

Several open-source tools help reduce a lot of the challenges mentioned above. One such project we will be looking at is Kubebox, which provides a terminal utility to better visualize and manage Kubernetes resources.

What is Kubebox?

Kubebox is an open-source project that helps gain visibility into Kubernetes clusters. It can be used as a terminal-based utility or can also be used as a Web UI. It provides real-time data about your Kubernetes clusters in an organized way that lets you relate different information. It’s designed to help Kubernetes operators monitor actions taking place in a cluster, track resource usage for pods, and quickly gain insights into the state of different components in the Kubernetes environment.

Let’s break down what’s happening in the above image:

  • Pod view: The top left menu lists all the pods in the `kube-system` namespace. 
  • Resource utilization: The top left menu shows the Network usage of the selected pod, `kube-proxy`. It can also show other resources, such as Memory, CPU, and Disk utilization.
  • Pod logs: The menu at the bottom of the image shows the logs of the selected pod.

From the above image, you can get good insights into what Kubebox can help you with. You can get detailed information about a pod, along with the logs, and resource utilization such as Memory, CPU, Network, and disk utilization. While it’s quite a simple project, it provides a great way to visualize important resources of the cluster. This is very useful when debugging applications and trying to find out how different resources co-relate to one another. 

Installing Kubebox

Let’s take a look at how you can install Kubebox and use it yourself to improve the efficiency of DevOps practices.

There are three different ways in which you can install KubeBox. We will explore all three. 

  1. Install the KubeBox binary locally
  2. Install KubeBox as a Kubernetes cluster resource
  3. Run KubeBox as an ephemeral pod.

Installing the binary locally

If you have access to the kubeconfig file of the Kubernetes cluster you wish to interact with, installing the binary locally might be a good option for you. When you install and use the binary on your local system, KubeBox will run in your terminal. KubeBox uses the cluster information present in the kubeconfig file to locate and authenticate with the Kubernetes cluster. In case you have a kubeconfig file with restricted permissions, KubeBox will have the same level of access to the cluster as provided by the cluster admin in your kubeconfig.

The KubeBox binary can be downloaded and installed with a single curl command. Depending on which Operating System you use, the binary will be different. Please select the correct binary for your system from the list below

Any Linux Distribution running on x86 Architecture

curl -Lo kubebox https://github.com/astefanutti/kubebox/releases/download/v0.10.0/kubebox-linux && chmod +x kubebox

Any Linux Distribution running on ARM architecture

curl -Lo kubebox https://github.com/astefanutti/kubebox/releases/download/v0.10.0/kubebox-linux-arm && chmod +x kubebox

MacOS/OSX

curl -Lo kubebox https://github.com/astefanutti/kubebox/releases/download/v0.10.0/kubebox-macos && chmod +x kubebox

Windows

curl -Lo kubebox.exe https://github.com/astefanutti/kubebox/releases/download/v0.10.0/kubebox-windows.exe

Once you have downloaded the binary file, you can simply run the below command in the terminal to start KubeBox. Please make sure that you are on the correct path

./kubebox

Installing KubeBox in the Kubernetes cluster

Many times, you might have multiple Kubernetes clusters, and you may want to use KubeBox to manage them. As of writing this article, KubeBox does not have support for multi-cluster management. This means you will require a KubeBox instance to run in each cluster for management.

KubeBox will be installed in the Kubernetes cluster as a pod, and it can be exposed to the outside world using a service. This makes KubeBox accessible through a web browser.

You can install KubeBox by using the below command. This will create

kubectl apply -f https://raw.github.com/astefanutti/kubebox/master/kubernetes.yaml

To access the web UI of KubeBox, you can port forward the service using the below command

kubectl port-forward svc/kubebox -n kubebox 8080:8080

You can now access the KubeBox dashboard on `localhost:8080`

Run KubeBox in an Ephemeral Pod

The last way to run KubeBox is within an ephemeral pod. This is useful when you want to check out a particular resource quickly or if you are running in a production cluster. 

Simply run the below command to spin up a temporary pod for running KubeBox When you exit the KubeBox dashboard, the pod will get deleted

kubectl run kubebox -it --rm --image=astefanutti/kubebox --restart=Never

KubeBox Best Practices

While using KubeBox, there are a few best practices to follow to ensure that you get maximum benefit while operating your Kubernetes clusters. Let’s explore some of these best practices.

Proper RBAC Configurations

KubeBox is a tool that uses your local KubeConfig file to determine the location, name, and TLS certificates for the Kubernetes cluster. When providing developers and operations teams with a KubeConfig for cluster access, provide them with the minimal required permissions to carry out their tasks. This ensures that no unwanted actions take place, and unauthorized users are not privy to sensitive data such as secrets and API keys. To set up RBAC, you can leverage Kubernetes roles and role bindings.

Setting Appropriate Resource Requests and Limits

While KubeBox can help visualize how much CPU and Memory resources are being used by a particular pod, the appropriate resource requests and limits such be set on the pod. You can use KubeBox to determine the right number of resources that should be allocated, which can help you accurately assign the required resources to the pod.

Set up cAdvisor

KubeBox uses cAdvisor to fetch the resource usage within the cluster. Without having cAdvisor installed, KubeBox will be unable to properly fetch the resource utilization of the different pods. For advanced metrics, you should install monitoring tools such as Prometheus and Grafana to visualize the metrics. 

Conclusion

Kubebox is a powerful tool for DevOps teams working with Kubernetes, that helps gain visibility into cluster resources and makes it easier to troubleshoot. As organizations scale and DevOps workloads increase, Kubebox can help manage Kubernetes resources in an efficient way and without the need for constant context-switching. By providing real-time monitoring of pod metrics, logs, and resource usage all in one terminal-based interface, Kubebox allows DevOps engineers to keep a close eye on cluster health and quickly identify issues.

Integrating tools like Kubebox into your DevOps arsenal can significantly reduce time spent on debugging and improve overall operational efficiency. With Kubebox’s ease of setup and various installation options, it’s a versatile addition for anyone aiming to enhance their Kubernetes management practices.For more information on DevOps and Cloud-based technology, refer to the CloudZenia website

Dec 31, 2024