From f3b06d4c4a4706f01200e5b7405c39f97994336a Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 24 Mar 2021 17:09:46 +0100 Subject: [PATCH] util: pass Namespace as part of KMSInitializerArgs Amazon KMS expects a Secret with sensitive account and key information in the Kubernetes Namespace where the Ceph-CSI Pods are running. It will fetch the contents of the Secret itself. Signed-off-by: Niels de Vos --- internal/util/kms.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/util/kms.go b/internal/util/kms.go index 0827c442b..bf9361a49 100644 --- a/internal/util/kms.go +++ b/internal/util/kms.go @@ -204,6 +204,10 @@ type KMSInitializerArgs struct { Tenant string Config map[string]interface{} Secrets map[string]string + // Namespace contains the Kubernetes Namespace where the Ceph-CSI Pods + // are running. This is an optional option, and might be unset when the + // KMSProvider.Initializer is called. + Namespace string } // KMSInitializerFunc gets called when the KMSProvider needs to be @@ -260,11 +264,18 @@ func (kf *kmsProviderList) buildKMS(tenant string, config map[string]interface{} providerName) } - return provider.Initializer(KMSInitializerArgs{ + kmsInitArgs := KMSInitializerArgs{ Tenant: tenant, Config: config, Secrets: secrets, - Namespace: getPodNamespace(), - ConfigMap: getKMSConfigMapName(), - }) + } + + // Namespace is an optional parameter, it may not be set and is not + // required for all KMSProviders + ns, err := getPodNamespace() + if err == nil { + kmsInitArgs.Namespace = ns + } + + return provider.Initializer(kmsInitArgs) }