> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pod security and admission policies

> Which e6data workloads pass Kubernetes Pod Security baseline and restricted, which need an exemption, and how to run e6data under your admission policies on EKS.

ReferenceApplies to: CloudPrem on AWS

The core e6data workloads pass Kubernetes Pod Security `restricted` once you turn on e6data pod hardening. Exceptions: the cluster log and metrics collector (on by default in e6data's install) and the optional Metriq sandbox worker. The usage stack, Copilot, Metriq and Tessellate were not checked. Pod Security `restricted` and Kyverno in Enforce mode work end to end with the steps below.

## Requirements

* Turn on e6data pod hardening before you enforce `restricted`.
* If cluster monitoring is on (the default in e6data's install), the collector DaemonSet `otelcol-unified` in `e6operator` needs an exemption: it fails `baseline` (hostPath `/var/log`; host ports 4317 and 4318).
* The optional Metriq sandbox worker fails `baseline` even with hardening on. It needs a Pod Security exemption, or turn it off.
* Keep `kube-system` excluded from your policies. The e6data node scaler (Karpenter) runs there.
* If your policies require the label `app.kubernetes.io/name` on every pod, add a mutate policy (below).

## What passes

| Policy | AWS | What you do |
| - | - | - |
| Pod Security `baseline` | Passes with cluster monitoring off. The collector uses hostPath and host ports, and the Metriq sandbox worker needs extra privileges | Exempt the collector and, if used, the Metriq sandbox worker |
| Pod Security `restricted` | Passes with hardening on | Steps below |
| No privileged containers, no hostPath | Passes, except the cluster collector (hostPath, host ports 4317/4318) and the Metriq sandbox worker | Exempt them |
| Usage stack, Copilot, Metriq, Tessellate | Not checked | Dry run them before you enforce |
| Allowed registries only | Passes with images mirrored to your registry | Mirror images ([Component versions and operations](https://docs.e6data.com/platform/deploy/aws-cloudprem/component-versions-and-operations.md) lists the images) |
| No `latest` tag | Fails | The Metriq sandbox image defaults to `latest`. Pin it to a versioned tag in your values; all other images use the versioned tags e6data provides |
| CPU and memory requests and limits required | Passes. Every e6data container sets them | Nothing |
| Label `app.kubernetes.io/name` required | Fails for metadata services, planner, queue and executor | Add the mutate policy below |

With e6data pod hardening on, every workspace pod runs as non-root with a read-only root filesystem, all capabilities dropped, privilege escalation off and the `RuntimeDefault` seccomp profile. The operator namespace passes `restricted` with cluster monitoring off. With it on (the default), exempt `otelcol-unified` in `e6operator`.

## Steps: Pod Security `restricted`

1. Turn on e6data pod hardening:

   ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
   kubectl -n <WORKSPACE_NAME> patch namespaceconfig <WORKSPACE_NAME>-nsc \
     --type merge -p '{"spec":{"podSecurityHardening":true}}'
   ```

   The workspace chart doesn't expose this setting yet. Use the patch above, or the operator-wide `E6_POD_SECURITY_HARDENING` setting, and check it is still set after a reinstall.
2. Restart the workspace deployments, and suspend and resume any running clusters, so pods pick up the setting.
3. Enforce:

   ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
   kubectl label --overwrite ns <WORKSPACE_NAME> pod-security.kubernetes.io/enforce=restricted
   ```

> [!WARNING]
>
> Turn on hardening before you enforce `restricted`. Pods created earlier stay non-compliant, and a recreated pod is then rejected.

## Steps: Kyverno or Gatekeeper label policy

If a policy requires `app.kubernetes.io/name`, the resume starts, the policy rejects the planner, queue and executor pods, and e6data rolls the cluster back to Suspended. Running pods are not affected. Add a mutate policy, scoped to the e6data namespaces, that copies e6data's own `component` or `app` label into `app.kubernetes.io/name`. Mutation runs before validation, so the pods pass. With this policy, Kyverno 1.19.2 in Enforce mode works end to end.

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata: {name: e6data-add-app-name-label}
spec:
  background: false
  rules:
  - name: add-app-name
    match:
      any:
      - resources:
          kinds: [Pod]
          namespaces: [<WORKSPACE_NAME>, e6operator]
    mutate:
      patchStrategicMerge:
        metadata:
          labels:
            +(app.kubernetes.io/name): "{{ request.object.metadata.labels.component || request.object.metadata.labels.app || 'e6data' }}"
```

## Preflight check

Run a server-side dry run. It shows which policy blocks which pod, without changing anything.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
kubectl label --dry-run=server --overwrite ns <WORKSPACE_NAME> pod-security.kubernetes.io/enforce=restricted
# no "violate" warnings means every running pod passes
kubectl get pod <pod> -n <WORKSPACE_NAME> -o yaml | kubectl create --dry-run=server -f -
```

## Verify

1. Resume a cluster from the e6data console. It reaches **Running**.
2. Run a query and check it appears in **Query History**.
3. `kubectl get events -n <WORKSPACE_NAME> | grep -i FailedCreate` returns nothing.

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| Cluster resume rolls back to Suspended; `FailedCreate` on planner, queue or executor | A label or security policy rejects the pods | Dry run the pod specs; add the mutate policy or hardening |

## Limitations

* A specific user or group ID required by your policy: ask e6data for the supported settings.
* Putting the workspace namespace inside an Istio mesh: refused by Pod Security `restricted`. Exclude e6data namespaces from the mesh.

## See also

* [Architecture](https://docs.e6data.com/platform/deploy/aws-cloudprem/architecture.md) - what e6data installs in your cluster.
* [Use an existing EKS cluster](https://docs.e6data.com/platform/deploy/aws-cloudprem/use-existing-cluster.md) - share the cluster with other teams.
* [Security review pack](https://docs.e6data.com/platform/trust/security-review-pack.md) - material for your security review.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.