|
| 1 | +--- |
| 2 | +sidebar_label: Security hardening |
| 3 | +sidebar_position: 50 |
| 4 | +title: Security hardening |
| 5 | +description: Harden the Kubewarden installation |
| 6 | +keywords: [kubewarden, kubernetes, security] |
| 7 | +doc-persona: [kubewarden-operator, kubewarden-integrator] |
| 8 | +doc-type: [howto] |
| 9 | +doc-topic: [operator-manual, security] |
| 10 | +--- |
| 11 | + |
| 12 | +Kubewarden strives to be secure with little configuration. |
| 13 | +In this section and its subpages you can find hardening tips (with their |
| 14 | +trade-offs) to secure Kubewarden itself. |
| 15 | + |
| 16 | +Please refer to our [threat model](../reference/threat-model) for more information. |
| 17 | + |
| 18 | +### `kubewarden-defaults` Helm chart |
| 19 | + |
| 20 | +Operators can obtain a secure deployment by installing all the |
| 21 | +Kubewarden Helm charts. It's recommended to install the |
| 22 | +`kubewarden-defaults` Helm chart and enable its recommended policies with: |
| 23 | + |
| 24 | +```console |
| 25 | +helm install --wait -n kubewarden kubewarden-defaults kubewarden/kubewarden-defaults \ |
| 26 | + --set recommendedPolicies.enabled=True \ |
| 27 | + --set recommendedPolicies.defaultPolicyMode=protect |
| 28 | +``` |
| 29 | + |
| 30 | +This provides a default PolicyServer and default policies, in protect mode, to |
| 31 | +ensure the Kubewarden stack is safe from other workloads. |
| 32 | + |
| 33 | +### Verifying Kubewarden artifacts |
| 34 | + |
| 35 | +See the [Verifying Kubewarden](../tutorials/verifying-kubewarden) tutorial. |
| 36 | + |
| 37 | +### RBAC |
| 38 | + |
| 39 | +Kubewarden describes RBAC configurations in different |
| 40 | +_Explanations_ sections. Users can fine-tune the needed permissions for the |
| 41 | +[Audit Scanner](../explanations/audit-scanner#permissions-and-serviceaccounts) |
| 42 | +feature, as well as [per Policy Server](../explanations/context-aware-policies) |
| 43 | +Service Account for the context-aware feature. |
| 44 | + |
| 45 | +The view all Roles: |
| 46 | + |
| 47 | +```console |
| 48 | +kubectl get clusterroles,roles -A | grep kubewarden |
| 49 | +``` |
| 50 | + |
| 51 | +### Per-policy permissions |
| 52 | + |
| 53 | +For context-aware policies, operators specify fine-grained permissions per |
| 54 | +policy under its `spec.contectAwareResources`, and those work in conjuction |
| 55 | +with the Service Account configured for the Policy Server where the policy |
| 56 | +runs. |
| 57 | + |
| 58 | +### Workload coverage |
| 59 | + |
| 60 | +By default, Kubewarden excludes specific Namespaces from Kubewarden coverage. This is |
| 61 | +done to simplify first-time use and interoperability with other workloads. |
| 62 | + |
| 63 | +Security-conscious operators can tune these Namespaces list via the |
| 64 | +`.global.skipNamespaces` value for both the `kubewarden-controller` and |
| 65 | +`kubewarden-defaults` Helm charts. |
| 66 | + |
| 67 | +### SecurityContexts |
| 68 | + |
| 69 | +Starting from 1.23, Kubewarden's stack is able to run in a Namespace |
| 70 | +where the [restricted |
| 71 | +Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted) |
| 72 | +are enforced, with current Pod hardening best practices. |
| 73 | + |
| 74 | +The `kubewarden-controller` Helm chart configures the SecurityContexts and |
| 75 | +exposes them in its `values.yaml`. |
| 76 | + |
| 77 | +The `kubewarden-defaults` Helm chart allows for configuing the default Policy |
| 78 | +Server `.spec.securityContexts` under `.Values.policyServer.securityContexts`. |
| 79 | + |
| 80 | +For Policy Servers managed by operators, you can configure them via their |
| 81 | +[`spec.securityContexts`](https://docs.kubewarden.io/reference/CRDs#policyserversecurity). |
0 commit comments