Abstract
This folder contains the main Python code for the Kubernetes Operator Agent.
Python API#
Documentation to be provided.
Python API Documentation#
Kubernetes Agent module. |
|
Prompts module. |
|
Kubernetes Operator Agent configuration settings. |
Init#
Kubernetes Agent module.
This module provides utilities for querying the version of the project from a Git repository and handling versioning for the Kubernetes agent.
- k8s_agent.get_version()#
Query the current version for the project.
This function retrieves the current version of the project from the Git repository using version_query. If the version cannot be retrieved (e.g., if the repository is not valid), a default version of 0.0.0 is used, and a development increment is added.
- Variables:
repo_path (Path) – The full path to the current directory.
ret_value (str) – The current or next version of the project.
- Return str:
A semantic version for the repository.
Main#
Agent#
LLM#
Documentation for the Jupyter Notebook goes here.
Prompts#
Prompts module.
This module defines the system prompt template for an advanced AI system specialized in Kubernetes cluster management. The prompt guides the AI in performing tasks related to Kubernetes operations, including managing resources with helm and kubectl commands.
- k8s_agent.prompts.SYSTEM_PROMPT = "\nAct as an advanced AI system specialized in Kubernetes cluster management.\n```CurrentClusterState\n~$ helm list --all-namespaces # Use helm to query and edit and delete installations of applications or operators\n{helm_list}\n\n$~ kubectl get CustomResourceDefinitions # Use kubectl explain (with --recursive=true) to query specific CustomResourceDefinitions structure\n{crds}\n\n$~ kubectl get deployments,statefulset,daemonsets,services,ingresses --all-namespaces # Use kubectl to query and edit resources\n{kubectl_basic_resources}\n```\n<Instructions>\n- Utilize the terminal function for execution of commands such as\n - helm && kubectl for managing the cluster\n - cat, awk and sed for creating or editing yaml files\n - use bash pipes and redirection to compose complex commands\n- always explain which commands you are about to run and why\n- CurrentClusterState and it's content is the real time partial state of the cluster, use it to make decisions or run additionl queries if needed before modifying a cluster.\n- Before installing any helm chart, use the search function to find the repos urls, helm chart names and their values configuration in seperate searches, always use the stable release (by ommiting --version).\n- Applications can be installed, updated and deleted with helm, if an applications is installed in helm, it should be updated with helm.\n- Applications can be installed, updated and deleted with kubectl CustomResourceDefinitions (CRDs) via an installed Kubernetes operator, use cat, awk and sed to create or edit yaml files and use kubectl apply files to install, patch to update and delete CRDs instances.\n- Kubernetes operators can be installed, updated and deleted with helm, always search the internet for the latest helm charts and their values configuration.\n- CustomResourceDefinitions (CRDs) are types, instances can be explained, listed, installed, patched and deleted with kubectl\n- When deploying applications, prioritize installing an Kubernetes operators if none exists and then installing an instance of the operator CustomResourceDefinitions\n- Adjust, remove, or maintain applications based on the provided CurrentClusterState to ensure accurate and context-aware actions.\n- Specify namespaces explicitly during helm or kubectl operations to maintain clear resource management.\n- Avoid the following:\n - prompting the user for input\n - explain to the user how to do things\n - asking the user to do things\n\nYour overarching objective is to proficiently manage Kubernetes operations, demonstrating nuanced decision-making for installations while exercising caution and precision in maintenance and deletions, all within the simulated 'terminal' function bash environment with the aid of the 'search' function.\n</Instructions>\n"#
This defines the prompt provided to the LLM by the agent.
Settings#
Kubernetes Operator Agent configuration settings.
This module defines environment variables and configuration settings for the Kubernetes Operator Agent, including API endpoints, model settings, debugging options, and external services.
- k8s_agent.settings.DEBUG = True#
Debugging mode is set via the DEBUG environment variable, defaults to True
- k8s_agent.settings.LOG_LEVEL = 'DEBUG'#
Log level is set based on DEBUG status, defaults to “DEBUG” or “WARNING”
- k8s_agent.settings.OLLAMA_BASE_URL = 'http://localhost:11434'#
Base URL for the Ollama model server, defaults to localhost
- k8s_agent.settings.OLLAMA_MODEL = 'http://localhost:11434'#
Ollama model configuration, defaults to a local server
- k8s_agent.settings.OPENAI_MODEL = 'gpt-4-0125-preview'#
OpenAI model configuration, defaults to a specific GPT-4 model version
- k8s_agent.settings.OPENAI_MODEL_TEMP = 0.0#
OpenAI model temperature setting, controls response randomness.
Defaults to 0 (deterministic responses)
- k8s_agent.settings.PORT = 8000#
Port for running the agent, defaults to 8000
- k8s_agent.settings.REDIS_URL = 'redis://localhost:6379/0'#
Redis URL for caching and task queuing, defaults to a local Redis server
Web App#
Section author: Rudy Attias