CLI Reference
This section provides an overview of the different k8sgpt
CLI commands.
Prerequisites
- You need to be connected to a Kubernetes cluster, K8sGPT will access it through your kubeconfig.
- Signed-up to OpenAI ChatGPT
- Have the K8sGPT CLI installed
Commands
Run a scan with the default analyzers
k8sgpt generate
k8sgpt auth add
k8sgpt analyze --explain
Filter on resource
k8sgpt analyze --explain --filter=Service
Filter by namespace
k8sgpt analyze --explain --filter=Pod --namespace=default
Output to JSON
k8sgpt analyze --explain --filter=Service --output=json
Anonymize during explain
k8sgpt analyze --explain --filter=Service --output=json --anonymize
Additional commands
List configured backends
k8sgpt auth list
Remove configured backends
k8sgpt auth remove --backend $MY_BACKEND
List integrations
k8sgpt integrations list
Activate integrations
k8sgpt integrations activate [integration(s)]
Use integration
k8sgpt analyze --filter=[integration(s)]
Deactivate integrations
k8sgpt integrations deactivate [integration(s)]
Serve mode with GRPC
k8sgpt serve
Analysis with GRPC serve mode
grpcurl -plaintext localhost:8080 schema.v1.ServerService/Analyze
Serve mode with GRPC and non-default backend (amazonbedrock)
k8sgpt serve -b amazonbedrock
Analysis with GRPC serve mode and non-default backend (amazonbedrock)
grpcurl -plaintext -d '{"explain": true, "backend": "amazonbedrock"}' localhost:8080 schema.v1.ServerService/Analyze
Serve mode with REST API
k8sgpt serve --http
Analysis with REST API serve mode
curl -X POST "http://localhost:8080/v1/analyze"
Serve mode with REST API serve mode and non-default backend (amazonbedrock)
k8sgpt serve --http -b amazonbedrock
Analysis with REST API serve mode and non-default backend (amazonbedrock)
curl -X POST "http://localhost:8080/v1/analyze?explain=true&backend=amazonbedrock"