Skip to main content

Overview

The Formal Kubernetes Egress Agent enables applying Formal to arbitrary traffic coming from Kubernetes application containers. The Kubernetes Egress Agent operates like the Formal Endpoint but runs as a native sidecar outside of the application container instead of being installed on the host. You can then configure policies against application container traffic like you would for the Formal Endpoint.

Cluster requirements

Your cluster must meet these requirements before you run the sidecar. Verify:
The server version must be 1.29 or later.

Installation

Install the agent as a native sidecar on your application Pod. The recommended path is the Helm chart. It injects the sidecar onto labeled Pods via a MutatingAdmissionPolicy. If you already control the workload spec, you can add the sidecar to your spec instead.

Add the Formal API Key Secret

The sidecar authenticates as a Formal machine user. Create an API key for that user and store it as a Kubernetes Secret in each namespace that runs labeled Pods. The chart does not create this Secret.
1

Create a machine user

Go to Users and click Create User. Choose Machine. Give the user a name that matches the workload.
2

Create an API key

Go to API Keys and click Create API Key. Assign the key to that machine user.
3

Create the Secret

Create formal-kubernetes-egress in every namespace that will run labeled Pods. The sidecar reads FORMAL_API_KEY from the formal-api-key key.
4

Verify

The Secret must exist before you create labeled Pods in that namespace.

Deploy with Helm

The chart is published as kubernetes-egress in the Formal Helm Charts repository. The chart needs Kubernetes 1.36+ and cluster RBAC to manage MutatingAdmissionPolicy and MutatingAdmissionPolicyBinding.

Apply the inject label

The policy binding mutates Pods that have this label set to true.
Put it on the Pod template (spec.template.metadata.labels) of your Deployment, StatefulSet, DaemonSet, Job, or CronJob:
The policy mutates Pod CREATE only. Labeling an existing Pod does not inject the sidecar. Verify:
Expected output includes formal.ai/kubernetes-egress-inject=true on the workload Pods. To stop injecting, remove the label from the Pod template and roll the workload. Existing Pods keep their sidecar until you replace them.
1

Add the Formal Helm repository

2

Install the chart

The chart installs cluster-scoped admission objects only.
3

Label Pods to inject

Apply the inject label on the workload Pod template. New Pods created with that label are injected.
4

Verify

New labeled Pods include a formal-kubernetes-egress init container.
Use helm upgrade --install for every apply.

Image pull credentials

The default image is: 654654333078.dkr.ecr.us-east-1.amazonaws.com/formalco-prod-kubernetes-egress:latest On AKS, pull from GAR with azure-gar-cred. Set pullWithCredentials: true and the GAR repository:
Use ecr-cred when you pull Formal ECR images outside AWS. Do not install both credential charts in the same namespace.

Add the sidecar to your spec

If you already control the workload chart or manifests, add this native sidecar to the Pod template instead of using Formal’s Helm chart.
On each application container, mount formal-ca at /formal-ca and set the TLS trust environment variables.

TLS trust

The sidecar intercepts TLS and presents Formal’s local CA. Injection mounts /formal-ca/localca-cert.pem on every application container and sets these environment variables so common HTTP clients trust that CA. Runtimes that ignore these variables need their own trust configuration pointed at /formal-ca/localca-cert.pem. That includes Java truststores, Go binaries that embed a CA pool, and some Python clients that pin certifi (for example httpx).

Troubleshooting

Possible causes:
  • The Pod spec does not include the sidecar
  • Pod is missing formal.ai/kubernetes-egress-inject: "true"
  • The label is present with a different value
  • The label is on the Deployment or Namespace, not the Pod
  • MutatingAdmissionPolicy is not installed
Solution:
  1. Confirm the Pod spec includes formal-kubernetes-egress, or confirm the Pod label
  2. For controllers, confirm spec.template.metadata.labels
  3. Confirm the admission objects exist if you use the injector
  4. Create a new Pod. Labeling a running Pod does not inject
Possible causes:
  • Secret formal-kubernetes-egress is missing
  • Image pull failed
  • Pod Security Standard drops NET_ADMIN
Solution:
  1. Create the Secret in that namespace
  2. Confirm image pull credentials
  3. Use Privileged Pod Security, or exempt the namespace
Cause: The chart requires Kubernetes 1.36 or later.
Fix: Add the sidecar to your spec, or upgrade the control plane and reinstall the chart.
Possible causes:
  • The client ignores the injected CA environment variables
  • The client uses a bundled CA store (Java, certifi, a static Go binary)
Solution:
  1. Point the client at /formal-ca/localca-cert.pem
  2. Confirm the container has that file: kubectl exec and ls /formal-ca
  3. Restart the Pod so it picks up the current admission mutation

Next Steps

Formal Endpoint

See how the Endpoint authenticates and routes traffic

Write Policies

Control intercepted egress with Rego policies

View Logs

Search Endpoint logs for intercepted requests

Machine users

Manage the identity the sidecar authenticates as