Closed sakiib closed 2 years ago
-> Enable: /database/config (one-time enable)
/aws/config/root => /k8s.-.{se-type}.se-ns.se-name/config/root
/database/config/:name => /k8s.-.{se-type}.se-ns.se-name/config/database
https://www.vaultproject.io/api/secret/databases#create-role
api path: /k8s.-.{se-type}.se-ns.se-name/roles/{es-role-cr-name}
https://www.vaultproject.io/api-docs/system/policies#create-update-acl-policy
metdata.name = replace({se-type}.se-ns.se-name.{es-role-cr-name}, ".", "-")
/sys/policies/acl/:name name = k8s.-.{se-type}.se-ns.se-name.{es-role-cr-name}
https://www.vaultproject.io/docs/auth/kubernetes#configuration
metadata.name: replace({se-type}.se-ns.se-name.{secret-role-binding-cr-name}, ".", "-")
vault write auth/kubernetes/role/demo \
bound_service_account_names=vault-auth \
bound_service_account_namespaces=default \
policies=default \
ttl=1h
demo = k8s.-.{se-type}.se-ns.se-name.{secret-role-binding-cr-name}
keys := map[string]string{}
flag.StringToStringVar(&keys, "keys", keys, "Key/Value map used to update pg-coordinator and replication mode detector image")
kubectl vault generate secretproviderclass <name> -n <ns>
--secretrolebinding=ns2/name2
--vault-role=AWSRole/name3
--keys x=y -o json,yaml | kubectl apply -f -
SecretProviderClass
to use theSecrets Store CSI driver
usingKubeVault CLI
. For example:$ kubectl-vault create secret-provider-class ...
Here's the complete step by step manual procedure and we want to automate the
Step 3
:Step 1: Enable
SecretEngine
and CreateSecretEngineRole
[DB Admin] Enable a new
SecretEngine
[DB Admin] Create a
SecretEngineRole
e.g.ElasticsearchRole
Step 2: Create
VaultPolicy
& bind it to aServiceAccount
usingVaultPolicyBinding
[DB Admin] Create
VaultPolicy
[User] Create
ServiceAccount
[Vault Admin] Create
VaultPolicyBinding
Step 3: Create
SecretProviderClass
SecretProviderClass
Step 4: Create a
Pod
& mountPod
and mount the dynamically generated Database credentials in it.Information we may need to generate the
SecretProviderClass
:vault
namespace for generatingvaultAddress
roleName
may be generated fromVaultPolicyBinding
name, e.g.k8s.(clusterName or -).namespace.name
objectName
may be kept same as the respectivesecretKey
secretPath
may be generated from SecretEngineRoleElasticsearchRole
name,path/creds/name