> ## 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 pods pass AKS pod security and admission policies, which need an exemption, and how to make label policies admit e6data pods.

ReferenceApplies to: CloudPrem on Azure

The built-in AKS pod security baseline admits everything except the cluster log and metrics collector (on by default in e6data's install), the local NVMe setup DaemonSet (only with NAP or AKS node pools) and, when Metriq is on, its sandbox worker. These need an exemption or can be left out. With the built-in baseline initiative in Deny mode and these exemptions, all e6data services and an XS query cluster start.

## Requirements

* If monitoring is on, the log collector DaemonSet needs an exemption (hostPath `/var/log`, `/var/lib/docker/containers`; host ports 4317 and 4318).
* An exemption for the two DaemonSets below, or run without them. With e6data's Karpenter there is no NVMe DaemonSet: the node stripes its NVMe at boot.
* When Metriq is on, its sandbox worker needs a Pod Security exemption, or turn Metriq 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 | Azure | What you do |
| - | - | - |
| Pod Security `baseline` | Passes, except NVMe setup, the log collector and, when Metriq is on, its sandbox worker | Exempt them |
| Pod Security `restricted` | Workspace pod hardening is off by default (`workspacePodHardening.enabled: false`), so workspace pods fail `restricted` as installed | Turn hardening on first (below), then check with a server-side dry run |
| No privileged containers, no hostPath | NVMe setup (privileged, hostPath `/app/tmp`) and log collector (hostPath `/var/log`, `/var/lib/docker/containers`; host ports 4317/4318) blocked | Exemption |
| Allowed registries only | Workspace images follow the registry you set; the NVMe setup DaemonSet names its image directly, so change that path too | Mirror images ([Component versions and operations](https://docs.e6data.com/platform/deploy/azure-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 | Operator-created pods set them; the NVMe setup DaemonSet sets none | Add them to the NVMe setup DaemonSet, or exempt it |
| Label `app.kubernetes.io/name` required | e6data pods don't carry this label | Add the mutate policy below |
| AKS Automatic Deployment Safeguards | Coming later: needs an operator release that is not yet available | Until then, exclude the workspace namespace from safeguards |

Workspace pod hardening is off by default. Turn it on (`workspacePodHardening.enabled: true`) before you try `restricted`. With it 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. Only the operator pod itself passes `restricted`. With cluster monitoring on (the default in e6data's install), the `e6operator` namespace fails `baseline` because of the collector.

## What you lose without the Azure DaemonSets

| DaemonSet | Without it |
| - | - |
| Local NVMe disk setup | Executors get no fast local NVMe spill disk; scratch uses the node's OS disk |
| Log and metrics collector | e6data logs and metrics are not shipped for support |

The exemption can be scoped to the e6data namespaces or to the two images only.

## 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, e6data runs end to end under Kyverno 1.19.2 in Enforce mode.

```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' }}"
```

## Steps: Azure baseline exemption

1. Exempt the e6data workspace namespace, or the NVMe setup and log collector images, from the pod security baseline assignment.
2. Keep the initiative's default excluded namespaces (`kube-system`, `gatekeeper-system`, `azure-arc`, `azure-extensions-usage-system`). If your policy removes the `kube-system` exclusion, tell e6data so Karpenter can be checked.
3. Azure Policy constraints take about 142 seconds to sync after assignment. Recreate e6data pods after that.

## 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 |
| `nvme-raid-disks-<ws>` has 0 pods | Baseline blocks hostPath and privileged | Exempt it, or run without local NVMe |
| Monitoring stays `Pending` | Baseline blocks the log collector | Exempt it, or run without log shipping |
| AKS Automatic: `Avoiding the latest tag` | Image with a `latest` tag | Use the versioned tags from e6data |
| AKS Automatic: resume times out with `planner template has not converged` | Safeguards add settings to pods | Use the operator version from e6data, or exclude the namespace |

## Limitations

* NVMe setup and log collector can't run under the baseline without an exemption.
* Pod Security `restricted`: workspace pods fail it as installed. Turn on workspace pod hardening and check with a server-side dry run before you enforce it.
* 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 or use PERMISSIVE mode; STRICT mTLS inside the namespace breaks 443 and 5432. Cilium WireGuard encryption works with no change.

## See also

* [Architecture](https://docs.e6data.com/platform/deploy/azure-cloudprem/architecture.md)
* [Use an existing AKS cluster](https://docs.e6data.com/platform/deploy/azure-cloudprem/use-existing-cluster.md)
* [Kubernetes permissions](https://docs.e6data.com/platform/deploy/azure-cloudprem/kubernetes-permissions.md)
* [Security review pack](https://docs.e6data.com/platform/trust/security-review-pack.md)


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