Skip to main content

KGPT

KGPT, or Kubernetes General Purpose Tasker, is a cutting-edge Kubernetes agent designed to simplify and streamline the management of complex and manual tasks within your Kubernetes cluster. In the dynamic world of container orchestration and cloud-native computing, KGPT emerges as a powerful ally, offering automation and intelligence to help you efficiently handle a wide range of tasks, from deployment and scaling to monitoring and troubleshooting. This innovative agent is engineered to alleviate the burden of manual interventions, enhancing the agility and reliability of your Kubernetes infrastructure. With KGPT at your side, you can confidently navigate the intricate landscape of Kubernetes, ensuring optimal performance and resource utilization while freeing up valuable time for more strategic endeavors.

Install

Prerequisites

  • You already setup an k8s cluster locally or on the cloud, and kubectl is working normally
  • You need Python and pip installed
  • openAI GPT-4 API key ready

Supported python version 3.8 | 3.9 | 3.10 | 3.11

pip install agentk8s

Install auto completion (optional)

$ kgpt --install-completion

Example

1. call the setup command to enter your GPT-4 api-key

kgpt setup

2. Now try a few command, like setup an deployment and a service.

kgpt chat "create an deployment called mynginx, image name is nginx, three replicas, expose port 80"

After a few seconds you should see the following output if everything is executed successfully.

user_proxy (to assistant):

exitcode: 0 (execution succeeded)
Code output: 
deployment.apps/mynginx created

service/mynginx exposed

3. We can also modify a resource in the cluster, let's change the mynginx service target port to 8001

kgpt chat "Change mynginx service's target port to 8001"

If everything is executed successfully, you should see the following output

exitcode: 0 (execution succeeded)
Code output: 
service/mynginx patched

4. Now let's delete the resource we just created.

kgpt chat "delete mynginx deployment and service"

You should be able to see the following output, if everything is executed successfully.

user_proxy (to assistant):

exitcode: 0 (execution succeeded)
Code output: 
deployment.apps "mynginx" deleted
service "mynginx" deleted

5. You can also chat with a file, just use the --doc [path or url] option, let's find how weather there are vulnerability in a k8s yaml (Note you can't execute code when you supplied --doc option in RAG enabled mode)

kgpt chat "find vulnerability in this k8s yaml file" --doc example_file/deployment1.yaml

you should be seeing the following output

Intent: Code generation task (to find vulnerability in the provided k8s yaml file).

The provided YAML file has a few issues that could potentially be considered vulnerabilities or misconfigurations:

1. The `image` field does not specify a tag. Using the `latest` tag or not specifying a tag can lead to unpredictable deployments because it's not clear which version of the image is being used. It's better to use a specific version for reproducibility and to avoid accidentally pulling in an updated version with potential vulnerabilities.

2. There are no resource requests or limits specified for the container. This can lead to resource exhaustion on the node where the pod is running, potentially affecting other pods and the stability of the node itself.

3. There is no readiness probe defined. While not necessarily a vulnerability, a readiness probe is important for ensuring that traffic is not sent to a container that isn't ready to handle it.

4. The deployment does not define any security context. Without a security context, the container may run with default settings, which could include running as root, potentially leading to security risks if the container is compromised.

5. The YAML syntax is incorrect. The dashes before `name` and `containerPort` should not be indented.

Please note that the specific values for image version, resource requests, limits, and security context should be adjusted according to the actual requirements and best practices for the application and the organization's security policies.

You can also supply kgpt with multiply docs

kgpt chat "combine these to yaml into one yaml" --doc example_file/deployment1.yaml --doc example_file/service1.yaml

List of possible tasks

  • "create an deployment called mynginx, image name is nginx, three replicas, expose port 80"
  • "change mynginx service's target port to 8001"
  • "delete mynginx deployment and service"
  • "remove all deployment and service in namespace model"
  • "watch the status of deployment nginx"
  • "list all deployment and service"
  • "list all running deployment with more than two replica"
  • "create a namespace called test"
  • "create a namespace called gpu and change the nginx deployment's namespace to gpu"
  • "remove the namespace gpu if no deployment with the namespace gpu"
  • "create a docker-registry secret called my-docker-secret, the docker server is mydocker.io usename is vurtne and the password is yqxzv193"
For more possible tasks that the agent can do please checkout here

Release files for agentk8s 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentk8s 0.1.12
File Size Uploaded
agentk8s-0.1.12.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentk8s 0.1.12
File Interpreter ABI Platform
agentk8s-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / agentk8s-0.1.12.tar.gz

Download URL agentk8s-0.1.12.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
30692d5e04d0880077c21c7e80aee7f2038f9e65d50f69f0ad9e6574d7601bc3
BLAKE2b-256 checksum
How to use checksums
09ca051abaafe4b260d79b490d982b55271e0131a777ad0c7781321437e565e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

Release files / agentk8s-0.1.12-py3-none-any.whl

Download URL agentk8s-0.1.12-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1968169b84b909bcc451f103e2860764cca3e03ea3659ea712c633ec7670e942
BLAKE2b-256 checksum
How to use checksums
8cb053729b9f5d8ef9190041ccb66f137e42c65b49f77423407575c0056be2d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

Release history Release notifications | RSS feed

This release

0.1.12 This release

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page