An AI agent that can merge code, restart a deployment, or call a cloud API is closer to a new staff account than to a script. It holds credentials, acts without waiting for a person, and can spend money at the speed of its retry loop. If you are building DevOps to lower costs, that matters twice: a permission mistake can cause an outage, and an over-scoped agent can keep launching work you pay for.
Thirty minutes will not produce a perfect security review. It will produce a decision: deploy as proposed, deploy with named changes, or hold. Write that decision down and give it an owner.
Treat the agent as three things: an identity, a set of runtime permissions, and a budget.
The identity is what it authenticates as. In Kubernetes, a Pod that does not name a service account gets the namespace’s default account, with credentials mounted automatically. The guide to configuring service accounts for Pods shows how to opt out with automountServiceAccountToken: false and how projected tokens carry a chosen audience and a bounded lifetime; it recommends TokenRequest-based tokens over manually created token Secrets. If your agent never calls the API server, it should not carry an API token.
Runtime permissions come next. The Kubernetes RBAC documentation states that permissions are additive, with no deny rules. A Role is namespaced; a ClusterRole can span namespaces or cluster-scoped resources. Wildcards are risky because resources: ["*"] also grants access to resource types added later. resourceNames can narrow a rule to named objects, though top-level create requests cannot be limited that way. The docs note that the built-in edit role can read Secrets and run Pods as any service account in the namespace, which is reason enough not to hand broad default roles to automation.
The third layer is reach and spend. Network access, node privileges, and quotas sit outside RBAC. An agent with a tidy Role can still call a payment API from a Pod if egress is open.
Write down every non-human identity in this release: CI jobs, controllers, scheduled jobs, agent SDK processes. For each, record a human owner, namespace, and the exact action it must perform. If you cannot name an owner, stop. An unowned identity is a blocker, because nobody will rotate its credentials or answer for its changes.
Confirm each workload names its own service account, not default, and ask whether it needs API access. If not, set automountServiceAccountToken: false. If it does, use a projected token with a short lifetime and an audience matching the consumer. The Kubernetes docs show expirationSeconds: 7200 for a two-hour token and note that the kubelet rotates it; your application must reload the file. Look for hard-coded tokens in environment variables, ConfigMaps, or image layers. A manually created token Secret needs a stated reason.
Do not trust the manifest alone. Ask the API server:
kubectl auth can-i --list --as=system:serviceaccount:prod:deploy-agent
kubectl get rolebindings,clusterrolebindings -A -o wide
Compare the output to the first list. Anything extra is a decision, not a detail. Watch cluster-wide bindings, secrets, pods/exec, and verbs such as deletecollection. If a rule uses a wildcard, require a written reason. The RBAC docs warn that wildcards also grant access to future resource types, so a harmless-looking rule can widen after a cluster upgrade.
Check the Pod cage. Kubernetes Pod Security Standards define Privileged, Baseline, and Restricted. Baseline blocks known privilege escalations such as host namespaces and privileged containers; Restricted adds non-root execution, dropping all Linux capabilities, and a seccomp profile. Aim for Restricted; log exceptions. Then check network rules. The NetworkPolicy documentation states that Pods are non-isolated by default, policies are additive, and the CNI plugin must enforce them. Default-deny egress also blocks DNS, so allow DNS explicitly if needed. Confirm the agent reaches only the services and endpoints on its action list.
Set a maximum spend for one agent run and decide where it is enforced. In Kubernetes that can mean resource quotas and per-namespace limits on pods, CPU, and memory. At the application layer it means caps on retries, concurrency, and paid API calls, plus a time-to-live for temporary jobs. Write the pause trigger: repeated failed deployments, an unexpected spend threshold, or an action outside the approved list. Name the person who can disable the credential and check that revoking it takes effect quickly. Finish with deploy, deploy with listed changes, or hold. Record the date and reviewer.
Every restriction has a price. See it before approving.
Least privilege costs engineer time. A narrow Role fails the first time the agent tries an action you forgot to list. That failure is useful, but it lands during someone’s afternoon. A shared admin credential avoids the interruption and makes incidents harder to attribute. A workable middle ground is one identity per agent, a narrow Role for routine work, and a manual path for rare privileged actions.
Restricted Pod settings and default-deny egress can break legitimate tooling. Image pulls, DNS, metrics endpoints, and a registry proxy need explicit allowances. The Kubernetes docs are clear that deny-all egress blocks DNS until you add a rule. Budget an hour or two for that wiring on a new cluster, then keep it in version control so the next agent inherits it.
Short-lived tokens are safer but need code. The kubelet refreshes a projected token; your application has to reload it. A long-lived token keeps an integration simple and gives anyone who copies it a credential with no expiry. Choose short-lived unless the integration cannot change, and document why.
Human approval slows a pipeline. Approving every deployment removes the main reason to run an agent. Approving only production changes, new infrastructure, or spend above a set figure keeps most of the speed and puts a person where risk is highest. Set the threshold against what a bad action would cost you, not a number copied from someone else’s policy.
A 30-minute audit is a sample, not a proof. It catches obvious privilege, missing owners, and open network paths. It will not find a subtle flaw in an agent’s reasoning or a compromised dependency. Schedule a deeper review after a material change to the agent’s code or permissions.
Permission work is often framed as security spending. It is also cost control. An agent with write access to your cluster can scale a deployment, spawn Jobs, or leave failed retries running. Each shows up on the bill. Quotas and time-to-live rules cap the blast radius; narrow RBAC reduces the expensive actions available in the first place.
The audit costs half an hour plus fixes. The recurring cost is usually exception lists: a role that grows with every new action, a network rule opened for a one-off task, a token that never got rotated. Give each exception an expiry date and delete it when the date passes.
Read access still has consequences. Kubernetes RBAC treats reading Secrets as an escalation path because Secret contents can include service account credentials. Use the same identity and owner checks, then decide whether read-only access to production data is acceptable for your business.
You can inspect your own namespace with kubectl auth can-i --list and read your own manifests. Checking cluster role bindings, audit configuration, and CNI enforcement needs wider rights. If nobody on the team has them, treat that as a gap to close before production.
Repeat the short check whenever the agent’s permissions, service account, or network rules change. Add a longer review when the agent gains a new category of action, such as creating infrastructure or calling a paid API.
Yes, if you want to answer “which identity did this?” from an audit log. One account per agent also lets you revoke one integration without stopping the others. The extra objects are cheap; the clarity is not.
No. A very short lifetime increases refresh traffic and can break a consumer that does not reload tokens. Match the lifetime to how quickly you need a revoked token to stop working, and make sure the consumer handles rotation.
If you want help turning this into a repeatable gate for your team, talk to Kubeify. Bring your current checklist and we will work through the gaps with you.
Kubeify's team decrease the time it takes to adopt open source technology while enabling consistent application environments across deployments... letting our developers focus on application code while improving speed and quality of our releases.
– Yaron Oren, Founder Maverick.ai (acquired by OutboundWorks)
Let us know what you are working on?
We would help you to build a
fault tolerant, secure and scalable system over kubernetes.