4 Tools that Make it Easy to manage your Kubernetes Cluster

Ian Kiprotich
12 min readApr 6, 2023

--

As a seasoned Kubernetes practitioner, I’ve had the opportunity to work with a variety of tools that have made managing clusters a breeze. In this blog post, I’m excited to share with you some of my favorite tools and how they’ve helped me streamline cluster management. Whether you’re a seasoned pro or just starting out, these tools are sure to make your life easier. So without further ado, let’s dive in and explore the wonderful world of Kubernetes tools!

K8sgpt

K8sGPT is an incredible tool that gives Kubernetes SREs superpowers. It provides a simple and efficient way to scan your Kubernetes clusters and diagnose issues in plain English. The tool is designed to have SRE experience codified into its analyzers, which helps to pull out the most relevant information and enrich it with AI.

Have you ever tried chatting with ChatGPT and been impressed by its amazing responses? Well, K8sGPT brings you ChatGPT for your K8s platform. It enables you to analyze issues in the cluster and report them back with suggestions to fix the issue. I used this tool to quickly check for K3s cluster, and it works nicely even in the first release.

Installing K8sGPT is straightforward and easy. You can do this by running the brew command, and you can check the official repository to find the necessary commands for your platform.

With K8sGPT, you get access to a tool that is built to simplify the Kubernetes management process. Its SRE experience and AI enrichment help users to quickly diagnose and troubleshoot issues within their Kubernetes clusters. Give it a try, and see the difference it can make in managing your K8s platform.

Installing K8sgpt

Installing K8sgpt can be done in various ways, but one simple method is by running the brew command. You can refer to the official repository for the relevant commands specific to your platform.

brew tap k8sgpt-ai/k8sgpt
brew install k8sgpt

Quick Start

Are you ready to get started with k8sgpt and analyze your Kubernetes configurations? Follow these simple steps to quickly get up and running:

  1. Generate an API key from OpenAI by running the command k8sgpt generate. This will open a link in your browser to generate the API key. Currently the default AI provider is OpenAI but in future you can change to Bard or any other AI
  2. Once you have generated the API key, run k8sgpt auth to set it in k8sgpt. You can also provide the API key directly using the --password flag.
  3. If you want to manage the active filters used by the analyzer, run k8sgpt filters. By default, all filters are executed during analysis.
  4. Run k8sgpt analyze to start the scan. This will analyze your Kubernetes configurations and provide a summary of any issues found.
  5. To get a more detailed explanation of the issues, use the --explain flag with the k8sgpt analyze command.

That’s it! With these simple steps, you can quickly start using k8sgpt to analyze your Kubernetes configurations and ensure that your clusters are secure and well-optimized.

We can run the following and be able to view the file as a json so that we can understand more. In future release we will see this information sent to your slack channel where you can automatically get notifications and make it easy to debug your cluster.

K8sgpt analyze -o json - explain - filter=Pod | jq .

K8sGPT comes equipped with analyzers to help you detect and troubleshoot issues in your Kubernetes cluster. These analyzers are included in the platform by default, and some of them are even enabled automatically. The built-in analyzers consist of podAnalyzer, pvcAnalyzer, rsAnalyzer, serviceAnalyzer, eventAnalyzer, and ingressAnalyzer. However, you also have the option of adding optional analyzers such as hpaAnalyzer and pdbAnalyzer. Plus, you can even create your own analyzers to suit your specific needs. With K8sGPT’s comprehensive set of analyzers, you can ensure that your cluster is always running smoothly and efficiently.

Usage:
k8sgpt [command]

Available Commands:
analyze This command will find problems within your Kubernetes cluster
auth Authenticate with your chosen backend
completion Generate the autocompletion script for the specified shell
filters Manage filters for analyzing Kubernetes resources
generate Generate Key for your chosen backend (opens browser)
help Help about any command
version Print the version number of k8sgpt

Flags:
--config string config file (default is $HOME/.k8sgpt.git.yaml)
-h, --help help for k8sgpt
--kubeconfig string Path to a kubeconfig. Only required if out-of-cluster.
--master string The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
-t, --toggle Help message for toggle

Use "k8sgpt [command] --help" for more information about a command.

In K8sGPT, filters are used to manage which resources to analyze. You can list the available filters by running the command k8sgpt filters list. The default filters are already enabled, but you can add or remove filters as needed. To add filters, run k8sgpt filters add followed by the filter(s) you want to add. You can add multiple filters by separating them with commas. To remove filters, run k8sgpt filters remove followed by the filter(s) you want to remove.

k8sgpt filters list

To add a single filter:

k8sgpt filters add Service

To add multiple filters:

k8sgpt filters add Ingress,Pod

To remove a single filter:

k8sgpt filters remove Service

To remove multiple filters:

k8sgpt filters remove Ingress,Pod

To run a scan with the default analyzers and get a detailed explanation of the issues:

k8sgpt generate
k8sgpt auth
k8sgpt analyze --explain

To filter the results by a specific resource, e.g. “Service”:

k8sgpt analyze --explain --filter=Service

To filter the results by a specific namespace, e.g. “default”:

k8sgpt analyze --explain --filter=Pod --namespace=default

To output the results in JSON format:

k8sgpt analyze --explain --filter=Service --output=json

Play around with the new kind and get to see her powers

K9s

K9s is a CLI tool that makes managing your Kubernetes cluster much easier. Here are some of its top features:

  • Real-time tracking of activities and metrics associated with resources running in your cluster
  • Handles both Kubernetes standard resources and custom resource definitions (CRD)
  • Provides standard cluster management commands like logs, scaling, port-forwards, and restarts, along with the ability to create custom command shortcuts via aliases and hotkeys
  • Plugin support to extend K9s for creating your own cluster commands
  • Powerful filtering mode to drill down and view workload-related resources
  • Error zoom feature allows you to quickly drill down to what’s wrong with your cluster’s resources
  • Skinnable and customizable interface with the ability to customize or arrange columns to display on a per-resource basis
  • Provides toggles to view minimal or full resource definitions
  • Provides an overview of your cluster resources via Pulses and XRay views
  • Supports viewing RBAC rules such as cluster/roles and their associated bindings, with reverse lookup to assert what a user/group or ServiceAccount can do on your clusters
  • Built-in benchmarking allows you to benchmark your HTTP services/pods directly from K9s to adjust your resources request/limit accordingly
  • Easy traversal of Kubernetes resources and their associated resources via resource graph traversals

With all these features, K9s simplifies Kubernetes cluster management, making it easier to monitor and control resources in real-time, while providing powerful filtering and traversal capabilities. Give K9s a try and see how it can enhance your Kubernetes cluster management experience.

Installing K9s

There are many ways to install K9s and but you can easily do that by running the brew command. You can check the official repo to find the necessary commands for your platform.

brew install derailed/k9s/k9s

After running the command it will install the necessary K9s binaries and the CLI and we can now use the CLI.

The k9s CLI

The following list are some of the CLI list that we can use to manage our cluster.

# List all available CLI options
k9s help
# To get info about K9s runtime (logs, configs, etc..)
k9s info
# To run K9s in a given namespace
k9s -n mycoolns
# Start K9s in an existing KubeConfig context
k9s --context coolCtx
# Start K9s in readonly mode - with all cluster modification commands disabled
k9s --readonly

To navigate more you can use the following.

  • K9s uses aliases to navigate most K8s resources
  • To show active keyboard mnemonics and help, type “?”
  • To show all available resource alias, press ctrl-a
  • To bail out of K9s, type :q or ctrl-c
  • To view a Kubernetes resource using singular/plural or short-name, type :po
  • To filter out a resource view given a filter, type /filter
  • To inverse regex filter, type /! filter
  • To filter resource view by labels, type /-l label-selector
  • To fuzzy find a resource given a filter, type /-f filter
  • To view and switch to another Kubernetes context, type :ctx context-name
  • To view and switch to another Kubernetes namespace, type :ns
  • To view all saved resources, type :screendump or sd
  • To delete a resource, use ctrl-d and confirm with ENTER
  • To kill a resource without confirmation dialog, use ctrl-k
  • To launch pulses view, type :pulses or pu
  • To launch XRay view, type :xray RESOURCE [NAMESPACE]
  • To launch Popeye view, type :popeye or pop

Screenshots

Pods

Logs

Lens

Lens is an Integrated Development Environment (IDE) that simplifies Kubernetes cluster management on Mac, Windows, and Linux platforms. Its feature-rich and intuitive graphic interface allows users to deploy and manage clusters directly from the console while providing key metrics and insights into everything running in the cluster.

What sets Lens apart from other Kubernetes IDEs is its popularity and unique features. With over 5 million downloads, Lens offers a clear view of how clusters and cloud-native software stacks work, making it easier for beginners and more experienced users to be productive.

Lens is also built on open source with over 19k stars on GitHub and is supported by Kubernetes and cloud-native ecosystem pioneers. It is the largest and most advanced Kubernetes platform in the world, enabling tens-of-thousands of businesses and hundreds of thousands of users to develop and operate their cloud-native workloads.

In summary, Lens simplifies Kubernetes cluster management, offers unique features that set it apart from other Kubernetes IDEs, and is backed by a strong open-source community.

Here are some key differentiators that set Lens apart:

  1. Multi-Cluster Management: Lens allows you to manage multiple Kubernetes clusters from a single interface, which is especially helpful for larger organizations with many clusters. This feature makes it easier to deploy and manage workloads across different clusters, without having to switch between different tools.
  2. Rich and Intuitive UI: Lens has a feature-rich and intuitive user interface that allows users to visualize and manage all aspects of their clusters from a central location. It provides a simple and straightforward way to monitor and manage deployments, configurations, networking, storage, access control, and even custom resources.
  3. Community-Driven Development: Lens is an open-source platform built by a community of developers, which means that it benefits from the collective knowledge and expertise of its users. This approach allows for faster development, improved features, and better support for the latest Kubernetes releases.
  4. Extensibility: Lens has a plugin system that allows users to extend the platform with custom features and integrations. This means that you can tailor the platform to your specific needs and use cases, making it even more valuable for your organization.
  5. Security: Lens takes security seriously, with built-in features like RBAC, TLS encryption, and access control policies. This ensures that your Kubernetes clusters are secure and protected from unauthorized access or attacks.

These key differentiators are what make Lens stand out from other Kubernetes IDEs and management tools.

Features of Lens

  1. Instant Situational Awareness in Context: Lens offers an integrated context-aware terminal, built-in Prometheus metrics, and comprehensive logging to provide real-time situational awareness. With these features, users can quickly navigate through all the layers in a stack, access performance data, and resolve issues efficiently.
  2. Multiple Workspaces: Lens Workspaces simplifies the experience of working with multiple clusters by enabling users to organize clusters into logical groups. Each workspace includes a list of clusters and their full configuration, allowing users to effectively access, manage, or remove a group of clusters as needed.
  3. Multi-Cluster Management on Any Cloud: Lens provides access to work with multiple Kubernetes clusters on any cloud, including clusters on minikube, Docker Desktop, Docker Enterprise, EKS, AKS, GKE, Rancher, or Red Hat OpenShift. Users can add clusters by importing the kubeconfig file with the cluster details directly into the application.
  4. Context-Aware Terminal: Lens features a built-in terminal that uses a version of kubectl that is always API-compatible with the chosen cluster. The terminal automatically downloads and assigns the correct kubectl version in the background and maintains the correct version and context while switching between clusters.
  5. Built-In Prometheus Stats: Lens comes with a built-in, multi-user Prometheus setup that provides real-time graphs and resource utilization charts integrated directly into the dashboard with role-based access control (RBAC) for each user. Users can only work with visualizations for the namespaces and resources they have permission to access.
  6. Helm Charts Management: With the built-in Helm integration, users can quickly browse, modify configuration settings, deploy, and manage thousands of publicly available Helm charts with single-click upgrades. Helm is the package manager for Kubernetes, and the majority of Kubernetes workloads and services are deployed as Helm charts.

To get started with Lens, you can visit their official website and download the appropriate package for your operating system. Once you have downloaded and installed the package, you will need to register for a Lens ID to start using the application. This Lens ID will provide you with access to all the features and functionalities of the tool, and will enable you to manage and monitor your Kubernetes clusters with ease.

Screenshot

Creating a cluster or Browsing the cluster
View your cluster and all that is running
Dashboard view to view different components

Rancher

Rancher is a comprehensive software stack designed to help teams who have adopted containers. This platform addresses the complex operational and security challenges of managing multiple Kubernetes clusters and provides integrated tools for running containerized workloads.

With Rancher, DevOps teams can easily manage and deploy their Kubernetes clusters from a centralized location, reducing the complexity of their container management.

Rancher Products

Rancher Manager, for instance, provides centralized authentication, role-based access control, and management capabilities for all of your Kubernetes clusters, no matter where they are.

Harvester, an open-source hyper-converged infrastructure software built on Kubernetes, simplifies deployment of virtual machines on top of Kubernetes clusters.

NeuVector is a Kubernetes-native container security platform that delivers complete container security,

K3s, a lightweight Kubernetes distribution, is easy to use and ideal for IoT and edge devices.

RKE1 is a fast and straightforward Kubernetes installer that works seamlessly on any infrastructure

RKE2 is designed for government compliance-based use cases.

Rancher Projects to manage your Cluster

Kubewarden, for instance, is a Kubernetes dynamic admission controller that validates incoming requests using policies written in WebAssembly,

Epinio is designed to help developers and operators work together to deploy applications on Kubernetes clusters.

Opni, on the other hand, is a multi-cluster, multi-tenant observability platform with AIOps,

Longhorn is a lightweight, reliable, and powerful distributed block storage system for Kubernetes.

Overall, Rancher provides DevOps teams with a one-stop-shop for managing and deploying their Kubernetes clusters, making container management easier and more streamlined. With its many products and projects, Rancher has everything teams need to tackle even the most complex container management challenges.

Screenshots

In conclusion, managing a Kubernetes cluster can be a daunting task, but with the right tools and approaches, it can be an enjoyable experience. In this blog post, we have explored some of the best tools available for managing Kubernetes clusters, including kubectl, k9s, k8sgpt, and Rancher. Each tool has unique features and capabilities that can simplify cluster management, improve efficiency, and enhance security. We encourage you to explore these tools and use them to manage your Kubernetes clusters effectively. By doing so, you’ll be able to streamline your operations, minimize errors, and ensure that your clusters are running smoothly.

In another blog i have talked about how to get started with rancher how to install it and many more topics about Rancher

Great news! You don’t have to stop here. Keep the momentum going by following me on Twitter and LinkedIn for exciting insights on a wide range of topics. Follow as i Share my journey in the Kubernetes field . If you have any questions or want to connect further, don’t hesitate to reach out to me at onai.rotich@gmail.com. I’m always happy to help you grow and learn!

--

--