Skip to content

feat(plugins): add plugin kubectl-ai, Integration for Intelligent Operations #3426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AaronLinOops
Copy link

@AaronLinOops AaronLinOops commented Jul 1, 2025

Overview

This PR integrates kubectl-ai functionality into k9s, bringing LLM-powered intelligent Kubernetes operations to the terminal UI experience.

What is kubectl-ai?

kubectl-ai is an AI-powered Kubernetes assistant that leverages Large Language Models (LLMs) to translate natural language requests into kubectl commands and execute Kubernetes operations 1116. It acts as an intelligent interface between users and Kubernetes clusters, eliminating the need to manually craft complex kubectl commands.

Features Added

  • Natural Language Interface: Users can describe operations in plain English within k9s
  • Smart Command Translation: AI automatically converts natural language to appropriate kubectl commands.

Example Usage

  Hey there, what can I help you with today?


>>> list all finished job in ops namespace
  Running: kubectl get jobs -n ops --field-selector status.successful=1 -o jsonpath='{range .items[?(@.status.succeeded==1)]}{.metadata.name}\n{end}'


  Here is the list of all finished (successful) jobs in the "ops" namespace:

  • auto-pause-29189260
  • cleanup-29189260  
  ...
  • superset-init-db

    Let me know if you need any more details! 😊


>>> cleanup those jobs which name start with 'cleanup'
  Running: kubectl delete jobs -n ops -l job-name-prefix=cleanup --field-selector metadata.name=cleanup

  Do you want to proceed ?
  1) Yes
  2) Yes, and don't ask me again
  3) No
  Enter your choice (1,2,3): 2

  The command to delete jobs with names starting with "cleanup" using the
  label selector did not find any resources because those jobs don't have such
  a label. I will delete the jobs based on name prefix using a different
  approach by listing and deleting them explicitly. Proceeding with this now.


  Running: kubectl get jobs -n ops -o jsonpath='{.items[?(@.metadata.name.startsWith("cleanup"))].metadata.name}' | xargs -r -n 1 kubectl delete job -n ops


  The JSONPath expression I used to filter jobs by prefix is invalid. I will
  try another approach: first list the jobs with name starting with "cleanup"
  in the "ops" namespace, then delete them one by one. I will do this in two
  steps.


  Running: kubectl get jobs -n ops -o jsonpath='{range .items[?(@.metadata.name =~ /^cleanup/)]}{.metadata.name}\n{end}'


  The jsonpath filter for regex match is not supported by kubectl. I will use
  a different approach: get all jobs in the ops namespace, then filter the
  names starting with "cleanup" using shell commands, and delete those jobs.
  Proceeding with this approach now.


  Running: kubectl get jobs -n ops -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | grep '^cleanup' | xargs -r -n 1 kubectl delete job -n ops


  All jobs in the "ops" namespace with names starting with "cleanup" have been
  deleted successfully. If you need any further assistance, feel free to ask!
  😊

>>> list jobs in ops namespace
  Running: kubectl get jobs -n ops


  Here is the list of jobs in the "ops" namespace:

  • auto-pause-29189260
  ...
  • superset-init-db

  If you want me to filter or show specific details, just let me know! 😊

>>>

Security & Production Readiness

⚠️ Important Notice:

The intelligent capabilities and security depend on the LLM model used by the kubectl-ai project. As this technology is still maturing, please DO NOT USE in production environments.

💰 Cost Considerations:

  • Token Usage: The system may examine pod logs, events, and cluster state during analysis
  • Potential High Costs: Large clusters with verbose logging can consume significant LLM tokens
  • Recommendations:
    • Monitor your API usage and billing
    • Set up cost alerts and limits
    • Consider using log filtering or sampling for large deployments
    • Test with small clusters first to estimate costs

Dependencies

Requires kubectl-ai to be installed and configured

Breaking Changes

None. This is an additive feature that doesn't modify existing k9s functionality.

@AaronLinOops AaronLinOops changed the title feat(plugins): add plugin kubectl-ai, Integration for Intelligent Operations operations feat(plugins): add plugin kubectl-ai, Integration for Intelligent Operations Jul 1, 2025
@derailed
Copy link
Owner

derailed commented Jul 5, 2025

@AaronLinOops Nice! Looks like we have conflicts ;( Can you take a peek?

@AaronLinOops
Copy link
Author

AaronLinOops commented Jul 7, 2025

@AaronLinOops Nice! Looks like we have conflicts ;( Can you take a peek?

@derailed My apologies for the delay! ^^; the conflict is now resolved! :-)

@AaronLinOops
Copy link
Author

It looks like dockercloud was unavailable at the time causing the workflow to fail.

{"error": "Our service is temporarily unavailable. We'll be back soon!"}

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronLinOops Tx for the updates!

@@ -0,0 +1,13 @@
plugin:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those that don't read the main readme ;(
We should have a brief header with the project url and how to install it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants