AI-assisted Kubernetes incident investigation and remediation platform built on Google Kubernetes Engine (GKE) using FastAPI, Prometheus, Grafana, Google IAP, Kubernetes APIs, and policy-controlled remediation.
The project is designed to reduce repetitive Kubernetes troubleshooting work by collecting operational evidence, analyzing workload health, surfacing likely root causes, and recommending controlled remediation actions.
The demo covers the end-to-end flow:
Google IAP Authentication
↓
AI SRE Dashboard
↓
Platform Health
↓
Monitoring
↓
Incident Investigation
↓
Namespace / Deployment Selection
↓
Root Cause Analysis
↓
Recommended Remediation
A normal Kubernetes incident often means switching between several tools:
Alert
↓
kubectl get pods
↓
kubectl describe pod
↓
kubectl logs
↓
kubectl get events
↓
Prometheus
↓
Grafana
↓
Manual Correlation
↓
Root Cause Analysis
This project brings those signals into one investigation workflow.
Example questions:
Why is payment-api crashing?
Show unhealthy pods
Check recent errors
Which containers are restarting frequently?
The platform gathers Kubernetes context and presents a structured investigation result.
- Kubernetes workload investigation
- Dynamic namespace discovery
- Dynamic deployment discovery
- Pod health analysis
- Container restart analysis
- Kubernetes event inspection
- Prometheus integration
- Grafana integration
- Platform health dashboard
- Incident investigation interface
- Root-cause oriented output
- Google Identity-Aware Proxy protection
- Google Cloud IAM authorization
- GKE Ingress
- Google Managed HTTPS
- Kubernetes RBAC
- Human-in-the-loop remediation
- Policy-controlled auto-healing
- Sample failure workloads for testing
User
│
▼
https://<YOUR_DOMAIN>
│
▼
Google HTTPS Load Balancer
│
▼
Identity-Aware Proxy
│
▼
IAM Authorization
│
▼
GKE Ingress
│
▼
ai-sre-agent Service
│
▼
FastAPI Backend
│
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
Kubernetes Prometheus Grafana
│ │ │
└─────────────┼─────────────┘
│
▼
Incident Analysis
│
▼
Root Cause Analysis
│
▼
Recommended Remediation
│
▼
Policy-Controlled Action
| Component | Technology |
|---|---|
| Backend | FastAPI |
| Frontend | HTML, CSS, JavaScript |
| Kubernetes | Google Kubernetes Engine |
| Container Runtime | Docker |
| Monitoring | Prometheus |
| Visualization | Grafana |
| Authentication | Google Identity-Aware Proxy |
| Authorization | Google Cloud IAM |
| HTTPS | Google Managed Certificate |
| Load Balancing | GKE Ingress |
| Registry | Google Artifact Registry |
| Kubernetes Integration | Kubernetes Python Client |
| Cluster Security | Kubernetes RBAC |
ai-sre-agent-gke/
├── app/
│ ├── __init__.py
│ ├── agent.py
│ ├── main.py
│ ├── remediation/
│ │ ├── __init__.py
│ │ ├── executor.py
│ │ ├── planner.py
│ │ ├── policies.py
│ │ └── verifier.py
│ ├── static/
│ │ ├── app.js
│ │ └── style.css
│ ├── templates/
│ │ ├── index.html
│ │ └── login.html
│ └── tools/
│ ├── __init__.py
│ └── kubernetes_tools.py
│
├── docs/
│ └── demo/
│ ├── ai-sre-demo.gif
│ ├── iap.png
│ ├── investigate.png
│ ├── login.png
│ ├── monitoring.png
│ ├── overview.png
│ ├── result-1.png
│ └── result-2.png
│
├── incident-app/
│ ├── crashloop-demo.yaml
│ ├── imagepull-demo.yaml
│ ├── payment-api-crash.yaml
│ └── pending-demo.yaml
│
├── k8s/
│ ├── ai-sre-agent-deployment.yaml
│ ├── ai-sre-agent-service.yaml
│ ├── ai-sre-backendconfig.yaml
│ ├── ai-sre-ingress.yaml
│ ├── managed-certificate.yaml
│ ├── rbac.yaml
│ └── serviceaccount.yaml
│
├── monitoring/
│ └── prometheus-values.yaml
│
├── .dockerignore
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
└── requirements.txt
You will need:
- Google Cloud project
- GKE cluster
- Artifact Registry repository
gcloudkubectl- Docker
- Helm
- Python 3
- DNS hostname
- Google OAuth client for IAP
- Prometheus and Grafana
Authenticate:
gcloud auth loginSet your project:
gcloud config set project <PROJECT_ID>Verify cluster access:
kubectl get nodesIf you are building from an Apple Silicon Mac and your GKE nodes use AMD64:
docker buildx build \
--platform linux/amd64 \
-t <REGION>-docker.pkg.dev/<PROJECT_ID>/<REPOSITORY>/ai-sre-agent:v1 \
--push .Apply the ServiceAccount:
kubectl apply -f k8s/serviceaccount.yamlApply RBAC:
kubectl apply -f k8s/rbac.yamlDeploy the application:
kubectl apply -f k8s/ai-sre-agent-deployment.yamlApply the Service:
kubectl apply -f k8s/ai-sre-agent-service.yamlCheck status:
kubectl get pods -n ai-sre
kubectl get svc -n ai-sreRestart when required:
kubectl rollout restart deployment ai-sre-agent -n ai-sre
kubectl rollout status deployment ai-sre-agent -n ai-sreThe AI SRE Agent uses a dedicated Kubernetes ServiceAccount.
Verify the ServiceAccount used by the deployment:
kubectl get deployment ai-sre-agent \
-n ai-sre \
-o jsonpath='{.spec.template.spec.serviceAccountName}'
echoVerify in-cluster Kubernetes access:
kubectl exec -n ai-sre deployment/ai-sre-agent -- \
python -c '
from kubernetes import client, config
config.load_incluster_config()
v1 = client.CoreV1Api()
print([n.metadata.name for n in v1.list_namespace().items])
'Typical read permissions include:
namespaces
pods
pods/log
events
services
endpoints
deployments
replicasets
Write permissions should be limited to explicitly approved remediation actions.
This project uses the open-source kube-prometheus-stack.
Add the Helm repository:
helm repo add prometheus-community \
https://prometheus-community.github.io/helm-chartsUpdate:
helm repo updateCreate the monitoring namespace:
kubectl create namespace monitoringInstall:
helm install monitoring \
prometheus-community/kube-prometheus-stack \
-n monitoring \
-f monitoring/prometheus-values.yamlCheck services:
kubectl get svc -n monitoringExample internal Prometheus endpoint:
http://monitoring-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090
The investigation flow allows an engineer to:
- Select a namespace
- Select a deployment
- Enter an investigation question
- Collect Kubernetes evidence
- Review the generated analysis
- Review remediation recommendations
Example questions:
Why is payment-api crashing?
Show unhealthy pods
Check recent errors
The workflow can inspect:
Pod state
Container state
Restart count
Readiness
Kubernetes events
Deployment state
Sample workloads are included under:
incident-app/
Examples:
crashloop-demo.yaml
imagepull-demo.yaml
payment-api-crash.yaml
pending-demo.yaml
Deploy one:
kubectl apply -f incident-app/payment-api-crash.yamlCheck:
kubectl get pods -n ai-sreThese manifests help reproduce common failure scenarios such as:
CrashLoopBackOff
ImagePullBackOff
Pending
Apply the Ingress:
kubectl apply -f k8s/ai-sre-ingress.yamlCheck:
kubectl describe ingress ai-sre-ingress -n ai-sreTraffic path:
Internet
↓
Google HTTPS Load Balancer
↓
GKE Ingress
↓
ClusterIP Service
↓
FastAPI Pod
Create:
gcloud compute addresses create ai-sre-static-ip \
--globalRetrieve:
gcloud compute addresses describe ai-sre-static-ip \
--global \
--format="get(address)"Point your DNS record to this IP.
Example:
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: ai-sre-cert
namespace: ai-sre
spec:
domains:
- <YOUR_DOMAIN>Apply:
kubectl apply -f k8s/managed-certificate.yamlCheck:
kubectl describe managedcertificate ai-sre-cert -n ai-sreWait for:
CertificateStatus: Active
The portal is protected using Google Cloud IAP.
Internet
↓
HTTPS Load Balancer
↓
Google IAP
↓
IAM Authorization
↓
GKE Backend
Example BackendConfig:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: ai-sre-backendconfig
namespace: ai-sre
spec:
iap:
enabled: true
oauthclientCredentials:
secretName: ai-sre-authApply:
kubectl apply -f k8s/ai-sre-backendconfig.yamlList GKE-created backend services:
gcloud compute backend-services list --globalDo not commit OAuth credentials to GitHub.
Create or patch the Kubernetes Secret at deployment time:
kubectl patch secret ai-sre-auth \
-n ai-sre \
--type merge \
-p='{
"stringData": {
"client_id": "<GOOGLE_CLIENT_ID>",
"client_secret": "<GOOGLE_CLIENT_SECRET>"
}
}'For IAP using a custom OAuth client, configure this callback under Authorized redirect URIs:
https://iap.googleapis.com/v1/oauth/clientIds/<CLIENT_ID>:handleRedirect
Grant access only to required users:
gcloud projects add-iam-policy-binding \
<PROJECT_ID> \
--member="user:<AUTHORIZED_USER>" \
--role="roles/iap.httpsResourceAccessor"Detect
↓
Collect
↓
Correlate
↓
Reason
↓
Recommend
↓
Remediate
↓
Verify
Evidence can come from:
Kubernetes API
Prometheus
Grafana
Events
Logs
Container Status
Deployment State
The project follows a human-in-the-loop remediation model.
Incident Detected
↓
Evidence Collected
↓
Root Cause Identified
↓
Risk Classification
↓
Remediation Proposed
↓
Human Approval
↓
Execute Action
↓
Verify Recovery
A low-risk action might be:
Rollout Restart
A configuration issue such as:
DATABASE_URL missing
should not be blindly restarted.
Instead, it should be classified as:
Configuration Fix Required
Auto-Heal Eligible: NO
Never commit:
OAuth client secrets
API keys
DNS provider tokens
service-account keys
kubeconfig files
session secrets
private certificates
personal credentials
Prefer:
Kubernetes Secrets
Google Secret Manager
Workload Identity
Environment Variables
- MCP-based Kubernetes tools
- Prometheus query integration
- Grafana / Loki correlation
- Kubernetes event timeline
- Deployment history analysis
- LLM-assisted RCA
- Risk-scored remediation
- Human approval workflow
- Automated recovery verification
- Incident audit trail
- Multi-cluster support
- Alert-driven investigation
- Slack / Teams integration
The goal is not to give an AI unrestricted Kubernetes access.
The approach is:
AI for investigation
+
Policies for control
+
Humans for approval
+
Automation for execution
+
Observability for verification
The engineer remains in control.
This project is intended for learning, experimentation, and controlled environments.
Do not enable automated remediation in production without:
- proper RBAC
- policy controls
- approval mechanisms
- audit logging
- rollback procedures
- validation
- testing
If you find the project useful, consider starring the repository.
