๐ Introducing the Fix Flag: Actionable Solutions in k8sgpt ๐
As we step into the holiday season, I wanted to share something exciting from my journey with k8sgpt! One feature I felt was missing was the ability to recommend fixes and provide actionable solutions.
So, I got to work and started contributing! My goal was to introduce the fix flag, enabling k8sgpt to deliver actionable solutions to identified issues, and hereโs my initial attempt. This feature is currently in its alpha stage, and, as you might imagine, itโs a challenging task. With AI providers producing different outputs for the same prompt, achieving consistent and accurate results takes some fine-tuning.
๐ฏ Nevertheless, Iโm thrilled to share the first version of this feature! While itโs still evolving, Iโd love to hear your thoughts. Your feedback and suggestions will be invaluable in refining this functionality.
Problem
Previously, k8sgpt would only provide recommendations for issues, like in the example below:
kubectl get pod
NAME READY STATUS RESTARTS AGE
badpod 0/1 ImagePullBackOff 0 12hk8sgpt analyze - explainOutput:0: Pod default/badpod()
- Error: Back-off pulling image โnginxbadโ
Error: Kubernetes is unable to pull the image โnginxbadโ due to a back-off error.Solution:
1. Check the image name and ensure it is spelled correctly.
2. Verify the image exists in the specified repository.
3. Ensure the image repository is accessible and the correct credentials are provided.
New Functionality: ` โ fix` Flag
With the new ` โ fix` flag, k8sgpt can now generate a YAML file with fixes for certain Kubernetes issues.Example Usage
./bin/k8sgpt analyze - explain - fixOutput:
Getting fix for Pod default/badpodโฆ
Fixed yaml saved to: fixed-Pod-default-badpod.yamlInspecting the fixed YAML file:
cat fixed-Pod-default-badpod.yaml
apiVersion: v1
kind: Pod
metadata:
name: badpod
namespace: default
spec:
containers:
- name: nginx
image: nginx:latestCurrent Limitations
- The ` โ fix` functionality currently supports only **basic Pod issues**.
- It requires **OpenAI** as the backend for generating fixes.
NOTE: This functionality is in its alpha stage and only addresses basic Pod issues. Contributions for extending support to other resources or more advanced issues are welcome.
Installation and Usage
Clone the Repository
git clone https://github.com/100daysofdevops/k8sgpt.git
cd k8sgpt
git switch addingfix
make clean && make buildRun the Analyzer with Fix
./bin/k8sgpt analyze โ explain โ fixProvide Feedback
As this feature is still in alpha, your feedback is greatly appreciated. Feel free to raise issues or contribute to the repository for enhancements.Contributing
If youโd like to add more functionality or fix advanced Kubernetes issues, please open a pull request or raise an issue in the repository.
๐ GitHub repository link:
๐Happy holidays and happy coding!
