Unlocking AI – K8sGPT + Kubernetes Observability

K8sGPT is most valuable when there are real problems . The workflow is: fast scan to detect, explain to diagnose, fit, re-scan to confirm clean.

Download K8sGPT from Github

curl -LO https://github.com/k8sgpt-ai/k8sgpt/releases/latest/download/k8sgpt_amd64.deb

Now install K8sGPT:

sudo dpkg -i k8sgpt_amd64.deb
k8sgpt version

Running the help commands

 k8sgpt --help

Configure Ollama as AI backend

kubectl get svc | grep ollama

To use the in-cluster Ollama service as its AI backend using the localai provider we just run

k8sgpt auth add --backend localai --baseurl http://10.43.76.90:11434/v1 --model llama3.2:latest


To enable Autocompletion

sudo apt install bash-completion -y
source /usr/share/bash-completion/bash_completion
# Add kubectl autocompletion to your bash profile echo 'source <(kubectl completion bash)' >> ~/.bashrc
# Add kubectl autocompletion to your bash profile echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'source <(k8sgpt completion bash)' >> ~/.bashrc
source ~/.bashrc

Run the get pods to see the state of pods

kubectl get pods -A

Lets just do quick non AI Analysis to see why the pod is not starting

k8sgpt analyze --namespace k8sgpt-lab

Run the AI Analysis to see the result and we can see its missing the db secret

k8sgpt analyze --explain --backend localai --namespace k8sgpt-lab

Create the missing secret

kubectl create secret generic db-secret --from-literal=password='VMware123!' --namespace k8sgpt-lab

Lets test it again to see if its still has any errors

kubectl get pods -n k8sgpt-lab

No errors found on our AI analysiss

k8sgpt analyze --namespace k8sgpt-lab
(Visited 2 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.