Rook has the ability to encrypt OSDs of clusters running on PVC via the flag (`encrypted: true`) in your `storageClassDeviceSets` [template](#pvc-based-cluster).
By default, the Key Encryption Keys (also known as Data Encryption Keys) are stored in a Kubernetes Secret.
The `security` section contains settings related to encryption of the cluster.
*`security`:
*`kms`: Key Management System settings
*`connectionDetails`: the list of parameters representing kms connection details
*`tokenSecretName`: the name of the Kubernetes Secret containing the kms authentication token
Supported KMS providers:
* [Vault](#vault)
## Vault
Rook supports storing OSD encryption keys in [HashiCorp Vault KMS](https://www.vaultproject.io/).
### Authentication methods
Rook support two authentication methods:
* [token-based](#token-based-authentication): a token is provided by the user and is stored in a Kubernetes Secret. It's used to
authenticate the KMS by the Rook operator. This has several pitfalls such as:
* when the token expires it must be renewed, so the secret holding it must be updated
* no token automatic rotation
* [Kubernetes Service Account](#kubernetes-based-authentication) uses [Vault Kubernetes native
authentication](https://www.vaultproject.io/docs/auth/kubernetes) mechanism and alleviate some of the limitations from the token authentication such as token automatic renewal. This method is
generally recommended over the token-based authentication.
#### Token-based authentication
When using the token-based authentication, a Kubernetes Secret must be created to hold the token.
This is governed by the `tokenSecretName` parameter.
Note: Rook supports **all** the Vault [environment variables](https://www.vaultproject.io/docs/commands#environment-variables).
The Kubernetes Secret `rook-vault-token` should contain:
```yaml
apiVersion:v1
kind:Secret
metadata:
name:rook-vault-token
namespace:rook-ceph
data:
token:<TOKEN># base64 of a token to connect to Vault, for example: cy5GWXpsbzAyY2duVGVoRjhkWG5Bb3EyWjkK
```
You can create a token in Vault by running the following command:
```console
vault token create -policy=rook
```
Refer to the official vault document for more details on [how to create a
token](https://www.vaultproject.io/docs/commands/token/create). For which policy to apply see the
next section.
In order for Rook to connect to Vault, you must configure the following in your `CephCluster` template:
```yaml
security:
kms:
# name of the k8s config map containing all the kms connection details