Skip to content

Commit dbe1ffd

Browse files
author
Martin Jackson
committed
Fix defaults for vault mount point on spoke clusters
1 parent 8d582dd commit dbe1ffd

6 files changed

Lines changed: 59 additions & 11 deletions

File tree

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: v2
33
name: vp-sscsi-spc
4-
version: 0.1.5
4+
version: 0.1.6
55
description: >-
66
Library chart for app-level Vault SecretProviderClass rendering with hub, spoke, and
77
external Vault support. Cluster CA material is managed by a separate cluster-wide chart.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vp-sscsi-spc
22

3-
![Version: 0.1.5](https://img.shields.io/badge/Version-0.1.5-informational?style=flat-square)
3+
![Version: 0.1.6](https://img.shields.io/badge/Version-0.1.6-informational?style=flat-square)
44

55
Library chart for app-level Vault SecretProviderClass rendering with hub, spoke, and external Vault support. Cluster CA material is managed by a separate cluster-wide chart.
66

@@ -12,7 +12,7 @@ This chart is the **library for `SecretProviderClass` only**, **one dependency p
1212

1313
This chart renders **only** `SecretProviderClass` YAML (named templates or optional `installDefaultManifests`). Use it from application charts that need:
1414

15-
- Hub-cluster Vault auth (`hub` mount + role)
15+
- Hub-cluster Vault auth (defaults `vaultKubernetesMountPath` to `hub` when `global.localClusterDomain == global.hubClusterDomain`, else `global.clusterDomain`; optional `vault.hubMountPath` override, hub role)
1616
- Spoke-cluster auth to centralized Vault (`clusterDomain` mount + role)
1717
- External Vault endpoint override (`vault.externalAddress`)
1818
- Optional reference to a pre-mounted CA path (`tls.vaultCACertPath`), or **`tls.projectedClusterCa.enabled: true`** to derive the path for **openshift-sscsi-vault**'s projected CNO/proxy bundle (same defaults as that chart's `syncProviderCaConfigMap`)
@@ -63,7 +63,7 @@ When `ocpSecretsStoreCsiVault.applicationKey` is set, the chart reads
6363
| ocpSecretsStoreCsiVault.tls.projectedClusterCa | object | `{"enabled":false,"injectTrustedCabundle":true,"keyInConfigMap":"vault-tls-ca.pem","mountDir":"/etc/pki/vault-ca","trustedCabundleDataKey":"ca-bundle.crt"}` | When `enabled` is true and `vaultCACertPath` is empty, set `vaultCACertPath` to the bundle file under **openshift-sscsi-vault** defaults (CNO proxy merge `ca-bundle.crt` vs PEM `vault-tls-ca.pem`). Align these fields with `ocpSecretsStoreCsiVault.caProvider.syncProviderCaConfigMap` on that chart. |
6464
| ocpSecretsStoreCsiVault.tls.vaultCACertPath | string | `""` | Explicit PEM path on the CSI provider pod. When non-empty, wins over `projectedClusterCa`. |
6565
| ocpSecretsStoreCsiVault.vault.externalAddress | string | `""` | If non-empty, used as `spec.parameters.vaultAddress` (external Vault endpoint). |
66-
| ocpSecretsStoreCsiVault.vault.hubMountPath | string | `"hub"` | Vault Kubernetes auth mount path for hub-style auth |
66+
| ocpSecretsStoreCsiVault.vault.hubMountPath | string | `""` | Optional override for hub-style `vaultKubernetesMountPath`. Empty defaults to `hub` when `global.localClusterDomain == global.hubClusterDomain`, else `global.clusterDomain`. |
6767
| ocpSecretsStoreCsiVault.workloadAuthIndex | int | `0` | Index into `clusterGroup.applications[applicationKey].ssCsiWorkloadAuth` when multiple entries are present. |
6868

6969
----------------------------------------------

README.md.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This chart is the **library for `SecretProviderClass` only**, **one dependency p
1313

1414
This chart renders **only** `SecretProviderClass` YAML (named templates or optional `installDefaultManifests`). Use it from application charts that need:
1515

16-
- Hub-cluster Vault auth (`hub` mount + role)
16+
- Hub-cluster Vault auth (defaults `vaultKubernetesMountPath` to `hub` when `global.localClusterDomain == global.hubClusterDomain`, else `global.clusterDomain`; optional `vault.hubMountPath` override, hub role)
1717
- Spoke-cluster auth to centralized Vault (`clusterDomain` mount + role)
1818
- External Vault endpoint override (`vault.externalAddress`)
1919
- Optional reference to a pre-mounted CA path (`tls.vaultCACertPath`), or **`tls.projectedClusterCa.enabled: true`** to derive the path for **openshift-sscsi-vault**'s projected CNO/proxy bundle (same defaults as that chart's `syncProviderCaConfigMap`)

templates/spc-library.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,14 @@ spec:
192192
vaultTLSServerName: {{ .Values.ocpSecretsStoreCsiVault.tls.vaultTLSServerName | quote }}
193193
{{- end }}
194194
{{- if $isHubStyleAuth }}
195-
vaultKubernetesMountPath: {{ .Values.ocpSecretsStoreCsiVault.vault.hubMountPath | quote }}
195+
{{- $hubMountPath := .Values.ocpSecretsStoreCsiVault.vault.hubMountPath | default "" | trim }}
196+
{{- $localDomain := $.Values.global.localClusterDomain | default "" | trim }}
197+
{{- $hubDomain := $.Values.global.hubClusterDomain | default "" | trim }}
198+
{{- $defaultHubMountPath := $.Values.global.clusterDomain | default "" | trim }}
199+
{{- if and (ne $localDomain "") (eq $localDomain $hubDomain) }}
200+
{{- $defaultHubMountPath = "hub" }}
201+
{{- end }}
202+
vaultKubernetesMountPath: {{ coalesce $hubMountPath $defaultHubMountPath "hub" | quote }}
196203
roleName: {{ coalesce $workloadAuth.roleName .Values.ocpSecretsStoreCsiVault.auth.roleName "hub-role" | quote }}
197204
{{- else }}
198205
vaultKubernetesMountPath: {{ $.Values.global.clusterDomain | quote }}

tests/secretproviderclass_test.yaml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tests:
2626
apiVersion: secrets-store.csi.x-k8s.io/v1
2727
any: true
2828

29-
- it: uses hub defaults on a hub cluster
29+
- it: uses hub mount path by default when localClusterDomain equals hubClusterDomain
3030
template: templates/install-default-manifests.yaml
3131
set:
3232
clusterGroup:
@@ -38,10 +38,10 @@ tests:
3838
name: app-secrets
3939
auth:
4040
roleName: hub-role
41-
vault:
42-
hubMountPath: hub
4341
global:
42+
clusterDomain: group-one
4443
hubClusterDomain: apps.hub.example.org
44+
localClusterDomain: apps.hub.example.org
4545
documentSelector:
4646
path: kind
4747
value: SecretProviderClass
@@ -62,6 +62,47 @@ tests:
6262
path: spec.parameters.roleName
6363
value: hub-role
6464

65+
- it: defaults hub-style mount path to global.clusterDomain when localClusterDomain differs
66+
template: templates/install-default-manifests.yaml
67+
set:
68+
clusterGroup:
69+
isHubCluster: true
70+
ocpSecretsStoreCsiVault:
71+
secretProviderClass:
72+
installDefaultManifests: true
73+
global:
74+
clusterDomain: group-one
75+
hubClusterDomain: apps.hub.example.org
76+
localClusterDomain: spoke.apps.example.org
77+
documentSelector:
78+
path: kind
79+
value: SecretProviderClass
80+
asserts:
81+
- equal:
82+
path: spec.parameters.vaultKubernetesMountPath
83+
value: group-one
84+
85+
- it: honors explicit hubMountPath override on a hub cluster
86+
template: templates/install-default-manifests.yaml
87+
set:
88+
clusterGroup:
89+
isHubCluster: true
90+
ocpSecretsStoreCsiVault:
91+
secretProviderClass:
92+
installDefaultManifests: true
93+
vault:
94+
hubMountPath: hub
95+
global:
96+
clusterDomain: group-one
97+
hubClusterDomain: apps.hub.example.org
98+
documentSelector:
99+
path: kind
100+
value: SecretProviderClass
101+
asserts:
102+
- equal:
103+
path: spec.parameters.vaultKubernetesMountPath
104+
value: hub
105+
65106
- it: uses spoke mount and role on spoke cluster with centralized Vault
66107
template: templates/install-default-manifests.yaml
67108
set:

values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ ocpSecretsStoreCsiVault:
1919
vault:
2020
# -- If non-empty, used as `spec.parameters.vaultAddress` (external Vault endpoint).
2121
externalAddress: ""
22-
# -- Vault Kubernetes auth mount path for hub-style auth
23-
hubMountPath: hub
22+
# -- Optional override for hub-style `vaultKubernetesMountPath`. Empty defaults to `hub` when `global.localClusterDomain == global.hubClusterDomain`, else `global.clusterDomain`.
23+
hubMountPath: ""
2424

2525
auth:
2626
# -- Vault Kubernetes auth role name for hub-style auth

0 commit comments

Comments
 (0)