{"id":31401,"date":"2026-05-26T13:34:11","date_gmt":"2026-05-26T08:04:11","guid":{"rendered":"https:\/\/opstree.com\/blog\/?p=31401"},"modified":"2026-05-26T14:28:04","modified_gmt":"2026-05-26T08:58:04","slug":"running-k8sgpt-with-local-llm","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/running-k8sgpt-with-local-llm\/","title":{"rendered":"K8sGPT: Running K8sGPT with Local LLM to Build Your Own AI-Powered Kubernetes Troubleshooting tool."},"content":{"rendered":"<p><b><span data-contrast=\"auto\">Kubernetes\u00a0<\/span><\/b><span data-contrast=\"auto\">is powerful, scalable, and production-ready &#8211; but troubleshooting Kubernetes issues is often painful and time-consuming.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">A Pod suddenly <\/span><span data-contrast=\"none\">enters CrashLoopBackOff, an image fails to pull, or a Deployment silently refuses to become ready. Engineers typically spend hours checking logs, events, YAML manifests, and <\/span><span data-contrast=\"none\">running multiple kubectl commands just to understand what went wrong.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Now imagine asking AI:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:0,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><strong>\u201cWhy is my Kubernetes Pod failing?\u201d\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">And within seconds, you get:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"auto\">The reason behind the failure<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">The possible root cause<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">Recommended solutions to fix it<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><!--more--><\/p>\n<p><span data-contrast=\"none\">That\u2019s exactly <\/span><span data-contrast=\"none\">what <\/span><b><span data-contrast=\"none\">K8sGPT<\/span><\/b><span data-contrast=\"none\">\u00a0does.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">K8sGPT is an AI-powered Kubernetes troubleshooting tool that analyzes your cluster and explains issues in simple, human-readable language. Instead of manually interpreting cryptic Kubernetes errors, K8sGPT acts\u00a0as\u00a0an AI assistant for your cluster.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">In this blog, we will set up K8sGPT as a\u00a0<\/span><b><span data-contrast=\"none\">CLI tool<\/span><\/b><span data-contrast=\"none\"> to manually analyze and troubleshoot Kubernetes issues directly from the terminal. This approach is lightweight, simple, and perfect for learning and <\/span><span data-contrast=\"none\">experimentation.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">In the next part, we will explore K8sGPT as a\u00a0<\/span><a href=\"https:\/\/opstree.com\/blog\/mongodb-setup-on-kubernetes-using-mongodb-operator\/\" target=\"_blank\" rel=\"noopener\"><b><span data-contrast=\"none\">Kubernetes Operator<\/span><\/b><\/a><span data-contrast=\"none\">, where it runs continuously inside the cluster and <\/span><span data-contrast=\"none\">automatically monitors resources for issues. Unlike the CLI approach, the Operator model is better suited for production environments because it enables automated, cluster-wide analysis without manually running commands every time.<\/span><\/p>\n<div style=\"background: #f8fafc; padding: 18px; border: 1px solid #e2e8f0; border-radius: 6px; margin: 20px 0; font-family: Arial, sans-serif;\">\n<h2 style=\"margin-top: 0; font-size: 18px; color: #0f172a;\">Table of Contents<\/h2>\n<ol style=\"margin: 0; padding-left: 18px; line-height: 1.8; font-size: 14px;\">\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#what-is-k8sgpt\">What is K8sGPT?<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#benefits-of-using-k8sgpt\">Benefits of Using K8sGPT<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#how-k8sgpt-works\">How K8sGPT Works<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#architecture-flow\">Architecture Flow<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#what-k8sgpt-can-do\">What K8sGPT CAN Do<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#what-k8sgpt-cannot-do\">What K8sGPT CANNOT Do (By Default)<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#what-we-are-building\">What We Are Building<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#why-use-local-ai-instead-of-cloud-ai\">Why Use Local AI Instead of Cloud AI?<br \/>\n<\/a><\/li>\n<li><a style=\"color: #2563eb; text-decoration: none;\" href=\"#final-thoughts\">Final Thoughts<\/a><\/li>\n<\/ol>\n<\/div>\n<h2 id=\"what-is-k8sgpt\" aria-level=\"1\"><b><span data-contrast=\"none\">What is K8sGPT?<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">K8sGPT is an open-source project that uses\u00a0<\/span><a href=\"https:\/\/opstree.com\/blog\/llm-powered-etl-genai-data-transformation\/\" target=\"_blank\" rel=\"noopener\"><b><span data-contrast=\"auto\">Large Language Models (LLMs)<\/span><\/b><\/a><span data-contrast=\"auto\">\u00a0to analyze Kubernetes clusters and explain issues and\u00a0possible solutions\u00a0in\u00a0simple English.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">It helps answer questions such as:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Why is my Pod in\u00a0CrashLoopBackOff?<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Why is my Service not reachable?<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Why is my Deployment not scaling?<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Why is my Ingress not routing traffic?<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">Instead of manually debugging low-level Kubernetes errors, K8sGPT converts them into understandable explanations with suggested fixes.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h2 id=\"benefits-of-using-k8sgpt\" aria-level=\"1\"><b><span data-contrast=\"none\">Benefits of Using K8sGPT<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<ul>\n<li><span data-contrast=\"none\">Reduced troubleshooting time<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Better understanding of Kubernetes issues<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Lower operational overhead<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Improved privacy with local AI models<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Faster onboarding for junior engineers<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<h2 id=\"how-k8sgpt-works\" aria-level=\"1\"><b><span data-contrast=\"none\">How K8sGPT Works<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">At\u00a0a high level, K8sGPT works in three simple steps.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h3><b><span data-contrast=\"none\">1. Scan the Cluster<\/span><\/b><\/h3>\n<p><span data-contrast=\"none\">K8sGPT inspects Kubernetes resources such as:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Pods<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Deployments<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Services<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Events<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">ConfigMaps<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Ingress resources<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<h3><b><span data-contrast=\"none\">2. Analyze with AI<\/span><\/b><\/h3>\n<p><span data-contrast=\"none\">The collected cluster information is sent to an AI backend for analysis.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">In this blog, the AI backend is:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Ollama\u00a0:- is\u00a0a free, open-source tool that allows you to easily download, set up, and run large language models (LLMs) entirely on your own computer<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">TinyLlama:- This is an LLM.\u00a0<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<h3><b><span data-contrast=\"none\">3. Generate Insights<\/span><\/b><\/h3>\n<p><span data-contrast=\"none\">K8sGPT returns:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Human-readable explanations<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Possible root\u00a0causes<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Recommended fixes<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">This significantly reduces troubleshooting time and helps engineers understand\u00a0Kubernetes&#8217;\u00a0issues much faster.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h2 id=\"architecture-flow\" aria-level=\"1\"><b><span data-contrast=\"none\">Architecture Flow<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">The overall architecture looks like this:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ol>\n<li><span data-contrast=\"none\">Deploy Ollama inside the <a href=\"https:\/\/opstree.com\/blog\/on-premise-setup-of-kubernetes-cluster-components-offline-mode-part-2\/\" target=\"_blank\" rel=\"noopener\">Kubernetes cluster<\/a><\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Run the\u00a0TinyLlama\u00a0model inside the\u00a0Ollama\u00a0Pod<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Install K8sGPT on your local machine or <a href=\"https:\/\/opstree.com\/blog\/restoring-a-backup-stored-in-s3-to-an-ec2-instance-using-xtrabackup\/\" target=\"_blank\" rel=\"noopener\">EC2 instance<\/a><\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Connect K8sGPT to the local\u00a0Ollama\u00a0AI backend<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Analyze Kubernetes issues using AI<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-31405 size-full\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page5_img1.jpeg\" alt=\"K8sGPT Architecture Flow\u00a0\" width=\"1220\" height=\"734\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page5_img1.jpeg 1220w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page5_img1-300x180.jpeg 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page5_img1-1024x616.jpeg 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page5_img1-768x462.jpeg 768w\" sizes=\"auto, (max-width: 1220px) 100vw, 1220px\" \/><\/p>\n<h2 id=\"what-k8sgpt-can-do\" aria-level=\"1\"><b><span data-contrast=\"none\">What K8sGPT CAN Do<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<ul>\n<li><span data-contrast=\"none\">Scan your cluster for common problems<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Detect configuration mistakes<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Inspect events, crashes, and resource issues<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Explain Kubernetes errors in simple English<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Suggest\u00a0possible solutions<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Reduce debugging time drastically<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<h2 id=\"what-k8sgpt-cannot-do\" aria-level=\"1\"><b><span data-contrast=\"none\">What K8sGPT CANNOT Do (By Default)<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<ul>\n<li><span data-contrast=\"none\">\u00a0It does not automatically fix problems<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">It should not make production changes on its own<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">It cannot understand your business logic completely<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">It cannot repair bugs inside application code<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">It cannot replace human review and approval processes<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><b><span data-contrast=\"none\">NOTE:\u00a0K8sGPT should be treated as an intelligent troubleshooting assistant, not a replacement for engineering decisions.<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h2 id=\"what-we-are-building\" aria-level=\"1\"><b><span data-contrast=\"none\">What We Are Building\u00a0<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">We\u2019ll\u00a0build a complete\u00a0<\/span><b><span data-contrast=\"none\">local <a href=\"https:\/\/buildpiper.io\/kubeops-kubernetes-management\/\" target=\"_blank\" rel=\"noopener\">AI-powered Kubernetes<\/a> troubleshooting environment<\/span><\/b><span data-contrast=\"none\">\u00a0using:<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Minikube<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Docker<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Ollama<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">K8sGPT<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">TinyLlama<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:220,&quot;335559739&quot;:220}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><b><span data-contrast=\"none\">NOTE: You can <\/span><\/b><b><span data-contrast=\"none\">use your <a href=\"https:\/\/buildpiper.io\/glossary\/kubernetes-cluster\/\" target=\"_blank\" rel=\"noopener\">Kubernetes cluster<\/a> instead of Minikube. I am using Minikube here simply to demonstrate how everything works in a local environment.<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><b><span data-contrast=\"none\">I am <\/span><\/b><b><span data-contrast=\"none\">also using TinyLlama because my system has limited resources. If your machine has better CPU\/RAM\/GPU capacity, you can use larger models such as llama3 for better response quality and accuracy.<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h2 id=\"why-use-local-ai-instead-of-cloud-ai\" aria-level=\"1\"><b><span data-contrast=\"none\">Why Use Local AI Instead of Cloud AI?<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:480,&quot;335559739&quot;:120}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">In this setup, the AI model runs completely locally instead of using cloud providers such as OpenAI.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p aria-level=\"2\"><b><span data-contrast=\"none\">The Best Part?<\/span><\/b><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;134245418&quot;:true,&quot;134245529&quot;:true,&quot;335559738&quot;:360,&quot;335559739&quot;:80}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"none\">Everything runs locally<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">No OpenAI API key\u00a0required<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">No external cloud dependency<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"none\">Completely free and privacy-friendly<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">This is especially useful for organizations that do not want to expose\u00a0Kubernetes\u00a0metadata, infrastructure details, or operational logs to third-party <a href=\"https:\/\/opstree.com\/services\/generative-ai-solutions\/\" target=\"_blank\" rel=\"noopener\">AI services<\/a>.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><b><span data-contrast=\"auto\">NOTE:<\/span><\/b><span data-contrast=\"auto\">\u00a0If you are setting this up in your pre-production or existing Kubernetes infrastructure and not for local testing using\u00a0Minikube, then you can skip\u00a0<\/span><b><span data-contrast=\"auto\">Step 1 \u2013 Step 4<\/span><\/b><span data-contrast=\"auto\">\u00a0and directly start from\u00a0<\/span><b><span data-contrast=\"auto\">Step 5<\/span><\/b><span data-contrast=\"auto\">.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<h3 id=\"step-1-install-minikube\">Step 1: Install Minikube<\/h3>\n<p><span data-contrast=\"none\">Minikube\u00a0allows us to run Kubernetes locally.<\/span><span data-ccp-props=\"{&quot;134233117&quot;:false,&quot;134233118&quot;:false,&quot;335559738&quot;:240,&quot;335559739&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">We can use below official documentation to install and setup\u00a0minikube<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">https:\/\/minikube.sigs.k8s.io\/docs\/start\/\r\n<\/pre>\n<h3 id=\"step-2-install-kubectl\">Step 2 : Install kubectl<\/h3>\n<p><code>kubectl<\/code> is the Kubernetes command-line tool used to interact with clusters.<\/p>\n<p>We can use the below official documentation to install <code>kubectl<\/code>.<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">https:\/\/kubernetes.io\/docs\/tasks\/tools\/install-kubectl-linux\/\r\n<\/pre>\n<h3 id=\"step-3-install-docker\">Step 3 : Install Docker<\/h3>\n<p>Docker is required as the container runtime for Minikube.<\/p>\n<p>We can follow the below official documentation to install Docker Engine.<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">https:\/\/docs.docker.com\/engine\/install\/ubuntu\/<\/pre>\n<h3 id=\"step-4-start-cluster\">Step 4: Start the Kubernetes Cluster<\/h3>\n<p><strong>Start Minikube<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">minikube start --cpus=4 --memory=8192\r\n<\/pre>\n<p><strong>Verify the Cluster<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl get nodes\r\n<\/pre>\n<p><strong>Expected Output:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">NAME       STATUS   ROLES           AGE   VERSION\r\nminikube   Ready    control-plane   2m    v1.xx.x\r\n<\/pre>\n<p>Your local Kubernetes cluster is now ready.<\/p>\n<h3 id=\"step-5-deploy-ollama\">Step 5 : Deploy Ollama in Kubernetes<\/h3>\n<p>Now we\u2019ll deploy Ollama inside Kubernetes.<\/p>\n<p>Create a file called: <code>ollama.yaml<\/code><\/p>\n<p>And add the below manifest to the file:<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">apiVersion: v1\r\nkind: Namespace\r\nmetadata:\r\n  name: ollama\r\n\r\n---\r\napiVersion: v1\r\nkind: PersistentVolumeClaim\r\nmetadata:\r\n  name: ollama-storage\r\n  namespace: ollama\r\n\r\nspec:\r\n  accessModes:\r\n    - ReadWriteOnce\r\n  resources:\r\n    requests:\r\n      storage: 8Gi\r\n\r\n---\r\napiVersion: apps\/v1\r\nkind: Deployment\r\nmetadata:\r\n  name: ollama\r\n  namespace: ollama\r\n\r\nspec:\r\n  replicas: 1\r\n\r\n  selector:\r\n    matchLabels:\r\n      app: ollama\r\n\r\n  template:\r\n    metadata:\r\n      labels:\r\n        app: ollama\r\n\r\n    spec:\r\n      containers:\r\n        - name: ollama\r\n          image: ollama\/ollama:latest\r\n\r\n          imagePullPolicy: IfNotPresent\r\n\r\n          ports:\r\n            - containerPort: 11434\r\n\r\n          env:\r\n            - name: OLLAMA_KEEP_ALIVE\r\n              value: \"30m\"\r\n\r\n          resources:\r\n            requests:\r\n              memory: \"1Gi\"\r\n              cpu: \"500m\"\r\n\r\n            limits:\r\n              memory: \"2Gi\"\r\n              cpu: \"1\"\r\n\r\n          volumeMounts:\r\n            - name: ollama-storage\r\n              mountPath: \/root\/.ollama\r\n\r\n          startupProbe:\r\n            tcpSocket:\r\n              port: 11434\r\n            failureThreshold: 30\r\n            periodSeconds: 10\r\n\r\n          readinessProbe:\r\n            tcpSocket:\r\n              port: 11434\r\n            initialDelaySeconds: 5\r\n            periodSeconds: 10\r\n\r\n          livenessProbe:\r\n            tcpSocket:\r\n              port: 11434\r\n            initialDelaySeconds: 30\r\n            periodSeconds: 20\r\n\r\n      volumes:\r\n        - name: ollama-storage\r\n          persistentVolumeClaim:\r\n            claimName: ollama-storage\r\n\r\n---\r\napiVersion: v1\r\nkind: Service\r\nmetadata:\r\n  name: ollama\r\n  namespace: ollama\r\n\r\nspec:\r\n  type: ClusterIP\r\n\r\n  selector:\r\n    app: ollama\r\n\r\n  ports:\r\n    - port: 11434\r\n      targetPort: 11434\r\n<\/pre>\n<h3 id=\"deploy-resources\">Deploy the Resources<\/h3>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl apply -f ollama.yaml\r\n<\/pre>\n<p><strong>Verify Deployment:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl get all -n ollama\r\n<\/pre>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31407\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img1.png\" alt=\"\" width=\"837\" height=\"198\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img1.png 837w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img1-300x71.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img1-768x182.png 768w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/h3>\n<h3 id=\"step-6-download-tinyllama\">Step 6 : Download the TinyLlama Model<\/h3>\n<p><strong>Access the Ollama container:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl exec -it -n ollama deploy\/ollama -- sh\r\n<\/pre>\n<p><strong>Pull the TinyLlama model:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">ollama pull tinyllama\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31408\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img2.png\" alt=\"\" width=\"1054\" height=\"232\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img2.png 1054w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img2-300x66.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img2-1024x225.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page11_img2-768x169.png 768w\" sizes=\"auto, (max-width: 1054px) 100vw, 1054px\" \/><\/p>\n<p><strong>Exit the container:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">exit\r\n<\/pre>\n<h3 id=\"step-7-expose-ollama\">Step 7 \u2014 Expose Ollama Locally<\/h3>\n<p><strong>Run port forwarding:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl port-forward -n ollama svc\/ollama 11434:11434\r\n<\/pre>\n<p><code>11434:11434<\/code> \u2192 This is Ollama\u2019s default port.<\/p>\n<p>Ollama is now accessible at:<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">http:\/\/localhost:11434\r\n<\/pre>\n<p>Keep this terminal running.<\/p>\n<p><strong>NOTE:<\/strong> Before moving to Step 8, install K8sGPT on the machine from where you run <code>kubectl<\/code> commands and access your Kubernetes cluster.<\/p>\n<h3 id=\"step-8-install-k8sgpt\">Step 8 : Install K8sGPT<\/h3>\n<p>K8sGPT uses your local <code>kubeconfig<\/code> context to analyze Kubernetes resources,<br \/>\nevents, Pods, Deployments, Services, and other cluster components.<\/p>\n<p><strong>Download K8sGPT:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">curl -LO https:\/\/github.com\/k8sgpt-ai\/k8sgpt\/releases\/download\/v0.4.32\/k8sgpt_amd64.deb\r\n<\/pre>\n<p><strong>Install it:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">sudo dpkg -i k8sgpt_amd64.deb\r\n<\/pre>\n<p><strong>Verify installation:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt version\r\n<\/pre>\n<h3 id=\"step-9-connect-k8sgpt-ollama\">Step 9 : Connect K8sGPT with Ollama<\/h3>\n<p>Configure K8sGPT to use the local AI model.<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt auth add \\\r\n  --backend ollama \\\r\n  --baseurl http:\/\/localhost:11434 \\\r\n  --model tinyllama\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-31409\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img1.png\" alt=\"\" width=\"1054\" height=\"128\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img1.png 689w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img1-300x37.png 300w\" sizes=\"auto, (max-width: 1054px) 100vw, 1054px\" \/><\/p>\n<h3 id=\"step-10-set-default-backend\">Step 10 \u2014 Set Ollama as the Default Backend<\/h3>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt auth default -p ollama\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31410\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img2.png\" alt=\"\" width=\"827\" height=\"345\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img2.png 827w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img2-300x125.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page13_img2-768x320.png 768w\" sizes=\"auto, (max-width: 827px) 100vw, 827px\" \/><\/p>\n<p><strong>Check configured providers:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt auth list\r\n<\/pre>\n<h3 id=\"step-11-analyze-kubernetes-issues\">Step 11 : Analyze Kubernetes Issues<\/h3>\n<p>Now let AI analyze your Kubernetes cluster.<\/p>\n<p><strong>Analyze the Entire Cluster:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze\r\n<\/pre>\n<p><strong>Get AI-Generated Explanations:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --explain\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31415\" src=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1.png\" alt=\"\" width=\"1674\" height=\"833\" srcset=\"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1.png 1674w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1-300x149.png 300w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1-1024x510.png 1024w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1-768x382.png 768w, https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/page14_img1-1536x764.png 1536w\" sizes=\"auto, (max-width: 1674px) 100vw, 1674px\" \/><\/p>\n<p><strong>Analyze Only Pods:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --filter Pod\r\n<\/pre>\n<p><strong>Analyze a Specific Namespace:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --namespace app1 --explain\r\n<\/pre>\n<p><strong>Export Results as JSON:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze -o json &gt; report.json\r\n<\/pre>\n<p><strong>Analyze Pods with AI Explanations:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze \\\r\n  --namespace app1 \\\r\n  --filter Pod \\\r\n  --explain\r\n<\/pre>\n<p><strong>Analyze with Anonymization:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --explain -b ollama --anonymize\r\n<\/pre>\n<h3 id=\"step-12-create-broken-pod\">Step 12 : Create a Broken Pod for Testing<\/h3>\n<p>Now let\u2019s intentionally deploy a broken Pod and allow K8sGPT to diagnose the issue.<\/p>\n<p><strong>Create a Namespace:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl create namespace app1\r\n<\/pre>\n<p><strong>Create <code>broken.yaml<\/code>:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">apiVersion: v1\r\n\r\nkind: Pod\r\n\r\nmetadata:\r\n  name: broken-nginx\r\n  namespace: app1\r\n\r\nspec:\r\n  containers:\r\n    - name: nginx\r\n      image: nginx:notfound\r\n<\/pre>\n<p><strong>Deploy the Broken Pod:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl apply -f broken.yaml\r\n<\/pre>\n<p><strong>Check Pod Status:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">kubectl get pods -n app1\r\n<\/pre>\n<p>You\u2019ll notice errors such as:<\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">ErrImagePull\r\n\r\nImagePullBackOff\r\n<\/pre>\n<p><strong>Ask K8sGPT to Explain the Issue:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --namespace app1 --filter Pod --explain\r\n<\/pre>\n<p>Instead of showing raw Kubernetes errors, K8sGPT provides a clear explanation in plain English.<br \/>\nThis is extremely useful for both beginners and experienced Kubernetes engineers.<\/p>\n<h3 id=\"understanding-anonymize-flag\">Understanding the &#8211;anonymize Flag<\/h3>\n<p>When using external AI providers such as OpenAI with K8sGPT, many organizations worry about exposing sensitive Kubernetes information like:<\/p>\n<ul>\n<li>Namespace names<\/li>\n<li>Service names<\/li>\n<li>Internal URLs<\/li>\n<li>Infrastructure details<\/li>\n<\/ul>\n<p>This is where the <code>--anonymize<\/code> flag becomes very important.<\/p>\n<p><strong>Run:<\/strong><\/p>\n<pre style=\"background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.6;\">k8sgpt analyze --explain --anonymize\r\n<\/pre>\n<p>K8sGPT masks sensitive cluster information before sending the data to the AI provider.<br \/>\nThe AI only receives masked resource details instead of the original values.<\/p>\n<p>After the analysis is completed, K8sGPT maps the response back locally so the user still receives meaningful explanations related to their actual Kubernetes resources.<\/p>\n<p>This allows teams to use AI-powered troubleshooting while significantly reducing privacy and security risks associated with sharing production cluster data with external AI platforms.<\/p>\n<h2 id=\"final-thoughts\">Final Thoughts<\/h2>\n<p>K8sGPT is one of the most practical AI tools currently available for Kubernetes operations.<\/p>\n<p>By combining:<\/p>\n<ul>\n<li>Kubernetes<\/li>\n<li>Ollama<\/li>\n<li>Local LLMs<\/li>\n<li>AI-powered analysis<\/li>\n<\/ul>\n<p>you can dramatically simplify Kubernetes troubleshooting without depending on external cloud AI providers.<\/p>\n<p>In the next part, we\u2019ll explore running K8sGPT as a Kubernetes Operator for continuous cluster monitoring and automated AI-powered diagnostics.<\/p>\n<h3>Related Searces<\/h3>\n<ul>\n<li><a href=\"https:\/\/opstree.com\/blog\/kubernetes-production-guide-architectur\/\" target=\"_blank\" rel=\"noopener\">Flagd on Kubernetes: Complete Production Guide to Architecture, Implementation and Troubleshooting<\/a>\\<\/li>\n<li><a href=\"https:\/\/opstree.com\/blog\/kubernetes-events-monitoring-using-open-telemetry-and-loki\/\" target=\"_blank\" rel=\"noopener\">Kubernetes Events Monitoring using Open Telemetry And Loki<\/a><\/li>\n<li><a href=\"https:\/\/opstree.com\/blog\/kong-gateway-in-kubernetes\/\" target=\"_blank\" rel=\"noopener\">A Complete Traffic Flow Guide to Using Kong Gateway in Kubernetes<\/a><\/li>\n<\/ul>\n<h3>Related Solutions<\/h3>\n<ul>\n<li><a href=\"https:\/\/opstree.com\/services\/devops-and-devsecops-services\/\" target=\"_blank\" rel=\"noopener\">DevSecOps Automation Services<\/a><\/li>\n<li><a href=\"https:\/\/opstree.com\/services\/cloud-migration-and-modernization-services\/\" target=\"_blank\" rel=\"noopener\">Cloud Engineering Services<\/a><\/li>\n<li><a href=\"https:\/\/opstree.com\/services\/database-and-data-engineering\/\" target=\"_blank\" rel=\"noopener\">Data Engineering Services<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes\u00a0is powerful, scalable, and production-ready &#8211; but troubleshooting Kubernetes issues is often painful and time-consuming.\u00a0 A Pod suddenly enters CrashLoopBackOff, an image fails to pull, or a Deployment silently refuses to become ready. Engineers typically spend hours checking logs, events, YAML manifests, and running multiple kubectl commands just to understand what went wrong.\u00a0 Now imagine [&hellip;]<\/p>\n","protected":false},"author":244582729,"featured_media":31422,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[768739351],"tags":[768739308,768739636,768739309,768739555,343865,768739635],"class_list":["post-31401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kubernetes-2","tag-devops","tag-k8sgpt","tag-kubernetes","tag-llm","tag-technical-blog","tag-yaml"],"blocksy_meta":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2026\/05\/Untitled-design-33.png","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-8at","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/31401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/244582729"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=31401"}],"version-history":[{"count":11,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/31401\/revisions"}],"predecessor-version":[{"id":31426,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/31401\/revisions\/31426"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/31422"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=31401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=31401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=31401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}