|
| 1 | +--- |
| 2 | +categories: |
| 3 | +- docs |
| 4 | +- operate |
| 5 | +- kubernetes |
| 6 | +description: Enable adding additional capabilities to the security context for the Redis Enterprise container by editing the `allowPrivilegeEscalation` field in the REC. |
| 7 | +linkTitle: Enable privileged mode |
| 8 | +title: Enable privileged mode |
| 9 | +weight: 98 |
| 10 | +--- |
| 11 | + |
| 12 | +[Security settings for Kubernetes pods](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) are configured in the [`SecurityContext`](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#securitycontext-v1-core). The `allowPrivilegeEscalation` field controls if a container can gain more privileges than its parent process. |
| 13 | + |
| 14 | +If `allowPrivilegeEscalation` is set to `true` the container can have additional [Linux capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) (such as `SYS_RESOURCE`) and is considered to be running in **privileged mode**. |
| 15 | + |
| 16 | +Redis Enterprise for Kubernetes 7.22.0-6 introduces the ability to run in **unprivileged mode**, where all capabilities are dropped from the Redis Enterprise container and `allowPrivilegeEscalation` is set to `false`. All other security-related settings remain the same as in privileged mode. Unprivileged mode is the default for installations and upgrades of the Redis Enterprise operator for versions 7.22.0-6 and later. |
| 17 | + |
| 18 | +## Default behavior |
| 19 | + |
| 20 | +**Unprivileged mode** is the default for installations and upgrades of the Redis Enterprise operator for versions 7.22.0-6 and later. This default behavior is in effect if REC spec has `allowAutoAdjustment` set to `false` or removed. |
| 21 | + |
| 22 | +The REC security context will look like this in unprivileged mode: |
| 23 | + |
| 24 | +```yaml |
| 25 | +securityContext: |
| 26 | + allowPrivilegeEscalation: false |
| 27 | + capabilities: |
| 28 | + drop: |
| 29 | + - ALL |
| 30 | + privileged: false |
| 31 | + readOnlyRootFilesystem: false |
| 32 | +``` |
| 33 | +
|
| 34 | +## Enable privileged mode |
| 35 | +
|
| 36 | +To allow the Redis Enterprise container additional capabilities, you can enable **privileged mode**. Note that changing the following value on a running cluster will trigger a rolling update. |
| 37 | +
|
| 38 | +To enable **privileged mode**, set `allowAutoAdjustment` to `true`. |
| 39 | + |
| 40 | +```yaml |
| 41 | +spec: |
| 42 | + securityContext: |
| 43 | + resourceLimits: |
| 44 | + allowAutoAdjustment: true |
| 45 | +``` |
| 46 | + |
| 47 | +In privileged mode, the security context should look like this: |
| 48 | + |
| 49 | +```yaml |
| 50 | +securityContext: |
| 51 | + allowPrivilegeEscalation: true |
| 52 | + capabilities: |
| 53 | + add: |
| 54 | + - SYS_RESOURCE |
| 55 | + drop: |
| 56 | + - ALL |
| 57 | + privileged: false |
| 58 | + readOnlyRootFilesystem: false |
| 59 | +``` |
| 60 | + |
| 61 | +OpenShift users upgrading to 7.22.0-6 need to make changes to your existing SCC (security context constraint). |
| 62 | + |
| 63 | +## OpenShift Upgrades |
| 64 | + |
| 65 | +If running in **unprivileged mode**, remove the custom `redis-enterprise-scc-v2` and disconnect it from the REC service account after completing your upgrade. |
| 66 | + |
| 67 | +If running in **privileged mode**, manually reapply the [security context constraints (SCC)](https://docs.openshift.com/container-platform/4.8/authentication/managing-security-context-constraints.html) file ([`scc.yaml`]({{< relref "/operate/kubernetes/deployment/openshift/openshift-cli#deploy-the-operator" >}})) and bind it to your service account. |
| 68 | + |
| 69 | +```sh |
| 70 | +oc apply -f openshift/scc.yaml |
| 71 | +``` |
| 72 | + |
| 73 | +```sh |
| 74 | +oc adm policy add-scc-to-user redis-enterprise-scc-v2 \ |
| 75 | + system:serviceaccount:<my-project>:<rec-name> |
| 76 | +``` |
| 77 | + |
| 78 | +## New OpenShift installations |
| 79 | + |
| 80 | +New installations of Redis Enterprise for Kubernetes 7.22.0-6 and later automatically run in **unprivileged mode**, using a built-in `nonroot-v2-SCC` which is less permissive and more secure. |
| 81 | + |
| 82 | +To enable **privileged mode** after installation, apply and grant permissions to the `redis-enterprise-scc-v2` SCC. |
| 83 | + |
| 84 | +1. Apply the file `scc.yaml` file. |
| 85 | + |
| 86 | + {{<warning>}} |
| 87 | +Do not edit this file. |
| 88 | + {{</warning>}} |
| 89 | + |
| 90 | + ```sh |
| 91 | + oc apply -f openshift/scc.yaml |
| 92 | + ``` |
| 93 | + |
| 94 | + You should receive the following response: |
| 95 | + |
| 96 | + ```sh |
| 97 | + securitycontextconstraints.security.openshift.io "redis-enterprise-scc-v2" configured |
| 98 | + ``` |
| 99 | + |
| 100 | +1. Provide the operator permissions for the pods. |
| 101 | + |
| 102 | + ```sh |
| 103 | + oc adm policy add-scc-to-user redis-enterprise-scc-v2 \ |
| 104 | + system:serviceaccount:<my-project>:<rec> |
| 105 | + ``` |
| 106 | + |
| 107 | +## SYS_RESOURCE |
| 108 | + |
| 109 | +The `SYS_RESOURCE` capability may be required if processes in the container need to raise resource limits, such as the maximum number of open file descriptors. |
| 110 | + |
| 111 | +Some Redis Enterprise processes require the ability to open at least 100,000 file descriptors. If the default limit is lower and the container lacks the `SYS_RESOURCE` capability, the process may fail repeatedly, rendering the cluster unusable. To use unprivileged mode, configure your Kubernetes worker nodes to ensure a default file descriptor limit of at least 100,000. |
| 112 | + |
| 113 | +If you are already running a Redis Enterprise Cluster on Kubernetes, your worker nodes are likely configured correctly. In this case, it is safe to upgrade the operator and use unprivileged mode. |
| 114 | + |
| 115 | +Based on our testing, all major cloud providers configure Kubernetes worker nodes with file descriptor limits well above the required minimum. These setups are compatible with unprivileged mode. The only known exception is clusters created with [Kubespray](hhttps://kubespray.io/#/), which sets default file descriptor limits below the required 100,000. If you use Kubespray with default settings, you must run the operator in privileged mode. |
| 116 | + |
0 commit comments