Join our Discord Server
Tanvir Kour Tanvir Kour is a passionate technical blogger and open source enthusiast. She is a graduate in Computer Science and Engineering and has 4 years of experience in providing IT solutions. She is well-versed with Linux, Docker and Cloud-Native application. You can connect to her via Twitter https://x.com/tanvirkour

K8sGPT CheatSheet 2025

1 min read

K8sGPT is an AI-powered diagnostic tool for Kubernetes clusters that helps identify and solve issues using natural language processing. This cheatsheet provides a quick reference for common K8sGPT commands and operations.

Installation

MethodCommand
Homebrewbrew tap k8sgpt-ai/k8sgpt && brew install k8sgpt
BinaryDownload from GitHub Releases
Krewkubectl krew install k8sgpt
Gogo install github.com/k8sgpt-ai/k8sgpt@latest

Basic Commands

OperationCommandDescription
Versionk8sgpt versionDisplay the current version of K8sGPT
Helpk8sgpt --helpShow help information
Authenticationk8sgpt authConfigure authentication for AI providers
Analyzek8sgpt analyzeRun analysis on your Kubernetes cluster
Listk8sgpt listList all analyses that have been performed
Servek8sgpt serveStart K8sGPT in server mode
Filtersk8sgpt filtersShow and manage resource filters

Configuration

OperationCommandDescription
Configure Providerk8sgpt auth --provider <provider>Set the AI provider (openai, azure, etc.)
Set API keyk8sgpt auth --apikey <your-api-key>Configure your AI provider API key
Set Modelk8sgpt auth --model <model-name>Set the AI model to use
Configure Contextk8sgpt auth --context <context-name>Set the Kubernetes context

Analysis Options

OperationCommandDescription
Basic Analysisk8sgpt analyzeRun analysis on all resources
Filter by Namespacek8sgpt analyze --namespace <ns>Analyze resources in specific namespace
Filter by Kindk8sgpt analyze --filter <kind>Analyze only specific resource types
Specify Kubeconfigk8sgpt analyze --kubeconfig <path>Use specific kubeconfig file
Set Severityk8sgpt analyze --threshold <num>Filter by minimum severity (0-10)
Generate YAMLk8sgpt analyze --explain yamlGenerate explanation in YAML format
Generate JSONk8sgpt analyze --explain jsonGenerate explanation in JSON format
Cache Resultsk8sgpt analyze --cacheEnable caching of results
Max Resultsk8sgpt analyze --max-results <num>Limit number of results

Filter Management

OperationCommandDescription
List Filtersk8sgpt filters listShow all active filters
Add Filterk8sgpt filters add <kind>Add resource kind to filter list
Remove Filterk8sgpt filters remove <kind>Remove resource kind from filter list
Reset Filtersk8sgpt filters resetReset all filters to default

Integration Options

IntegrationCommand/ReferenceDescription
Kubectl Pluginkubectl k8sgpt analyzeUse as kubectl plugin
Kubernetes Operatork8sgpt-operatorDeploy as an operator
Prometheus Integrationk8sgpt serve --metricsExpose Prometheus metrics
Slack IntegrationConfigure via .k8sgpt.yamlSend results to Slack

Example Workflows

TaskCommand SequenceDescription
Quick Troubleshootingk8sgpt analyzeRun a full cluster analysis
Focused Analysisk8sgpt analyze --filter Pod --namespace appAnalyze only Pods in the app namespace
Continuous Monitoringk8sgpt serveRun in server mode for continuous analysis
CI/CD Integrationk8sgpt analyze --explain json --output file.jsonGenerate machine-readable output for CI/CD

Advanced Configuration (.k8sgpt.yaml)

ai:
  provider: openai
  model: gpt-4
  apikey: your-api-key-here
  backend: http://localhost:8080
  temperature: 0.7
filters:
  - Pod
  - Deployment
  - StatefulSet
kubernetes:
  context: my-cluster-context
  kubeconfig: /path/to/kubeconfig

Supported Resource Kinds

CategoryResource Kinds
WorkloadsPod, Deployment, StatefulSet, DaemonSet, ReplicaSet, Job, CronJob
ServicesService, Ingress, NetworkPolicy
ConfigConfigMap, Secret, HorizontalPodAutoscaler
StoragePersistentVolume, PersistentVolumeClaim, StorageClass
RBACRole, RoleBinding, ClusterRole, ClusterRoleBinding, ServiceAccount
CustomCustomResourceDefinition, plus most custom resources

Tips and Best Practices

  • Start with a broad analysis and then narrow down with filters
  • Use the –explain yaml option for sharing analysis results with team members
  • Configure multiple AI providers as fallbacks
  • Set appropriate severity thresholds for your environment
  • Integrate with monitoring tools for continuous analysis

Have Queries? Join https://launchpass.com/collabnix

Tanvir Kour Tanvir Kour is a passionate technical blogger and open source enthusiast. She is a graduate in Computer Science and Engineering and has 4 years of experience in providing IT solutions. She is well-versed with Linux, Docker and Cloud-Native application. You can connect to her via Twitter https://x.com/tanvirkour
Join our Discord Server
Index