Skip to content

Commit 0663de6

Browse files
authored
Fix the HVAC configurable mount point and add to helm chart (#4088)
1 parent a414054 commit 0663de6

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

docker/zenml-server-hf-spaces.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ENV ZENML_SERVER_SECURE_HEADERS_CSP="frame-ancestors *;"
5959
# ENV ZENML_SECRETS_STORE_VAULT_ADDR=""
6060
# ENV ZENML_SECRETS_STORE_VAULT_TOKEN=""
6161
# ENV ZENML_SECRETS_STORE_VAULT_NAMESPACE=""
62+
# ENV ZENML_SECRETS_STORE_MOUNT_POINT=""
6263
# ENV ZENML_SECRETS_STORE_MAX_VERSIONS=""
6364

6465
ENTRYPOINT ["uvicorn", "zenml.zen_server.zen_server_api:app", "--log-level", "debug", "--no-server-header"]

docs/book/getting-started/deploying-zenml/deploy-with-docker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ These configuration options are only relevant if you're using Hashicorp Vault as
195195
* **ZENML\_SECRETS\_STORE\_VAULT\_ADDR**: The URL of the HashiCorp Vault server to connect to. NOTE: this is the same as setting the `VAULT_ADDR` environment variable.
196196
* **ZENML\_SECRETS\_STORE\_VAULT\_TOKEN**: The token to use to authenticate with the HashiCorp Vault server. NOTE: this is the same as setting the `VAULT_TOKEN` environment variable.
197197
* **ZENML\_SECRETS\_STORE\_VAULT\_NAMESPACE**: The Vault Enterprise namespace. Not required for Vault OSS. NOTE: this is the same as setting the `VAULT_NAMESPACE` environment variable.
198+
* **ZENML\_SECRETS\_STORE\_MOUNT\_POINT**: The mount point to use for the HashiCorp Vault secrets store. If not set, the default value of `secret` will be used.
198199
* **ZENML\_SECRETS\_STORE\_MAX\_VERSIONS**: The maximum number of secret versions to keep for each Vault secret. If not set, the default value of 1 will be used (only the latest version will be kept).
199200
{% endtab %}
200201

docs/book/getting-started/deploying-zenml/deploy-with-helm.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ To use the HashiCorp Vault service as a Secrets Store back-end, it must be confi
530530
vault_token: <your Vault token>
531531
# The Vault Enterprise namespace. Not required for Vault OSS.
532532
vault_namespace: <your Vault namespace>
533+
# The mount point to use for the HashiCorp Vault secrets store. If not set, the default value of `secret` will be used.
534+
mount_point: <your Vault mount point>
533535
```
534536
{% endtab %}
535537

helm/templates/_environment.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ vault_addr: {{ .SecretsStore.hashicorp.vault_addr | quote }}
335335
{{- if .SecretsStore.hashicorp.vault_namespace }}
336336
vault_namespace: {{ .SecretsStore.hashicorp.vault_namespace | quote }}
337337
{{- end }}
338+
{{- if .SecretsStore.hashicorp.mount_point }}
339+
mount_point: {{ .SecretsStore.hashicorp.mount_point | quote }}
340+
{{- end }}
338341
{{- if .SecretsStore.hashicorp.max_versions }}
339342
max_versions: {{ .SecretsStore.hashicorp.max_versions | quote }}
340343
{{- end }}

helm/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ zenml:
702702
vault_token:
703703
# The Vault Enterprise namespace. Not required for Vault OSS.
704704
vault_namespace:
705+
# The mount point to use (defaults to "secret" if not set)
706+
mount_point:
705707
# The maximum number of secret versions to keep. If not set, the default
706708
# value of 1 will be used (only the latest version will be kept).
707709
max_versions:
@@ -962,6 +964,8 @@ zenml:
962964
vault_token:
963965
# The Vault Enterprise namespace. Not required for Vault OSS.
964966
vault_namespace:
967+
# The mount point to use (defaults to "secret" if not set)
968+
mount_point:
965969
# The maximum number of secret versions to keep. If not set, the default
966970
# value of 1 will be used (only the latest version will be kept).
967971
max_versions:

src/zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
HVAC_ZENML_SECRET_NAME_PREFIX = "zenml"
4545
ZENML_VAULT_SECRET_VALUES_KEY = "zenml_secret_values"
4646
ZENML_VAULT_SECRET_METADATA_KEY = "zenml_secret_metadata"
47+
DEFAULT_MOUNT_POINT = "secret"
4748

4849

4950
class HashiCorpVaultSecretsStoreConfiguration(SecretsStoreConfiguration):
@@ -120,13 +121,11 @@ def client(self) -> hvac.Client:
120121
else None,
121122
namespace=self.config.vault_namespace,
122123
)
124+
# Configure the intended mount (idempotent)
123125
self._client.secrets.kv.v2.configure(
126+
mount_point=self.config.mount_point or DEFAULT_MOUNT_POINT,
124127
max_versions=self.config.max_versions,
125128
)
126-
if self.config.mount_point:
127-
self._client.secrets.kv.v2.configure(
128-
mount_point=self.config.mount_point,
129-
)
130129
return self._client
131130

132131
# ====================================
@@ -197,6 +196,7 @@ def store_secret_values(
197196
},
198197
# Do not allow overwriting an existing secret
199198
cas=0,
199+
mount_point=self.config.mount_point or DEFAULT_MOUNT_POINT,
200200
)
201201
except VaultError as e:
202202
raise RuntimeError(f"Error creating secret: {e}")
@@ -224,6 +224,7 @@ def get_secret_values(self, secret_id: UUID) -> Dict[str, str]:
224224
vault_secret = (
225225
self.client.secrets.kv.v2.read_secret(
226226
path=vault_secret_id,
227+
mount_point=self.config.mount_point or DEFAULT_MOUNT_POINT,
227228
)
228229
.get("data", {})
229230
.get("data", {})
@@ -295,6 +296,7 @@ def update_secret_values(
295296
ZENML_VAULT_SECRET_VALUES_KEY: secret_values,
296297
ZENML_VAULT_SECRET_METADATA_KEY: metadata,
297298
},
299+
mount_point=self.config.mount_point or DEFAULT_MOUNT_POINT,
298300
)
299301
except InvalidPath:
300302
raise KeyError(f"Secret with ID {secret_id} does not exist.")
@@ -320,6 +322,7 @@ def delete_secret_values(self, secret_id: UUID) -> None:
320322
try:
321323
self.client.secrets.kv.v2.delete_metadata_and_all_versions(
322324
path=vault_secret_id,
325+
mount_point=self.config.mount_point or DEFAULT_MOUNT_POINT,
323326
)
324327
except InvalidPath:
325328
raise KeyError(f"Secret with ID {secret_id} does not exist.")

0 commit comments

Comments
 (0)