> For the complete documentation index, see [llms.txt](https://vault.koudingspawn.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vault.koudingspawn.de/supported-secret-types/secret-type-keyvaluev2.md).

# Secret Type - KEYVALUEV2

The KEYVALUEV2-Type is made for synchronising Secrets stored in the new KV2 Secret Engine with Kubernetes Secrets.

### How To

First write some secrets to HashiCorp Vault:

```bash
$ vault kv put versioned/example key=value
```

After this create the following Vault-Resource and apply it to Kubernetes:

```yaml
apiVersion: "koudingspawn.de/v1"
kind: Vault
metadata:
  name: versionedsecret
spec:
  path: "versioned/example"
  type: "KEYVALUEV2"
  versionConfiguration:
    version: 1
```

Now you should see, the new Secret and the Vault resource are available:

```
$ kubectl get vault versionedsecret
NAME                 AGE
versionedsecret      10m
```

```bash
$ kubectl get secret versionedsecret
NAME                                   TYPE                                  DATA      AGE
versionedsecret                        Opaque                                1    
```

### Configuration Options

The versionConfiguration in the Vault-Custom Resource Definition is optional. If no version is specified the latest version will be used and in case of a new version in Vault it will be synchronized automatically to Kubernetes.

```yaml
apiVersion: "koudingspawn.de/v1"
kind: Vault
metadata:
  name: versionedsecret
spec:
  path: "versioned/example"
  type: "KEYVALUEV2"
```

### Change Adjustment Callback

For more details please see [Change Detection](/change-detection.md)!
