Documentation
Welcome to the KRS documentation! This section serves as your one-stop shop for everything you need to understand and navigate the KRS platform effectively. Here, you’ll find comprehensive guides, tutorials, and explanations to help you unlock the full potential of KRS and elevate your Kubernetes cluster management experience.
We understand that documentation needs vary depending on project size and complexity. Feel free to explore the available headings below.
1 - Getting Started
Get Started with KRS
This AI-powered tool empowers you to manage your Kubernetes clusters with ease. Dive into the guide to unlock KRS’s functionalities:
- Intelligent recommendations
- Proactive problem detection
- Powerful health checks
Ready to streamline your Kubernetes experience? Let’s get going!
1.1 - Overview
An introduction to KRS
KRS is an innovative AI-powered tool designed to simplify and streamline your Kubernetes cluster management. Imagine having an intelligent co-pilot for your cluster, offering insights and functionalities to optimize performance and maintain smooth operation. That’s exactly what KRS provides.
Why Use KRS?
Effortless Optimization: KRS analyzes your Kubernetes cluster’s configuration and resource usage. Based on this intelligent assessment, it recommends the most suitable tools to address your specific needs, ensuring an optimized environment.
Proactive Problem Detection: KRS utilizes advanced language models to delve into your pod logs and events. This proactive approach empowers KRS to identify potential issues before they snowball into major problems, saving you time and frustration.
Enhanced Troubleshooting: KRS’s AI capabilities allow it to analyze issues within your cluster at a deeper level. This significantly reduces troubleshooting time and effort, allowing you to focus on other critical tasks.
Simplified Management: KRS provides a user-friendly command-line interface (CLI) that puts cluster management at your fingertips. This eliminates the need for complex configurations or extensive technical expertise.
Who should use KRS?
KRS is ideal for anyone who manages Kubernetes clusters, regardless of experience level. Whether you’re a seasoned pro or just getting started, KRS can empower you to:
Optimize your cluster’s performance and resource utilization
Proactively identify and address potential issues before they disrupt your operations
Simplify troubleshooting and reduce the time spent resolving cluster problems
Gain valuable insights into your cluster’s health and performance
What’s Next?
Let KRS become your trusted companion for optimizing and managing your Kubernetes clusters effectively!
1.2 - How It Works
How KRS works
The Kubernetes Resource Scanner (KRS) utilizes a multi-faceted approach to empower you with intelligent Kubernetes cluster management. This section delves into the core functionalities and the underlying Artificial Intelligence (AI) mechanisms that drive KRS’s effectiveness.
Comprehensive Cluster Analysis
Initial Scan:
Upon executing krs scan, KRS conducts a comprehensive scan of your Kubernetes cluster. This scan meticulously identifies the tools currently deployed within your environment, providing valuable insights into your existing infrastructure.
Deep Log and Event Analysis:
KRS transcends basic scanning by leveraging its Natural Language Processing (NLP) capabilities. It delves into pod logs and events, uncovering potential issues that traditional methods might overlook. This proactive analysis helps you stay ahead of potential problems and maintain cluster stability.
KRS Recommender System:
KRS maintains a meticulously curated database of Kubernetes tools. These tools are categorized and ranked based on various factors such as functionality, maturity, and community adoption. This ranking system ensures that KRS recommends the most relevant and effective tools for your specific needs.
Tailored Suggestions for Optimization:
Following the analysis of your cluster configuration and identified tools, KRS leverages its AI engine to recommend the most suitable tools from its database. These recommendations can address potential gaps in your existing setup or suggest more efficient alternatives to optimize your cluster’s performance.
Proactive Health Checks with Large Language Models (LLMs)
Harnessing the Power of LLMs:
KRS integrates seamlessly with cutting-edge Large Language Models (LLMs) such as OpenAI’s gpt-3 or models from Hugging Face. These AI powerhouses are trained on massive datasets of text and code, enabling them to analyze information and reason at an exceptional level.
In-Depth Pod Analysis:
When you initiate krs health and select a specific pod, KRS retrieves the associated logs and events. This data is then fed into the LLM you choose for analysis.
AI-Driven Insights and Interactive Troubleshooting:
The chosen LLM meticulously analyzes the pod’s health data, pinpointing potential problems and offering recommendations for rectification. The interactive terminal session facilitates further exploration of specific issues. You can delve deeper into the LLM’s analysis or request additional insights to expedite troubleshooting and resolution
In essence, KRS acts as your intelligent co-pilot for Kubernetes cluster management. It automates tedious tasks, proactively identifies potential problems, and empowers you to make informed decisions for a healthy and optimized cluster environment. This translates to increased efficiency, reduced downtime, and a more robust Kubernetes management experience.
1.3 - Architecture
KRS Architecture Overview
Introduction
The Kubetools Recommender System (KRS) is a tool designed to assist Kubernetes administrators in optimizing their cluster configurations by recommending suitable tools based on the existing setup. This document outlines the core components of KRS and their interactions.
System Architecture
Overview
CLI (Command-Line Interface)
- The user’s primary interaction point with the system
- Provides commands for scanning, recommending tools, performing health checks, and managing system state
- Orchestrates interactions with other components
Scanner
- Responsible for interacting with the Kubernetes API to gather information about the cluster’s resources (pods, services, deployments, etc.)
- Extracts data on deployed tools and their configurations
- Stores collected data in a structured format for subsequent processing
- Maintains a curated database of Kubernetes tools, categorized and ranked based on various criteria (e.g., functionality, popularity, maturity)
- Serves as a knowledge base for the recommender component
Recommender
- Analyzes the scanned cluster data to identify potential tool gaps
- Leverages the tool database to suggest suitable tools based on the identified gaps and ranking criteria
- Generates recommendations in a user-friendly format
Health Checker
- Provides in-depth health checks for selected pods
- Extracts pod logs and events for analysis
- Utilizes a Language Model (LLM) to process the data and identify potential issues
- Offers recommendations for resolving identified problems
Data Storage
- Manages persistent storage of tool rankings, cluster information, and other relevant data
- Employs JSON and pickle formats for efficient data handling
Data Flow
- The user initiates a scan using the CLI.
- The scanner interacts with the Kubernetes API to collect cluster data
- Collected data is stored in the data storage component
- The recommender analyzes the stored data and generates tool recommendations
- The CLI presents the recommendations to the user
- If a health check is requested, the CLI interacts with the health checker
- The health checker collects pod information, processes it using the LLM, and presents findings to the user
Deployment Architecture
KRS is designed to run as a standalone application on a machine with access to a Kubernetes cluster. It can be deployed as a containerized application or as a traditional executable.
Conclusion
KRS is a tool designed to optimize Kubernetes cluster management. It leverages a modular architecture comprising a CLI, scanner, recommender, health checker, and data storage components. By analyzing cluster data and utilizing LLM technology, KRS provides actionable insights and recommendations for tool selection and cluster health.
2 - Local Installation
Set up your own Kubernetes playground locally.
This guide empowers you to set up a complete Kubernetes development environment right on your machine! With a local Kubernetes cluster, you unlock a powerful platform for
- Effortless Experimentation: Test and deploy applications in a controlled setting, independent of external resources.
- Hands-on Learning: Gain practical experience with fundamental Kubernetes concepts like pods, deployments, and services.
- Rapid Iteration: Practice and refine your configurations without affecting production systems.
This comprehensive guide equips you with the knowledge to set up your local Kubernetes environment.
We’ll explore popular options like Kind, and Minikube, guiding you through the
installation and configuration process for each tool, and equally interacting with them via KRS.
2.1 - Manual
How to Install and Use KRS on Your Cluster
KRS empowers you to manage your Kubernetes clusters with the help of cutting-edge Artificial Intelligence. This guide equips you with everything you need to get started and unlock the potential of KRS’s intelligent recommendations, proactive problem detection, and powerful health checks.
Prerequisites
Up and Running Kubernetes Cluster: Ensure you have a Kubernetes cluster running locally (e.g., Minikube, etc) or in the cloud (e.g., Amazon EKS, Google Kubernetes Engine, etc), if on the cloud, ensure that you’ve secured a config file, before using KRS.
Python 3.6+: KRS is a Python-based tool, so make sure you have Python 3.6 or a later version installed on your system. You can check your version by running python3 –version in your terminal. If you don’t have Python installed, head over to https://www.python.org/downloads/ for installation instructions.
Basic understanding of Kubernetes concepts: Having a foundational understanding of Kubernetes concepts like pods, namespaces, and deployments will help you get the most out of KRS’s functionalities.
Installation
- Clone the Repository
git clone https://github.com/kubetoolsca/krs.git
- Change directory to the cloned repository
cd krs
- Python Package Installation
pip install krs
Initial Setup
Initialize KRS
This step initializes KRS’s services and loads the scanner.
krs init
Explore KRS Commands
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Scan Your Cluster and Explore Recommendations
This is where the real power of KRS comes in!
Scan your cluster
Execute the following command to scan your cluster and identify the tools currently in use:
krs scan
You’ll see the following results:
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+============+===============+
+-------------+--------+------------+---------------+
View recommended tools
KRS analyzes your cluster and recommends tools based on best practices and its internal ranking database. Use the following command to explore these recommendations
krs recommend
You’ll see similar results to this:
krs recommend
Our recommended tools for this deployment are:
+----------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+======================+==================+=============+===============+
| Alert and Monitoring | Recommended tool | grafana | listed |
+----------------------+------------------+-------------+---------------+
| Cluster Management | Recommended tool | rancher | unlisted |
+----------------------+------------------+-------------+---------------+
Interactive Health Check with AI
KRS leverages Large Language Models (LLMs) like OpenAI or Hugging Face to provide in-depth health checks for your pods.
Start the health check
Execute the following command to initiate an interactive terminal session:
krs health
You’ll see the following results:
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>>
Choose your LLM provider
The user is prompted to choose a model provider for the health check. The options provided are “OpenAI” and “Huggingface”. The selected option determines which LLM model will be used for the health check.
Let’s say you choose the option “1”, then it will install the necessary libraries.
Enter your OpenAI API key: open_ai_api_key
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. default
2. kube-node-lease
3. kube-public
4. kube-system
5. ns1
Which namespace do you want to check the health for? Select a namespace by entering
its number: >> 4
Specify the pod
Choose the pod you want to analyze from the listed options. KRS will then extract logs and events for the selected pod.
Which namespace do you want to check the health for? Select a namespace by entering
its number: >> 4
Pods in the namespace kube-system:
1. coredns-76f75df574-mdk6w
2. coredns-76f75df574-vg6z2
3. etcd-docker-desktop
4. kube-apiserver-docker-desktop
5. kube-controller-manager-docker-desktop
6. kube-proxy-p5hw4
7. kube-scheduler-docker-desktop
8. storage-provisioner
9. vpnkit-controller
Which pod from kube-system do you want to check the health for? Select a pod by entering its
number: >> 4
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
>>
Interact with the LLM
The LLM will analyze the extracted information and provide insights into potential issues with your pod.
You can ask clarifying questions or request further analysis within the interactive terminal.
If your pod has no errors, your output would be :
Interactive session started. Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. Therefore,
I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them
thoroughly to identify the root cause. Depending on the specific warnings or
errors, potential steps to resolve the issues could include:
1. Analyzing the specific error message to understand the problem
2. Checking Kubernetes resources (e.g., pods, deployments, configmaps)
for any misconfigurations
3. Verifying connectivity to external resources or dependencies
4. Checking for resource limitations or constraints that could be causing issues
5. Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. Using Kubernetes troubleshooting tools like kubectl logs, describe, or events
to gather more information
By following these steps and addressing any identified issues, you can resolve
warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly
monitor and maintain the Kubernetes environment to ensure smooth operation. Some best
practices for Kubernetes maintenance include:
1. Regularly updating Kubernetes components and cluster nodes to the latest stable versions
to benefit from bug fixes and security patches.
2. Implementing automated backups of critical data and configurations to
prevent data loss in case of failures.
3. Monitoring resource utilization and scaling components as needed to optimize
performance and cost efficiency.
4. Implementing security best practices, such as network policies, RBAC, and
pod security policies to protect
the cluster from unauthorized access or malicious activities.
5. Conducting regular health checks and performance tuning to identify
and address any bottlenecks or
inefficiencies in the cluster.
6. Developing a disaster recovery plan and testing it periodically to
ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security
of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and
discussed best practices for Kubernetes maintenance. If you have any more
questions or need further assistance, feel free to ask. Otherwise,
we can consider this conversation complete.
>> Wonderful. Thanks! end chat
>> You're welcome! If you have any more questions in the future,
feel free to reach out. Have a great day! Goodbye!
>> end chat
Else, your output would be:
Interactive session started. Type 'end chat' to exit from the session!
>> Warning/Error 1:
"Unable to authenticate the request" with err="[invalid bearer token,
service account token has expired]"
This indicates that there was an issue with authenticating the request due to an invalid bearer token and
an expired service account token. To resolve this issue, the bearer token needs to be updated or regenerated,
and the service account token needs to be renewed.
Warning/Error 2:
"Failed to update lease" with err="StorageError: invalid object, Code: 4, Key:
/registry/leases/kube-system/apiserver-457xdkumpkdqmkwikdt6khrbya"
This error indicates a storage error while trying to update a lease, possibly due to an invalid object
or a conflict in UIDs. To resolve this issue, the lease object needs to be checked and possibly
recreated with the correct UID.
Warning/Error 3:
"Error removing old endpoints from kubernetes service: no API server IP addresses were listed in storage,
refusing to erase all endpoints for the kubernetes Service"
This warning indicates that there were no API server IP addresses listed in storage, causing the removal
of old endpoints from the Kubernetes service to fail. To resolve this issue, the API server IP addresses
need to be correctly listed in storage.
Warning/Error 4:
"Skipping API apps/v1beta1 because it has no resources."
This warning indicates that the API version 'apps/v1beta1' is being skipped because it has no
associated resources. This might be an informational warning and may not necessarily require
immediate action, depending on the use case.
Warning/Error 5:
"watch chan error: etcdserver: mvcc: required revision has been compacted"
This error indicates a watch channel error related to the revision being compacted in etcdserver.
To resolve this issue, the etcd database revision or configuration may need to be checked and potentially adjusted.
Overall, it is important to investigate and address each warning and error to ensure the stability
and reliability of the Kubernetes cluster. If there are no concerns in the log entries provided,
the message 'Everything looks good!' can be returned.
>> can you help me in fixing this error message
>> To help you fix the error messages mentioned in the log entries, here are some steps you can take:
1. For the "Unable to authenticate the request" error:
- Generate a new bearer token and update it in the relevant configuration files.
- Renew the service account token to prevent expiration issues.
2. For the "Failed to update lease" error:
- Investigate the storage error and check for any invalid objects.
- Recreate the lease object with the correct UID if needed.
3. For the "Error removing old endpoints from Kubernetes service" error:
- Ensure that the API server IP addresses are correctly listed in the storage.
- Verify the configuration of the Kubernetes service and update it if necessary.
4. For the "watch chan error: etcdserver: mvcc: required revision has been compacted" error:
- Check the etcd server configuration and ensure that the revision is maintained correctly.
- Monitor the etcd server for any potential issues causing revision compaction.
After performing these steps, restart relevant services or components as needed to apply the changes.
Monitor the Kubernetes cluster for any further errors and ensure that the issues have been resolved successfully.
Feel free to provide more specific details or additional logs if you need further assistance with resolving the error messages.
Exit the session
Type end chat to exit the interactive health check session.
Additional Resources!
KRS Project Repository: For those interested in contributing to the project or exploring the source code, visit the project repository. (Github Repo)
2.2 - Docker Desktop
How to Setup Docker Desktop on Your system
Get started with Docker Desktop to build and run containerized applications.
To install and get started with Docker Desktop, follow these steps:
For detailed instructions and troubleshooting, refer to the official Docker documentation: Instructions on Getting Started
By following these steps, you’ll have Docker Desktop up and running on your machine, enabling you to start building and running containerized applications.
2.3 - Kind
How to Use KRS on Kind
Prerequisites
- Podman, Docker, or Virtual Box (container runtime)
- Kubectl
- go (version 1.16+)
Getting Started
Setup a Kind Kubernetes Cluster on your Local Machine
go install sigs.k8s.io/kind@v0.23.0 && kind create cluster
Setup KRS using these commands
git clone https://github.com/kubetoolsca/krs.git
cd krs
pip install .
Initialize KRS to permit it access to your cluster using the given command
krs init
Get a view of all possible actions with KRS, by running the given command
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Permit KRS to get information on the tools utilized in your cluster by running the given command
krs scan
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+===================================+===============+
| kind | 3 | Alternative Tools for Development | listed |
+-------------+--------+-----------------------------------+---------------+
| | 4 | Cluster Management | listed |
+-------------+--------+-----------------------------------+---------------+
Get recommendations on possible tools to use in your cluster by running the given command
krs recommend
krs recommend
Our recommended tools for this deployment are:
+-----------------------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+===================================+==================+=============+===============+
| Alternative Tools for Development | Recommended tool | minikube | listed |
+-----------------------------------+------------------+-------------+---------------+
| Cluster Management | Recommended tool | rancher | unlisted |
+-----------------------------------+------------------+-------------+---------------+
Check the pod and namespace status in your Kubernetes cluster, including errors
krs health
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: sk-proj-qxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxP
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **default
2. **kube-node-lease
3. **kube-public
4. **kube-system
5. **local-path-storage
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 4
Pods in the namespace kube-system:
1. **cilium-9lqbq
2. **cilium-ffpct
3. **cilium-pvknr
4. **coredns-85f59d8784-nvr2n
5. **coredns-85f59d8784-p9jcv
6. **cpc-bridge-proxy-c6xzr
7. **cpc-bridge-proxy-p7r4p
8. **cpc-bridge-proxy-tkfrd
9. **csi-do-node-hwxn7
10. **csi-do-node-q27rc
11. **csi-do-node-rn7dm
12. **do-node-agent-6t5ms
13. **do-node-agent-85r8b
14. **do-node-agent-m7bvr
15. **hubble-relay-74686df4df-856pj
16. **hubble-ui-86cc69bddc-xc745
17. **konnectivity-agent-9k8vk
18. **konnectivity-agent-h5fm2
19. **konnectivity-agent-kf4xh
20. **kube-proxy-94945
21. **kube-proxy-qgv4j
22. **kube-proxy-vztzf
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. **Therefore, I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them thoroughly to identify the root cause. **Depending on the specific warnings or errors, potential steps to resolve the issues could include:
1. **Analyzing the specific error message to understand the problem
2. **Checking Kubernetes resources (e.g., pods, deployments, configmaps) for any misconfigurations
3. **Verifying connectivity to external resources or dependencies
4. **Checking for resource limitations or constraints that could be causing issues
5. **Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. **Using Kubernetes troubleshooting tools like kubectl logs, describe, or events to gather more information
By following these steps and addressing any identified issues, you can resolve warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly monitor and maintain the Kubernetes environment to ensure smooth operation. **Some best practices for Kubernetes maintenance include:
1. **Regularly updating Kubernetes components and cluster nodes to the latest stable versions to benefit from bug fixes and security patches.
2. **Implementing automated backups of critical data and configurations to prevent data loss in case of failures.
3. **Monitoring resource utilization and scaling components as needed to optimize performance and cost efficiency.
4. **Implementing security best practices, such as network policies, RBAC, and pod security policies to protect the cluster from unauthorized access or malicious activities.
5. **Conducting regular health checks and performance tuning to identify and address any bottlenecks or inefficiencies in the cluster.
6. **Developing a disaster recovery plan and testing it periodically to ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and discussed best practices for Kubernetes maintenance. **If you have any more questions or need further assistance, feel free to ask. **Otherwise, we can consider this conversation complete.
>> Wonderful. **Thanks! end chat
>> You're welcome! If you have any more questions in the future, feel free to reach out. **Have a great day! Goodbye!
>> end chat
2.4 - Minikube
How to Use KRS on Minikube
Minikube: Your local Kubernetes playground. Quickly spin up a single-node cluster and pair it with KRS for effortless cluster optimization.
Prerequisites
- Podman, Docker, or Virtual Box (container runtime)
- Kubectl
Getting Started
Setup a MiniKube Kubernetes Cluster on your Local Machine
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
minikube start
Setup KRS using these commands
git clone https://github.com/kubetoolsca/krs.git
cd krs
pip install .
Initialize KRS to permit it access to your cluster using the given command
krs init
Get a view of all possible actions with KRS, by running the given command
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Permit KRS to get information on the tools utilized in your cluster by running the given command
krs scan
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+==================+===============+
| cilium | 1 | Network Policies | graduated |
+-------------+--------+------------------+---------------+
| hubble | 7 | Security Tools | listed |
+-------------+--------+------------------+---------------+
Get recommendations on possible tools to use in your cluster by running the given command
krs recommend
krs recommend
Our recommended tools for this deployment are:
+------------------+------------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+==================+========================+=============+===============+
| Network Policies | Already using the best | cilium | graduated |
+------------------+------------------------+-------------+---------------+
| Security Tools | Recommended tool | trivy | listed |
+------------------+------------------------+-------------+---------------+
Check the pod and namespace status in your Kubernetes cluster, including errors
krs health
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: sk-proj-qxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxP
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **default
2. **kube-node-lease
3. **kube-public
4. **kube-system
5. **portainer
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 4
Pods in the namespace kube-system:
1. **cilium-9lqbq
2. **cilium-ffpct
3. **cilium-pvknr
4. **coredns-85f59d8784-nvr2n
5. **coredns-85f59d8784-p9jcv
6. **cpc-bridge-proxy-c6xzr
7. **cpc-bridge-proxy-p7r4p
8. **cpc-bridge-proxy-tkfrd
9. **csi-do-node-hwxn7
10. **csi-do-node-q27rc
11. **csi-do-node-rn7dm
12. **do-node-agent-6t5ms
13. **do-node-agent-85r8b
14. **do-node-agent-m7bvr
15. **hubble-relay-74686df4df-856pj
16. **hubble-ui-86cc69bddc-xc745
17. **konnectivity-agent-9k8vk
18. **konnectivity-agent-h5fm2
19. **konnectivity-agent-kf4xh
20. **kube-proxy-94945
21. **kube-proxy-qgv4j
22. **kube-proxy-vztzf
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. **Therefore, I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them thoroughly to identify the root cause. **Depending on the specific warnings or errors, potential steps to resolve the issues could include:
1. **Analyzing the specific error message to understand the problem
2. **Checking Kubernetes resources (e.g., pods, deployments, configmaps) for any misconfigurations
3. **Verifying connectivity to external resources or dependencies
4. **Checking for resource limitations or constraints that could be causing issues
5. **Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. **Using Kubernetes troubleshooting tools like kubectl logs, describe, or events to gather more information
By following these steps and addressing any identified issues, you can resolve warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly monitor and maintain the Kubernetes environment to ensure smooth operation. **Some best practices for Kubernetes maintenance include:
1. **Regularly updating Kubernetes components and cluster nodes to the latest stable versions to benefit from bug fixes and security patches.
2. **Implementing automated backups of critical data and configurations to prevent data loss in case of failures.
3. **Monitoring resource utilization and scaling components as needed to optimize performance and cost efficiency.
4. **Implementing security best practices, such as network policies, RBAC, and pod security policies to protect the cluster from unauthorized access or malicious activities.
5. **Conducting regular health checks and performance tuning to identify and address any bottlenecks or inefficiencies in the cluster.
6. **Developing a disaster recovery plan and testing it periodically to ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and discussed best practices for Kubernetes maintenance. **If you have any more questions or need further assistance, feel free to ask. **Otherwise, we can consider this conversation complete.
>> Wonderful. **Thanks! end chat
>> You're welcome! If you have any more questions in the future, feel free to reach out. **Have a great day! Goodbye!
>> end chat
3 - Cloud Providers
How to interact with cloud-hosted Kubernetes clusters.
KRS works seamlessly across cloud providers (AWS, Azure, GCP, etc.). Manage your Kubernetes clusters effortlessly, regardless of your cloud choice.
3.1 - Azure EKS
How to Install KRS on AKS
Optimize your AKS cluster management with KRS. This powerful tool, installed locally on your machine, analyzes your AKS cluster to identify areas for improvement. KRS leverages AI to provide recommendations for enhancing your cluster’s efficiency and functionality.
Prerequisites:
- An Azure account
- Install Azure CLI on your laptop
Installation
Clone the repository using the command
git clone https://github.com/kubetoolsca/krs.git
Install the Krs Tool
Change directory to /krs and run the following command to install krs locally on your system:
pip install .
Check if the tool has been successfully installed using
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Once you get a list of commands you can move onto the next part.
Create an EKS cluster on your Azure account
Create an EKS Cluster
To create an EKS account, you can log into your account and search for Azure Kubernetes Service.
Once you click create, you can name your cluster, add a node pool (I used the default agent pool but you can create your own), and leave everything else to its default state. **This will help you create a cluster.
Install Azure CLI
brew update && brew install azure-cli
Log into your Azure account
Once the CLI is installed, log into your Azure account using the command:
az login
Connect to Your Cluster
Retrieve the connection command from your cluster details on the Azure portal and execute it to connect to your cluster.
Using Krs
Initialise Krs
krs init
Scan the Clusters
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+=============================+===============+
| autoscaler | 5 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
Get Recommended Tools
% krs recommend`
Our recommended tools for this deployment are:
+-----------------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+=============================+==================+=============+===============+
| Cluster with Core CLI tools | Recommended tool | k9s | unlisted |
+-----------------------------+------------------+-------------+---------------+
Installing a few tools
brew install helm
helm install kubeview kubeview
helm install kubeview kubeview
NAME: kubeview
LAST DEPLOYED: Sat Jun 29 21:44:17 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
=====================================
==== KubeView has been deployed! ====
=====================================
To get the external IP of your application, run the following:
export SERVICE_IP=$(kubectl get svc --namespace default kubeview -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace default svc -w kubeview'
Exports pod info with logs and events
krs export
Pod info with logs and events exported. **Json file saved to current directory!
```
meetsimarkaur@meetsimars-MBP krs % ls
CODE_OF_CONDUCT.md arch.png gke.md kubeview
CONTRIBUTIONS.md bhive.png krs samples
LICENSE build krs.egg-info setup.py
README.md exported_pod_info.json kubetail
Detecting and Fixing Issues with my cluster
krs health`
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries.........
openai is already installed.
Enter your OpenAI API key: sk-proj-xxxxxxx
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **default
2. **kube-node-lease
3. **kube-public
4. **kube-system
Which namespace do you want to check the health for? Select a namespace by entering its number:
>> 1
Pods in the namespace default:
1. **kubeview-64fd5d8b8c-khv8v
Which pod from default do you want to check the health for? Select a pod by entering its number:
>> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> Everything looks good!
Since the log entries provided are empty, there are no warnings or errors to analyze or address. **If there were actual log entries to review, common steps to resolve potential issues in a Kubernetes environment could include:
1. **Checking the configuration files for any errors or inconsistencies.
2. **Verifying that all necessary resources (e.g. **pods, services, deployments) are running as expected.
3. **Monitoring the cluster for any performance issues or resource constraints.
4. **Troubleshooting any networking problems that may be impacting connectivity.
5. **Updating Kubernetes components or applying patches as needed to ensure system stability and security.
6. **Checking logs of specific pods or services for more detailed error messages to pinpoint the root cause of any issues.
>> 2
>> Since the log entries are still empty, the response remains the same: Everything looks good! If you encounter any specific issues or errors in the future, feel free to provide the logs for further analysis and troubleshooting.
With KRS, you can effortlessly identify and optimize the tools within your Kubernetes clusters, whether on-premises or in the public cloud, simplifying your Kubernetes management journey.
3.2 - DigitalOcean
How to Install KRS on Digital Ocean Kubernetes Cluster
KRS is your Kubernetes sidekick, effortlessly optimizing your Digital Ocean cluster. Simply install, initialize, and scan to uncover hidden potential.
Prerequisites
- Digital Ocean Account
- Homebrew(if you’re on Mac)
Getting Started
Setup a Kubernetes Cluster on Digital Ocean
Install and Setup doctl on your Local Machine
If on Ubuntu use:
sudo snap install doctl
sudo snap connect doctl:kube-config
sudo snap connect doctl:ssh-keys :ssh-keys
sudo snap connect doctl:dot-docker
If on Mac, use:
brew install doctl
Authenticate your Digital Ocean Account
doctl auth init
Connect your Local Machine to your Digital Ocean Kubernetes Cluster
doctl kubernetes cluster kubeconfig save ea3a5a97-fdba-4455-bd81-46df80c68267
Setup KRS using these commands
git clone https://github.com/kubetoolsca/krs.git
cd krs
pip install .
Initialize KRS to permit it access to your cluster using the given command
krs init
Get a view of all possible actions with KRS, by running the given command
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Permit KRS to get information on the tools utilized in your cluster by running the given command
krs scan
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+==================+===============+
| cilium | 1 | Network Policies | graduated |
+-------------+--------+------------------+---------------+
| hubble | 7 | Security Tools | listed |
+-------------+--------+------------------+---------------+
Get recommendations on possible tools to use in your cluster by running the given command
krs recommend
krs recommend
Our recommended tools for this deployment are:
+------------------+------------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+==================+========================+=============+===============+
| Network Policies | Already using the best | cilium | graduated |
+------------------+------------------------+-------------+---------------+
| Security Tools | Recommended tool | trivy | listed |
+------------------+------------------------+-------------+---------------+
Check the pod and namespace status in your Kubernetes cluster, including errors.
krs health
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: sk-proj-qxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxP
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **default
2. **kube-node-lease
3. **kube-public
4. **kube-system
5. **portainer
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 4
Pods in the namespace kube-system:
1. **cilium-9lqbq
2. **cilium-ffpct
3. **cilium-pvknr
4. **coredns-85f59d8784-nvr2n
5. **coredns-85f59d8784-p9jcv
6. **cpc-bridge-proxy-c6xzr
7. **cpc-bridge-proxy-p7r4p
8. **cpc-bridge-proxy-tkfrd
9. **csi-do-node-hwxn7
10. **csi-do-node-q27rc
11. **csi-do-node-rn7dm
12. **do-node-agent-6t5ms
13. **do-node-agent-85r8b
14. **do-node-agent-m7bvr
15. **hubble-relay-74686df4df-856pj
16. **hubble-ui-86cc69bddc-xc745
17. **konnectivity-agent-9k8vk
18. **konnectivity-agent-h5fm2
19. **konnectivity-agent-kf4xh
20. **kube-proxy-94945
21. **kube-proxy-qgv4j
22. **kube-proxy-vztzf
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. **Therefore, I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them thoroughly to identify the root cause. **Depending on the specific warnings or errors, potential steps to resolve the issues could include:
1. **Analyzing the specific error message to understand the problem
2. **Checking Kubernetes resources (e.g., pods, deployments, configmaps) for any misconfigurations
3. **Verifying connectivity to external resources or dependencies
4. **Checking for resource limitations or constraints that could be causing issues
5. **Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. **Using Kubernetes troubleshooting tools like kubectl logs, describe, or events to gather more information
By following these steps and addressing any identified issues, you can resolve warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly monitor and maintain the Kubernetes environment to ensure smooth operation. **Some best practices for Kubernetes maintenance include:
1. **Regularly updating Kubernetes components and cluster nodes to the latest stable versions to benefit from bug fixes and security patches.
2. **Implementing automated backups of critical data and configurations to prevent data loss in case of failures.
3. **Monitoring resource utilization and scaling components as needed to optimize performance and cost efficiency.
4. **Implementing security best practices, such as network policies, RBAC, and pod security policies to protect the cluster from unauthorized access or malicious activities.
5. **Conducting regular health checks and performance tuning to identify and address any bottlenecks or inefficiencies in the cluster.
6. **Developing a disaster recovery plan and testing it periodically to ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and discussed best practices for Kubernetes maintenance. **If you have any more questions or need further assistance, feel free to ask. **Otherwise, we can consider this conversation complete.
>> Wonderful. **Thanks! end chat
>> You're welcome! If you have any more questions in the future, feel free to reach out. **Have a great day! Goodbye!
>> end chat
3.3 - AWS EKS
How to Install KRS on AWS EKS
Optimize your EKS cluster with KRS. KRS running locally on your machine, analyzes your EKS cluster for improvement. Leverage KRS to gain valuable insights and recommendations for a smoother Kubernetes experience.
Prerequisites
- AWS Account
- AWSCLI installed on your system
- Homebrew(if you’re on Mac)
Getting Started
Setup Amazon EKS Cluster
eksctl create cluster --name <cluster_name> --version <kubernetes_version> --region <aws_region_name e.g us-east-1> --nodegroup-name <linux_nodes> --node-type <node_type> --nodes <number_of_nodes> --zones=<zone_names, e.g: us-east-1a,us-east-1b>
Authenticate your AWS account
aws configure
Extract the list of running clusters on AWS using this command
aws eks list-clusters
Create a config file that permits KRS access to the EKS cluster using this command
aws eks update-kubeconfig --name <cluster_name>
Setup KRS using these commands
$git clone https://github.com/kubetoolsca/krs.git
$ cd krs
$ pip install
Initialize KRS to permit it access to your cluster using the given command
krs init
Get a view of all possible actions with KRS, by running the given command
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Permit KRS to get information on the tools utilized in your cluster by running the given command
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+=============================+===============+
| autoscaler | 5 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
| istio | 2 | Service Mesh | graduated |
+-------------+--------+-----------------------------+---------------+
| kserve | 3 | Artificial Intelligence | listed |
+-------------+--------+-----------------------------+---------------+
Get recommendations on possible tools to use in your cluster by running the given command
krs recommend
+-----------------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+=============================+==================+=============+===============+
| Cluster with Core CLI tools | Recommended tool | k9s | unlisted |
+-----------------------------+------------------+-------------+---------------+
| Service Mesh | Recommended tool | traefik | listed |
+-----------------------------+------------------+-------------+---------------+
| Artificial Intelligence | Recommended tool | k8sgpt | sandbox |
+-----------------------------+------------------+-------------+---------------+
Check the pod and namespace status in your Kubernetes cluster, including errors
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: sk-proj-xxxxxxxxxx
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **cert-manager
2. **default
3. **istio-system
4. **knative-serving
5. **kserve
6. **kserve-test
7. **kube-node-lease
8. **kube-public
9. **Kube-system
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 9
Pods in the namespace kube-system:
1. **aws-node-46hzm
2. **aws-node-wdgnn
3. **coredns-586b798467-54t6h
4. **coredns-586b798467-jmlrp
5. **kube-proxy-hfmjl
6. **kube-proxy-n8lc6
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> The provided log entries are empty, so there is nothing to analyze. **Everything looks good!
>> Wonderful, so what next
>> If you have any specific questions or another set of log entries you would like me to analyze, feel free to provide them. **I'm here to help with any DevOps or Kubernetes-related queries you may have. **Just let me know how I can assist you further!
3.4 - Google's GKE
How to Install KRS on Google Kubernetes Engine
Effortlessly optimize your GKE cluster with KRS. This powerful tool, running locally on your machine, analyzes your GKE cluster for improvement. Leverage KRS to gain valuable insights and recommendations for a smoother Kubernetes experience.
Prerequisite
- A Google Cloud Account
- Installing Google Cloud SDK on your macOS
Getting Started
Execute the following command to install Google Cloud SDK in your system
tar xfz google-cloud-sdk-195.0.0-darwin-x86_64.tar.gz
./google-cloud-sdk/install.sh
Enable Google Cloud Engine API
Authenticate Your Google Cloud using gcloud auth
gcloud init
In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud Platform resources.
Creating GKE Cluster
gcloud container clusters create k8s-lab1 --disk-size 10 --zone asia-east1-a --machine-type n1-standard-2 --num-nodes 3 --scopes compute-rw
Viewing it on Google Cloud Platform
Viewing the new context on Docker Desktop
Verifying the Google Kubernetes Cluster
kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-k8s-lab1-default-pool-5dfb7153-3fr7 Ready <none> 3m1s v1.29.4-gke.1043002
gke-k8s-lab1-default-pool-5dfb7153-nl3v Ready <none> 3m1s v1.29.4-gke.1043002
gke-k8s-lab1-default-pool-5dfb7153-rkg8 Ready <none> 3m2s v1.29.4-gke.1043002
Initialize the KRS
krs init
Services initialized and scanner loaded.
Running the scanner
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+=============================+===============+
| autoscaler | 5 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
| fluentbit | 4 | Logging and Tracing | unlisted |
+-------------+--------+-----------------------------+---------------+
Checking the Krs Recommendation
krs recommend
Our recommended tools for this deployment are:
+-----------------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+=============================+==================+=============+===============+
| Cluster with Core CLI tools | Recommended tool | k9s | unlisted |
+-----------------------------+------------------+-------------+---------------+
| Logging and Tracing | Recommended tool | elk | unlisted |
Installing Kubeview
git clone https://github.com/benc-uk/kubeview
cd kubeview/charts/
helm install kubeview kubeview
Running the scanner again
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+=============================+===============+
| kubeview | 30 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
| | 3 | Cluster Management | unlisted |
+-------------+--------+-----------------------------+---------------+
| autoscaler | 5 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
| fluentbit | 4 | Logging and Tracing | unlisted |
+-------------+--------+-----------------------------+---------------+
Discover other KRS commands
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
4 - AI Model
How to Use DIfferent AI Models with KRS
Krs’ effectiveness hinges on the AI model powering it. Explore the options available and learn how to integrate different AI models into your Krs implementation.
4.1 - OpenAI
How to use KRS with OpenAI
Leverage OpenAI’s powerful language models to enhance Krs’ problem-solving and recommendation capabilities.
Prerequisites
Up and Running Kubernetes Cluster: Ensure you have a Kubernetes cluster running locally (e.g., Minikube, etc) or in the cloud (e.g., Amazon EKS, Google Kubernetes Engine, etc), if on the cloud, ensure that you’ve secured a config file, before using KRS.
Python 3.6+: KRS is a Python-based tool, so make sure you have Python 3.6 or a later version installed on your system. You can check your version by running python3 –version in your terminal. If you don’t have Python installed, head over to https://www.python.org/downloads/ for installation instructions.
Basic understanding of Kubernetes concepts: Having a foundational understanding of Kubernetes concepts like pods, namespaces, and deployments will help you get the most out of KRS’s functionalities.
Installation
- Clone the Repository
git clone https://github.com/kubetoolsca/krs.git
- Change directory to the cloned repository
cd krs
- Python Package Installation
pip install krs
Initial Setup
Initialize KRS
This step initializes KRS’s services and loads the scanner.
krs init
Explore KRS Commands
krs --help
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Scan Your Cluster and Explore Recommendations
This is where the real power of KRS comes in!
Scan your cluster
Execute the following command to scan your cluster and identify the tools currently in use:
krs scan
You’ll see the following results:
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+============+===============+
+-------------+--------+------------+---------------+
View recommended tools
KRS analyzes your cluster and recommends tools based on best practices and its internal ranking database. Use the following command to explore these recommendations
krs recommend
You’ll see similar results to this:
krs recommend
Our recommended tools for this deployment are:
+----------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+======================+==================+=============+===============+
| Alert and Monitoring | Recommended tool | grafana | listed |
+----------------------+------------------+-------------+---------------+
| Cluster Management | Recommended tool | rancher | unlisted |
+----------------------+------------------+-------------+---------------+
Interactive Health Check with AI
KRS leverages Large Language Models (LLMs) like OpenAI or Hugging Face to provide in-depth health checks for your pods.
Start the health check
Execute the following command to initiate an interactive terminal session:
krs health
You’ll see the following results:
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>>
Choose 1 to Select OpenAI as Your LLM provider
The user is prompted to choose a model provider for the health check. Select option “1”, and all necessary libraries will be installed.
Enter your OpenAI API key: open_ai_api_key
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. default
2. kube-node-lease
3. kube-public
4. kube-system
5. ns1
Which namespace do you want to check the health for? Select a namespace by entering
its number: >> 4
Specify the pod
Choose the pod you want to analyze from the listed options. KRS will then extract logs and events for the selected pod.
Which namespace do you want to check the health for? Select a namespace by entering
its number: >> 4
Pods in the namespace kube-system:
1. coredns-76f75df574-mdk6w
2. coredns-76f75df574-vg6z2
3. etcd-docker-desktop
4. kube-apiserver-docker-desktop
5. kube-controller-manager-docker-desktop
6. kube-proxy-p5hw4
7. kube-scheduler-docker-desktop
8. storage-provisioner
9. vpnkit-controller
Which pod from kube-system do you want to check the health for? Select a pod by entering its
number: >> 4
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
>>
Interact with the LLM
The LLM will analyze the extracted information and provide insights into potential issues with your pod.
You can ask clarifying questions or request further analysis within the interactive terminal.
If your pod has no errors, your output would be :
Interactive session started. Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. Therefore,
I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them
thoroughly to identify the root cause. Depending on the specific warnings or
errors, potential steps to resolve the issues could include:
1. Analyzing the specific error message to understand the problem
2. Checking Kubernetes resources (e.g., pods, deployments, configmaps)
for any misconfigurations
3. Verifying connectivity to external resources or dependencies
4. Checking for resource limitations or constraints that could be causing issues
5. Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. Using Kubernetes troubleshooting tools like kubectl logs, describe, or events
to gather more information
By following these steps and addressing any identified issues, you can resolve
warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly
monitor and maintain the Kubernetes environment to ensure smooth operation. Some best
practices for Kubernetes maintenance include:
1. Regularly updating Kubernetes components and cluster nodes to the latest stable versions
to benefit from bug fixes and security patches.
2. Implementing automated backups of critical data and configurations to
prevent data loss in case of failures.
3. Monitoring resource utilization and scaling components as needed to optimize
performance and cost efficiency.
4. Implementing security best practices, such as network policies, RBAC, and
pod security policies to protect
the cluster from unauthorized access or malicious activities.
5. Conducting regular health checks and performance tuning to identify
and address any bottlenecks or
inefficiencies in the cluster.
6. Developing a disaster recovery plan and testing it periodically to
ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security
of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and
discussed best practices for Kubernetes maintenance. If you have any more
questions or need further assistance, feel free to ask. Otherwise,
we can consider this conversation complete.
>> Wonderful. Thanks! end chat
>> You're welcome! If you have any more questions in the future,
feel free to reach out. Have a great day! Goodbye!
>> end chat
Else, your output would be:
Interactive session started. Type 'end chat' to exit from the session!
>> Warning/Error 1:
"Unable to authenticate the request" with err="[invalid bearer token,
service account token has expired]"
This indicates that there was an issue with authenticating the request due to an invalid bearer token and
an expired service account token. To resolve this issue, the bearer token needs to be updated or regenerated,
and the service account token needs to be renewed.
Warning/Error 2:
"Failed to update lease" with err="StorageError: invalid object, Code: 4, Key:
/registry/leases/kube-system/apiserver-457xdkumpkdqmkwikdt6khrbya"
This error indicates a storage error while trying to update a lease, possibly due to an invalid object
or a conflict in UIDs. To resolve this issue, the lease object needs to be checked and possibly
recreated with the correct UID.
Warning/Error 3:
"Error removing old endpoints from kubernetes service: no API server IP addresses were listed in storage,
refusing to erase all endpoints for the kubernetes Service"
This warning indicates that there were no API server IP addresses listed in storage, causing the removal
of old endpoints from the Kubernetes service to fail. To resolve this issue, the API server IP addresses
need to be correctly listed in storage.
Warning/Error 4:
"Skipping API apps/v1beta1 because it has no resources."
This warning indicates that the API version 'apps/v1beta1' is being skipped because it has no
associated resources. This might be an informational warning and may not necessarily require
immediate action, depending on the use case.
Warning/Error 5:
"watch chan error: etcdserver: mvcc: required revision has been compacted"
This error indicates a watch channel error related to the revision being compacted in etcdserver.
To resolve this issue, the etcd database revision or configuration may need to be checked and potentially adjusted.
Overall, it is important to investigate and address each warning and error to ensure the stability
and reliability of the Kubernetes cluster. If there are no concerns in the log entries provided,
the message 'Everything looks good!' can be returned.
>> can you help me in fixing this error message
>> To help you fix the error messages mentioned in the log entries, here are some steps you can take:
1. For the "Unable to authenticate the request" error:
- Generate a new bearer token and update it in the relevant configuration files.
- Renew the service account token to prevent expiration issues.
2. For the "Failed to update lease" error:
- Investigate the storage error and check for any invalid objects.
- Recreate the lease object with the correct UID if needed.
3. For the "Error removing old endpoints from Kubernetes service" error:
- Ensure that the API server IP addresses are correctly listed in the storage.
- Verify the configuration of the Kubernetes service and update it if necessary.
4. For the "watch chan error: etcdserver: mvcc: required revision has been compacted" error:
- Check the etcd server configuration and ensure that the revision is maintained correctly.
- Monitor the etcd server for any potential issues causing revision compaction.
After performing these steps, restart relevant services or components as needed to apply the changes.
Monitor the Kubernetes cluster for any further errors and ensure that the issues have been resolved successfully.
Feel free to provide more specific details or additional logs if you need further assistance with resolving the error messages.
Exit the session
Type end chat to exit the interactive health check session.
Additional Resources!
KRS Project Repository: For those interested in contributing to the project or exploring the source code, visit the project repository. (Github Repo)
4.2 - HuggingFace
How to Install KRS on AWS EKS
Optimize your EKS cluster with KRS. KRS running locally on your machine, analyzes your EKS cluster for improvement. Leverage KRS to gain valuable insights and recommendations for a smoother Kubernetes experience.
Prerequisites
- AWS Account
- AWSCLI installed on your system
- Homebrew(if you’re on Mac)
Getting Started
Setup Amazon EKS Cluster
eksctl create cluster --name <cluster_name> --version <kubernetes_version> --region <aws_region_name e.g us-east-1> --nodegroup-name <linux_nodes> --node-type <node_type> --nodes <number_of_nodes> --zones=<zone_names, e.g: us-east-1a,us-east-1b>
Authenticate your AWS account
aws configure
Extract the list of running clusters on AWS using this command
aws eks list-clusters
Create a config file that permits KRS access to the EKS cluster using this command
aws eks update-kubeconfig --name <cluster_name>
Setup KRS using these commands
$git clone https://github.com/kubetoolsca/krs.git
$ cd krs
$ pip install
Initialize KRS to permit it access to your cluster using the given command
krs init
Get a view of all possible actions with KRS, by running the given command
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]... **
krs: A command line interface to scan your Kubernetes Cluster, detect errors,
provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. ** │
│ --show-completion Show completion for the current shell, to copy │
│ it or customize the installation. ** │
│ --help Show this message and exit. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from │
│ system. **Removes all cached data. ** │
│ export Exports pod info with logs and events. ** │
│ health Starts an interactive terminal using an LLM of your choice to │
│ detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. ** │
│ namespaces Lists all the namespaces. ** │
│ pods Lists all the pods with namespaces, or lists pods under a │
│ specified namespace. ** │
│ recommend Generates a table of recommended tools from our ranking │
│ database and their CNCF project status. ** │
│ scan Scans the cluster and extracts a list of tools that are │
│ currently used. ** │
╰──────────────────────────────────────────────────────────────────────────────╯
Permit KRS to get information on the tools utilized in your cluster by running the given command
krs scan
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+-----------------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+=============================+===============+
| autoscaler | 5 | Cluster with Core CLI tools | unlisted |
+-------------+--------+-----------------------------+---------------+
| istio | 2 | Service Mesh | graduated |
+-------------+--------+-----------------------------+---------------+
| kserve | 3 | Artificial Intelligence | listed |
+-------------+--------+-----------------------------+---------------+
Get recommendations on possible tools to use in your cluster by running the given command
krs recommend
+-----------------------------+------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+=============================+==================+=============+===============+
| Cluster with Core CLI tools | Recommended tool | k9s | unlisted |
+-----------------------------+------------------+-------------+---------------+
| Service Mesh | Recommended tool | traefik | listed |
+-----------------------------+------------------+-------------+---------------+
| Artificial Intelligence | Recommended tool | k8sgpt | sandbox |
+-----------------------------+------------------+-------------+---------------+
Check the pod and namespace status in your Kubernetes cluster, including errors
krs health
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: sk-proj-xxxxxxxxxx
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. **cert-manager
2. **default
3. **istio-system
4. **knative-serving
5. **kserve
6. **kserve-test
7. **kube-node-lease
8. **kube-public
9. **Kube-system
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 9
Pods in the namespace kube-system:
1. **aws-node-46hzm
2. **aws-node-wdgnn
3. **coredns-586b798467-54t6h
4. **coredns-586b798467-jmlrp
5. **kube-proxy-hfmjl
6. **kube-proxy-n8lc6
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. **Type 'end chat' to exit from the session!
>> The provided log entries are empty, so there is nothing to analyze. **Everything looks good!
>> Wonderful, so what next
>> If you have any specific questions or another set of log entries you would like me to analyze, feel free to provide them. **I'm here to help with any DevOps or Kubernetes-related queries you may have. **Just let me know how I can assist you further!
4.3 - LocalAI
How to Use KRS with LocalAI
5 - Contribution Guidelines
How to contribute to the KRS project
Thank you for your interest in contributing to the Kubernetes Resource Scanner (KRS) tool! We welcome your contributions and are excited to help make this project better.
Code of Conduct
Before contributing, please review and adhere to the Code of Conduct. We expect all contributors to follow these guidelines to ensure a positive and inclusive environment.
Release Management and Pull Request Submission Guidelines
Repository Branch Structure
Our project employs a three-branch workflow to manage the development and release of new features and fixes:
- main: Stable release branch that contains production-ready code.
- pre-release: Staging branch for final testing before merging into main.
- release-v0.x.x: Active development branch where all new changes, bug fixes, and features are made and tested.
Contributing to the Project
To contribute to our project, follow these steps to ensure your changes are properly integrated:
Selecting the Correct Branch
- Always base your work on the latest release-vx.x.x branch. This branch will be named according to the version, for example, release-v0.1.0.
- Ensure you check the branch name in the repository for the most current version branch.
Working on Issues
- Before you start working on an issue, comment on that issue stating that you are taking it on. This helps prevent multiple contributors from working on the same issue simultaneously.
- Include the issue number in your branch name for traceability, e.g., 123-fix-login-bug.
Pull Request (PR) Process
To maintain code quality and orderly management, all contributors must follow this PR process:
Step 1: Sync Your Fork
Before starting your work, sync your fork with the upstream repository to ensure you have the latest changes from the release-v0.x.x branch:
git checkout release-vx.x.x
git pull origin release-vx.x.x
Step 2: Create a New Branch
Create a new branch from the release-vx.x.x branch for your work:
git checkout -b your-branch-name
Step 3: Make Changes and Commit
Make your changes locally and commit them with clear, concise commit messages. Your commits should reference the issue number:
git commit -m "Fix issue #123: resolve login bug"
Step 4: Push Changes
Push your branch and changes to your fork:
git push -u origin your-branch-name
Step 5: Open a Pull Request
- Go to the original repository on GitHub and open a pull request from your branch to the release-vx.x.x branch.
- Clearly describe the changes you are proposing in the PR description. Link the PR to any relevant issues.
Step 6: PR Review
- All pull requests must undergo review by at least two peers before merging.
- Address any feedback and make required updates to your PR; this may involve additional commits.
Step 7: Final Merging
- Once your PR is approved by the reviewers, one of the maintainers will merge it into the release-v0.x.x branch.
- The changes will eventually be merged into pre-release and then main as part of our release process.
Notes on Contribution
- Please make sure all tests pass before submitting a PR.
- Adhere to the coding standards and guidelines provided in our repository to ensure consistency and quality.
Additional Resources
6 - CLI Reference
Everything you need to master the KRS CLI
The KRS CLI provides a powerful set of commands for interacting with your Kubernetes clusters and leveraging KRS’s intelligent features. This section serves as a comprehensive reference guide for all available commands and their functionalities.
krs --help
Usage: krs [OPTIONS] COMMAND [ARGS]...
krs: A command line interface to scan your Kubernetes Cluster, detect errors, provide resolutions using LLMs and recommend latest tools for your cluster
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ exit Ends krs services safely and deletes all state files from system. Removes all cached data. │
│ export Exports pod info with logs and events. │
│ health Starts an interactive terminal using an LLM of your choice to detect and fix issues with your cluster │
│ init Initializes the services and loads the scanner. │
│ namespaces Lists all the namespaces. │
│ pods Lists all the pods with namespaces, or lists pods under a specified namespace. │
│ recommend Generates a table of recommended tools from our ranking database and their CNCF project status. │
│ scan Scans the cluster and extracts a list of tools that are currently used. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Understanding the Output
When you execute krs –help, you’ll see a formatted output that provides an overview of the KRS CLI and its functionalities. Here’s a breakdown of the key sections:
- Usage:
This line describes the general format for using KRS commands. It specifies that you can use optional arguments ([OPTIONS]) followed by a specific command (COMMAND) and any additional arguments ([ARGS]) needed for that command.
- krs: A command line interface… :
This section provides a brief description of KRS’s purpose: scanning Kubernetes clusters, detecting errors, providing solutions using LLMs, and recommending the latest tools.
- Options (Global):
These options apply to all KRS commands and can be used to customize their behavior.
--install-completion
:
Installs autocompletion for the current shell, making it easier to type KRS commands.--show-completion
:
Shows available autocompletion options for the current shell.--help
:
Displays this help message and exits the program.
- Commands:
This table lists all available KRS commands and their brief descriptions.
Detailed Command Explanations
This section dives deeper into each KRS command, providing a comprehensive explanation of its purpose, usage syntax, options, and examples for practical application.
1. krs init:
- Purpose:
Initializes the KRS services and loads the scanner. This step is necessary for KRS to function properly. Initialization ensures essential internal services are running efficiently, enabling features like health checks and communication with Large Language Models (LLMs).
- Usage:
- Options: None
- Example:
krs init
Output
Services initialized and scanner loaded.
2. krs scan:
Purpose:
Scans your Kubernetes cluster to identify currently deployed tools and extract relevant information about their usage. This information is used for various purposes, including understanding your current cluster setup and generating recommendations.
Usage:
Options: None
Example:
krs scan
Output:
The krs scan command provides a list of tools detected within your Kubernetes cluster. This list may include tools for monitoring, logging, security, networking, and more.
Scanning your cluster...
Cluster scanned successfully...
Extracted tools used in cluster...
The cluster is using the following tools:
+-------------+--------+------------------+---------------+
| Tool Name | Rank | Category | CNCF Status |
+=============+========+==================+===============+
| cilium | 1 | Network Policies | graduated |
+-------------+--------+------------------+---------------+
| hubble | 7 | Security Tools | listed |
+-------------+--------+------------------+---------------+
3. krs namespaces:
Purpose:
Lists all namespaces within your cluster. Namespaces provide a way to logically group Kubernetes resources. Understanding your cluster’s namespace structure is essential for managing resources effectively.
Usage:
Options: None
Example:
krs namespaces
Output:
The krs namespaces command displays a list of all namespace names within your Kubernetes cluster.
Namespaces in your cluster are:
1. default
2. kube-node-lease
3. kube-public
4. kube-system
4. krs pods [–namespace <namespace_name>]:
Purpose:
Lists all pods within the cluster, optionally filtered by a specific namespace. Pods are the fundamental units of execution in Kubernetes and house containerized applications.
Usage:
krs pods
krs pods --namespace <namespace_name>
Options:
--namespace <namespace_name>
: Filters the list of pods to include only those within the specified namespace.
Example:
krs pods
krs pods --namespace kube-system
Output:
The krs namespaces command displays a list of all namespace names within your Kubernetes cluster.
Pods in namespace 'kube-system':
1. cilium-9lqbq
2. cilium-ffpct
3. cilium-pvknr
4. coredns-85f59d8784-nvr2n
5. coredns-85f59d8784-p9jcv
6. cpc-bridge-proxy-c6xzr
7. cpc-bridge-proxy-p7r4p
8. cpc-bridge-proxy-tkfrd
9. csi-do-node-hwxn7
10. csi-do-node-q27rc
11. csi-do-node-rn7dm
12. do-node-agent-6t5ms
13. do-node-agent-85r8b
14. do-node-agent-m7bvr
15. hubble-relay-74686df4df-856pj
16. hubble-ui-86cc69bddc-xc745
17. konnectivity-agent-9k8vk
18. konnectivity-agent-h5fm2
19. konnectivity-agent-kf4xh
20. kube-proxy-94945
21. kube-proxy-qgv4j
22. kube-proxy-vztzf
5. krs recommend:
Purpose:
Generates a table of recommended tools based on KRS’s internal ranking database and your cluster configuration. The recommendations consider factors like the identified gaps in your current tooling, tool popularity within the Kubernetes community, and feature compatibility with your cluster setup.
Usage:
Options: None
Example:
krs recommend
Output:
The krs recommend command displays a table with recommended tools. The table typically includes information like the tool name, a brief description, and its CNCF project status (e.g., graduated, listed).
Our recommended tools for this deployment are:
+------------------+------------------------+-------------+---------------+
| Category | Recommendation | Tool Name | CNCF Status |
+==================+========================+=============+===============+
| Network Policies | Already using the best | cilium | graduated |
+------------------+------------------------+-------------+---------------+
| Security Tools | Recommended tool | trivy | listed |
+------------------+------------------------+-------------+---------------+
6. krs health:
Purpose:
Starts an interactive terminal session for performing in-depth health checks on your Kubernetes cluster. This session utilizes KRS’s capabilities to go beyond basic health checks provided by Kubernetes itself.
Usage:
Options: None
Example:
krs health
Output:
Executing krs health launches a new interactive terminal window. Within this terminal, you’ll have access to a set of KRS health check functionalities. These functionalities may vary depending on your KRS version and configuration, but they typically include:
- Detailed Pod Health: KRS can delve deeper than basic liveness and readiness probes offered by Kubernetes. It can analyze container logs, resource consumption metrics, and even leverage LLMs to identify potential issues within pods that might not be readily apparent with standard checks.
- Network Health Analysis: KRS can assess the health of your cluster’s network fabric. This might involve examining pod-to-pod communication latency, identifying potential bottlenecks, and verifying network configuration for optimal performance.
- Security Posture Evaluation: KRS can scan your cluster for security vulnerabilities. This may involve analyzing deployments for outdated container images, checking security context constraints (SCCs), and searching for suspicious activities within the cluster.
Starting interactive terminal...
Choose the model provider for healthcheck:
[1] OpenAI
[2] Huggingface
>> 1
Installing necessary libraries..........
openai is already installed.
Enter your OpenAI API key: *open_ai_api_key*
Enter the OpenAI model name: gpt-3.5-turbo
API key and model are valid.
Namespaces in the cluster:
1. default
2. kube-node-lease
3. kube-public
4. kube-system
5. portainer
Which namespace do you want to check the health for? Select a namespace by entering its number: >> 4
Pods in the namespace kube-system:
1. cilium-9lqbq
2. cilium-ffpct
3. cilium-pvknr
4. coredns-85f59d8784-nvr2n
5. coredns-85f59d8784-p9jcv
6. cpc-bridge-proxy-c6xzr
7. cpc-bridge-proxy-p7r4p
8. cpc-bridge-proxy-tkfrd
9. csi-do-node-hwxn7
10. csi-do-node-q27rc
11. csi-do-node-rn7dm
12. do-node-agent-6t5ms
13. do-node-agent-85r8b
14. do-node-agent-m7bvr
15. hubble-relay-74686df4df-856pj
16. hubble-ui-86cc69bddc-xc745
17. konnectivity-agent-9k8vk
18. konnectivity-agent-h5fm2
19. konnectivity-agent-kf4xh
20. kube-proxy-94945
21. kube-proxy-qgv4j
22. kube-proxy-vztzf
Which pod from kube-system do you want to check the health for? Select a pod by entering its number: >> 1
Checking status of the pod...
Extracting logs and events from the pod...
Logs and events from the pod extracted successfully!
Interactive session started. Type 'end chat' to exit from the session!
>> The log entries provided are empty {}, so there is nothing to analyze. Therefore, I can confirm that 'Everything looks good!' in this case.
If there were warnings or errors in the log entries, I would have analyzed them thoroughly to identify the root cause. Depending on the specific warnings or errors, potential steps to resolve the issues could include:
1. Analyzing the specific error message to understand the problem
2. Checking Kubernetes resources (e.g., pods, deployments, configmaps) for any misconfigurations
3. Verifying connectivity to external resources or dependencies
4. Checking for resource limitations or constraints that could be causing issues
5. Reviewing recent changes in the Kubernetes environment that could have introduced problems
6. Using Kubernetes troubleshooting tools like kubectl logs, describe, or events to gather more information
By following these steps and addressing any identified issues, you can resolve warnings or errors in the Kubernetes environment.
>> Wonderful, anything else to note?
>> In addition to resolving warnings or errors in Kubernetes logs, it's important to regularly monitor and maintain the Kubernetes environment to ensure smooth operation. Some best practices for Kubernetes maintenance include:
1. Regularly updating Kubernetes components and cluster nodes to the latest stable versions to benefit from bug fixes and security patches.
2. Implementing automated backups of critical data and configurations to prevent data loss in case of failures.
3. Monitoring resource utilization and scaling components as needed to optimize performance and cost efficiency.
4. Implementing security best practices, such as network policies, RBAC, and pod security policies to protect the cluster from unauthorized access or malicious activities.
5. Conducting regular health checks and performance tuning to identify and address any bottlenecks or inefficiencies in the cluster.
6. Developing a disaster recovery plan and testing it periodically to ensure business continuity in case of unexpected events.
By following these maintenance practices, you can ensure the stability, scalability, and security of your Kubernetes environment for optimal DevOps operations.
>> Alright, so are we done?
>> Yes, we have covered the analysis of the Kubernetes log entries and discussed best practices for Kubernetes maintenance. If you have any more questions or need further assistance, feel free to ask. Otherwise, we can consider this conversation complete.
>> Wonderful. Thanks! end chat
>> You're welcome! If you have any more questions in the future, feel free to reach out. Have a great day! Goodbye!
>> end chat