# 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)!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vault.koudingspawn.de/supported-secret-types/secret-type-keyvaluev2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
