K8s-Copilot is a command-line tool based on Golang which allows you to create/list/update/delete Kubernetes built-in resources interactively powered by ChatGPT.
Note: Model is currently hard-coded in gpt-4o-mini.
- Create a Kubernetes resource in a specific namespace.
- List Kubernetes either namespaced or non-namespaced resources.
- Update a Kubernetes resource given specific name & namespace.
- Delete a Kubernetes resource given specific name & namespace.
k8s-copilot
├── ask
│ ├── chatgpt
└── analyze
├── eventAn out-of-box Kubernetes cluster environment, try kind. 👈
Install Golang.
$ go build -o k8s-copilotTry APIYI 👈 if you had difficulty acquiring OpenAI API Key from mainland China.
# wsl env to win
$ export API_KEY="api_key"
$ export BASE_URL="base_url"If you're using WSL, add below to /etc/wsl.conf then export the ENV.
[automount]
options = "metadata"$ export WSLENV=API_KEY/w:BASE_URL/wHelp
$ ./k8s-copilot -hAsk
$ ./k8s-copilot ask chatgptA greeting prompt will show up.
Greetings, I'm a Copilot for Kubernetes, you require my assistant?
>
Type your queries:
Note: open another terminal to run kubectl cmd for checking.
> create a deploy named nginx, image is nginx:latest, replica is 2
# check
$ kubectl get deploy> ls all pods
> ls all pods in kube-system
> ls all services in kube-system
> ls all namespaces
> update deploy named nginx replica to 3# check
$ kubectl get deploy> add label env=test to deploy named nginx
# check
$ kubectl get po --show-labels> remove label env=test from deploy named nginx
# check
$ kubectl get po --show-labels> update image of deploy named nginx to nginx:1.26.2
# check
$ kubectl get deploy nginx -o yaml | grep image:> delete deploy named nginx
$ kubectl get deploy> exit
See more in UML. 👈
- Sometimes the update query is not strictly idempotent due to returned response from LLM, please try multiple times.
- The update query will create a new ReplicaSet if you try to add a label to Deployment.
N/A
N/A
N/A
N/A
- Add a flag to select LLM.
- Replace stdin with GNU-Readline.
- Add event analyzer feature.
- Fine tune system prompt to LLM to improve robustness & Idempotence.