# Check pods with Kyverno

The kyverno add-on checks every pod against the Pod Security Standards, reporting first and refusing when you choose.

Replace _my-cluster_ with your cluster's name or id.

The `kyverno` add-on runs Kyverno with the Kubernetes Pod Security Standards as policies:

| `level`              | Policies | What it stops                                                                                    |
| -------------------- | -------- | ------------------------------------------------------------------------------------------------ |
| `baseline` (default) | 12       | Privileged containers, host namespaces, host paths and ports, added capabilities, unsafe sysctls |
| `restricted`         | 18       | Also: running as root, privilege escalation, missing seccomp, volume types beyond the safe ones  |

In `audit` mode (the default) a pod that breaks a policy still runs and the violation is written to
a PolicyReport in its namespace. In `enforce` mode the pod is refused. Start in audit, read the
reports, fix or exclude, then enforce.

Kubernetes' own namespaces, `kyverno`, and the namespaces of Deutsche Cloud add-ons that need
privileged pods (`opentelemetry-collector`, `velero`) are never checked; `excludeNamespaces` adds
your own.

## Install and read the reports

**Console**
1. Open **Kubernetes**, open the cluster, then choose **Add-ons**.
2. Choose **Add an add-on**, then **Policies (Kyverno)**.
3. Choose the standard and whether a violation is reported or refused.
4. Choose **Install**.

**CLI**
```sh
dcloud eks addons create my-cluster --name kyverno --config 'level="baseline"' --config 'mode="audit"'
```

**API**
```http
POST /eks/api/clusters/my-cluster/addons
{ "name": "kyverno", "config": { "level": "baseline", "mode": "audit" } }
```

**Terraform**
```hcl
resource "dcloud_eks_addon" "kyverno" {
  cluster_id = dcloud_eks_cluster.main.id
  name       = "kyverno"
  config     = jsonencode({ level = "baseline", mode = "audit" })
}
```

```sh
kubectl get policyreports -A
```

To enforce, change `mode` to `enforce` (**Change** on the add-on's row). You need
`eks:UpdateAddon`.
