Kubernetes has become the standard platform for running business applications, from ecommerce services to cloud-native network functions. Workloads are created, scaled and replaced every few minutes, and every container is a potential entry point for an attacker. Security scanning in the CI/CD pipeline catches known vulnerabilities before deployment, but it can’t see what happens inside a container once it’s running. 

In the world of GitOps, every change to the cluster goes through Git and a merge request, but runtime security often stays outside this process. It’s a familiar scenario: a security tool raises an alert, it waits in a queue with hundreds of others, and by the time someone confirms the threat and prepares a fix, the same misconfiguration is already running in other services. 

What if a runtime alert ended in a verified, ready-to-review merge request instead of a ticket? 

In this article, you’ll find out how an AI agent, Falco and Kyverno can turn a runtime detection into a Kubernetes policy and a hardened manifest delivered as a GitLab merge request, and which decisions in this process belong to the AI, deterministic code and the engineer. 

Advantages of integrating an AI agent into Kubernetes runtime security 

Runtime security tools like Falco watch system calls and Kubernetes audit events and ship with hundreds of rules, so detecting an attack is rarely the problem. The bottleneck is what happens after the alert. Every alert needs context: which workload it concerns, how it was deployed and whether the behavior is normal for it. A confirmed threat needs a fix that doesn’t break other services, and fixing a single running pod doesn’t stop the same insecure configuration from being deployed again with the next release. 

Large language models (LLMs) handle this middle part well. They can read an alert in context, explain it and propose a fix. By combining an AI agent with policy as code and a GitOps workflow, the agent prepares the fix, deterministic tools verify it, and an engineer approves it. 

Operational aspect Reactive approach AI-based approach 
Alert handling Every alert waits in a queue for manual analysis Alerts are filtered, enriched with Kubernetes context and assessed by AI within seconds 
Root cause Searched manually in manifests and deployment history Linked to the workload configuration that made the attack possible 
Fix preparation Designed by an engineer, often as a one-off change to the running pod Drafted as a Kyverno policy and a hardened manifest, verified against the live cluster 
Delivery Ticket, then a manual change Merge request in the GitOps repository, reviewed by an engineer 
Recurrence The same configuration can be deployed again Blocked or reported by Kyverno admission control 

Full autonomy, where an agent applies fixes in production without human approval, remains premature, mainly because of the risk of misinterpretation and the limited explainability of LLMs. That’s why the solution follows a human-in-the-loop model: the AI does the analysis and the preparation, and an engineer makes the final call. Integrating an AI agent into runtime security helps DevSecOps teams: 

Additionally, every automated and human decision is recorded in Git and in the application database, which supports compliance with regulations like NIS2 and DORA. 

CNCF projects at the core of the solution 

The solution is built almost entirely on Cloud Native Computing Foundation (CNCF) projects. Graduated projects go through security audits, have stable APIs and are widely used in production, so the AI layer sits on components that operators already trust. Both security engines, Falco and Kyverno, are CNCF graduated projects. 

Project CNCF maturity Role in the solution 
Kubernetes Graduated The protected platform. Its admission control and audit log are the enforcement and visibility points. 
Falco (with Falcosidekick and the k8saudit plugin) Graduated Runtime threat detection from system calls and Kubernetes audit events. 
Kyverno Graduated Mitigation layer: admission policies in Deny or Audit mode, and verification of every AI proposal with the Kyverno CLI. 
Helm Graduated Reproducible installation of Falco and Kyverno, with values files kept in Git. 
containerd, etcd, CoreDNS Graduated Container runtime, cluster state and service discovery underneath every workload. 

Around this core, the integration layer is simple: a Python service (FastAPI and LangGraph) with an LLM from Azure OpenAI, PostgreSQL for alerts and decisions, and GitLab for merge requests and CI/CD. 

AI agent system architecture 

The process is based on a closed feedback loop where AI acts as a “security analyst” between runtime events and the configuration repository. 

Figure 1. The closed loop: Falco detects; the AI agent triages the alert and drafts a mitigation; Kyverno verifies it; a human approves it, and CI deploys it.

Figure 1. The closed loop: Falco detects; the AI agent triages the alert and drafts a mitigation; Kyverno verifies it; a human approves it, and CI deploys it.

The key components of this solution include: 

The AI agent never writes to the cluster 

The agent’s service account is read-only. Every mitigation reaches Kubernetes through Git, a merge request approved by a human and the same pipeline that deploys everything else. 


AI-driven decision process: from runtime alert to merge request


The guiding principle is simple: the AI proposes, deterministic code verifies, and a human decides. Every step of the loop is a decision, and each one has an owner chosen by two criteria: how expensive a wrong decision would be and whether it can be checked automatically. 

Figure 2. Decision points along the loop, by owner: deterministic code, the AI model or the human reviewer.

Figure 2. Decision points along the loop, by owner: deterministic code, the AI model or the human reviewer.

Decision Owner How it’s made 
Is this event suspicious? Code (Falco rules) Upstream rules plus tuned exceptions, evaluated on the kernel event stream 
Is it worth an LLM call? Code Exceptions for platform components, deduplication and noise budget per rule and resource 
How risky is it, and how certain is the assessment? AI Risk and confidence are two separate values. Uncertain cases are escalated, high-risk ones get extra votes 
Is mitigation needed? Code Risk of at least 0.8, confidence of at least 0.7, not a likely false positive, workload outside the platform namespaces 
What is the fix? AI Kyverno validations and workload hardening, each tied to an observed attack step 
Does the fix work, and is it safe? Code (Kyverno CLI) The current workload must fail, the hardened manifest must pass and no other workload may be blocked 
Block or alert? AI proposes, code enforces Deny only when no other workload is affected. Otherwise, the AI narrows the scope or uses Audit 
Ship it? Human Merge request review, optional changes requested in comments, merge 

How does this work in practice? The main process flow follows a few repeatable steps: 

1. Detection: Falco detects suspicious behavior in a running container, for example a binary written and executed at runtime. No AI is involved in deciding what an event is. 

2. Noise filtering: Before an alert reaches the model, deterministic filters remove known benign activity of the platform itself and handle bursts of repeated alerts. This saves cost and keeps the model focused on events that need judgment. 

3. AI triage: The model assesses the alert in context. Risk and confidence are kept apart, because missing context should lower the confidence, never the risk. Ambiguous cases get a second, deeper pass and high-risk ones get additional independent votes. 

4. Mitigation gate: Only confident, high-risk alerts on application workloads qualify. Alerts from the same workload are grouped into one incident, so one attack results in one merge request. 

5. Fix generation: The agent receives the incident, the workload manifest and the list of other running workloads, and drafts a Kyverno policy together with a hardened manifest. The hardening relies on established guidelines, such as the Restricted profile of the Kubernetes Pod Security Standards and NIST SP 800-190, and every control is linked to the attack step it blocks. 

6. Verification: The Kyverno CLI checks the proposal against the live cluster. The policy must reject the workload as it runs today, accept the hardened version and, in Deny mode, block nothing else. If a check fails, the error goes back to the model, which gets up to three attempts. 

7. Merge request: The agent opens a merge request with the policy, the manifest change, the incident timeline, the reasoning, the known limitations and the verification results. 

8. Human-in-the-loop: The engineer reviews the fix and can talk to the agent in MR comments. The agent answers questions or revises the proposal, verifies it again and pushes a new commit. After approval, the engineer merges the change and the pipeline deploys it. 

Why GitOps is the right delivery path for AI mitigations 

An AI agent with write access to the cluster could apply a fix within seconds. Why is it better to go through Git? In a GitOps model, the repository is the single source of truth. A change applied directly with kubectl is invisible in the repository, disappears with the next sync and isn’t reviewed by anyone. When the agent delivers a fix as a merge request, it becomes a regular commit: 

In the test environment, a GitLab CI job applies the merged manifests. The same merge request works with pull-based GitOps controllers such as Argo CD or Flux, both graduated CNCF projects, which pick up the merged commit and reconcile the cluster. 

How it works in practice: a live test 

The whole loop was tested on a three-node Kubernetes cluster with Falco, Kyverno and Azure OpenAI. The target was demo-shop, a deliberately vulnerable service with an OS command injection flaw, deployed the way a busy developer might do it: as root, with a writable root filesystem and no security context. 

Figure 3. The merge request opened by the agent: the incident with its AI assessment and the proposed mitigation with the attack steps it blocks.

Figure 3. The merge request opened by the agent: the incident with its AI assessment and the proposed mitigation with the attack steps it blocks.

Figure 4. The rest of the description: limitations, Kyverno CLI verification results and instructions for talking to the agent.

Figure 4. The rest of the description: limitations, Kyverno CLI verification results and instructions for talking to the agent.

Review: The reviewer commented with a suggestion to set a dedicated user. About 50 seconds later, the agent extended the manifest and the policy, verified them again and pushed a new commit.

Figure 5. The reviewer’s comment and the agent’s reply with the re-verified revision.

Figure 5. The reviewer’s comment and the agent’s reply with the re-verified revision.

$ kubectl -n demo-shop run vulnerable-check --image=python:3.12-slim --dry-run=server 

Error from server: admission webhook ... denied the request: 

Pod securityContext.runAsNonRoot must be true. 

$ curl ... (same exploit) 

uid=10001 gid=10001 groups=10001 

head: cannot open '/etc/shadow' for reading: Permission denied 

cp: cannot create regular file '/tmp/kworker': Read-only file system

The code flaw itself remains and has to be fixed by developers, which the agent also stated in the merge request. The hardening limits what an attacker can do with it, and Falco raised no further alerts for the workload. 

How to measure the success of AI-driven runtime mitigation 

The value of such a solution should be verified with measurable indicators rather than general impressions. The table below shows the key metrics and the values recorded in the live test. They come from a single scenario on a test cluster, so they show what’s possible rather than an average for production environments. 

Metric What it measures Live test result 
Mean time to detect (MTTD) Time from the attack to the alert and its AI assessment Same second (risk 0.98 and 0.99) 
Time to verified fix Time from the alert to a merge request with a verified policy and manifest 1 min 45 s, first attempt 
Blast radius Number of other workloads that the policy would block 0 
Revision time Time from a reviewer’s comment to a verified commit on the MR branch About 50 s 
Recurrence Whether the vulnerable configuration can be deployed again Denied by Kyverno admission control 
Residual alerts Falco alerts for the workload after the fix, with the same exploit 0 

A production rollout should also track the false positive rate of the AI triage and the share of AI merge requests accepted without changes, because both show how much the team can trust the agent. 

Benefits of AI-driven runtime mitigation 

Traditional runtime security often ends at the alert. The solution described here shifts the burden from reporting to remedying. Along with a faster response, it offers the following benefits: 

Strengthen Kubernetes runtime security with AI 

Combined with security scanning in the CI/CD pipeline, an AI agent on the runtime side closes the DevSecOps loop. Insecure manifests are caught before deployment, and anything exploited at runtime is turned into a policy that prevents it from happening again. The agent takes over the most repetitive parts of the work: reading alerts in context, drafting policies and hardening manifests. Engineers keep the final decision on every change and can focus on tasks that need their expertise. 

If you want to find out how our DevOps and AI experts can help you protect your Kubernetes workloads with AI, get in touch with us. You’ll be able to see a demo of the agent and learn more about tailoring it to your processes. 

FAQ 

What are the key components of AI-driven runtime mitigation in Kubernetes? 

This solution involves Falco for runtime threat detection, an AI agent built with LangGraph and an LLM for triage and fix generation, Kyverno for policy enforcement and verification, and a GitOps workflow in GitLab for delivery. Falco and Kyverno are both CNCF graduated projects. 

Does the AI agent change the Kubernetes cluster on its own? 

No. The agent has read-only access to the cluster. It proposes mitigations as merge requests, an engineer reviews and merges them, and the regular CI/CD pipeline or GitOps controller deploys them. 

How do you make sure an AI-generated policy doesn’t break other services? 

Every proposal is checked with the Kyverno CLI against the live cluster before a merge request is opened. In Deny mode, the policy may not block any other running workload, and platform namespaces are always excluded. 

Can AI-generated mitigations be used with Argo CD or Flux? 

Yes. The agent only commits a policy and a manifest to Git. After the merge, any GitOps controller can reconcile the cluster from the repository, the same way it does for changes made by people.