Kom
by weibaohui
Kom is a Kubernetes Operations Manager, providing SDK-level kubectl and client-go usage encapsulation. It offers a range of functionalities to manage Kubernetes resources, including creating, updating, deleting, and retrieving resources, and even using SQL statements to query and manage k8s resources.
Last updated: N/A
What is Kom?
Kom is a tool for Kubernetes operations, acting as an SDK-level encapsulation of kubectl and client-go. It simplifies Kubernetes resource management, supports multiple clusters and CRDs, and even allows querying resources using SQL.
How to use Kom?
To use Kom, you need to register clusters using RegisterCluster
. Then, you can use the chainable API to perform operations like creating, getting, listing, updating, and deleting resources. Examples are provided in the README for various use cases, including working with CRDs and using SQL queries.
Key features of Kom
Simple and easy to use
Multi-cluster support
MCP support with stdio and SSE modes
Cross-namespace resource querying
Chainable API calls
Custom Resource Definition (CRD) support
Callback mechanism for extending business logic
POD file operations
High-frequency operation encapsulation (restart, scale, etc.)
SQL query support for Kubernetes resources
Query caching for improved performance
Use cases of Kom
Managing Kubernetes resources (deployments, pods, services, etc.)
Operating on Custom Resource Definitions (CRDs)
Automating Kubernetes tasks
Integrating with MCP tools for multi-cluster management
Querying Kubernetes resources using SQL
Performing file operations within Pods
Extending Kubernetes functionality with custom callbacks
FAQ from Kom
How do I register a Kubernetes cluster?
How do I register a Kubernetes cluster?
Use the kom.Clusters().RegisterByPathWithID()
or kom.Clusters().RegisterInCluster()
functions, providing the kubeconfig path or using the in-cluster configuration.
How do I perform a simple resource operation, like listing pods?
How do I perform a simple resource operation, like listing pods?
Use the chainable API: kom.DefaultCluster().Resource(&corev1.Pod{}).Namespace("default").List(&pods)
.
Can I use SQL to query Kubernetes resources?
Can I use SQL to query Kubernetes resources?
Yes, use the kom.DefaultCluster().Sql(sql)
function with a valid SQL query targeting Kubernetes resources.
How do I handle Custom Resource Definitions (CRDs)?
How do I handle Custom Resource Definitions (CRDs)?
Use the kom.DefaultCluster().CRD(group, version, kind)
function to interact with CRDs, providing the group, version, and kind of the CRD.
How do I execute a command inside a Pod?
How do I execute a command inside a Pod?
Use the kom.DefaultCluster().Namespace("default").Name("pod-name").Ctl().Pod().ContainerName("container-name").Command("command", "args...").ExecuteCommand(&result)
function.