GitHub - GoogleCloudPlatform/secrets-store-csi-driver-provider-gcp: Google Secret Manager provider for the Secret Store CSI Driver. (original) (raw)

e2e

Google Secret Manager provider for the Secret Store CSI Driver. Allows you to access secrets stored in Secret Manager as files mounted in Kubernetes pods.

Install

kubectl apply -f deploy/provider-gcp-plugin.yaml

if you want to use helm

helm upgrade --install secrets-store-csi-driver-provider-gcp charts/secrets-store-csi-driver-provider-gcp

NOTE: The driver's rotation and secret syncing functionality is still in Alpha and requires additional installation steps.

Usage

Secret Manager

The provider will use the workload identity of the pod that a secret is mounted onto when authenticating to the Google Secret Manager API. For this to work the workload identity of the pod must be configured and appropriate IAM bindings must be applied.

$ export PROJECT_ID= $ gcloud config set project $PROJECT_ID $ export PROJECT_NUMBER="$(gcloud projects describe "${PROJECT_ID}" --format='value(projectNumber)')"

Create a secret with 1 active version

$ echo "foo" > secret.data $ gcloud secrets create testsecret --replication-policy=automatic --data-file=secret.data $ rm secret.data

grant the new service account permission to access the secret

$ gcloud secrets add-iam-policy-binding testsecret
--role=roles/secretmanager.secretAccessor
--member=principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/default/sa/mypodserviceaccount

$ ./scripts/example.sh $ kubectl exec -it mypod /bin/bash root@mypod:/# ls /var/secrets

Parameter Manager

From version 1.9.0, secrets-store-csi-driver-provider-gcp also supports mounting the parameter version from Google Parameter Version

Parameter Manager is an extension to the Secret Manager service and provides a centralized storage for all configuration parameters related to your workload deployments.

$ export PROJECT_ID= $ gcloud config set project $PROJECT_ID $ export PROJECT_NUMBER="$(gcloud projects describe "${PROJECT_ID}" --format='value(projectNumber)')"

set the location

$ export LOCATION_ID= $ gcloud config set api_endpoint_overrides/parametermanager https://parametermanager.${LOCATION_ID}.rep.googleapis.com/ $ echo "server_port: 8080" > parameter.data $ gcloud parametermanager parameters create testparameter --location LOCATIONID−−parameter−format=YAML−−project{LOCATION_ID} --parameter-format=YAML --project LOCATIONIDparameterformat=YAMLproject{PROJECT_ID} $ gcloud parametermanager parameters versions create testversion --parameter=testparameter --location=${LOCATION_ID} --payload-data-from-file=parameter.data $ rm parameter.data

grant the new service account permission to access the secret

$ gcloud projects add-iam-policy-binding ${PROJECT_ID}
--role=roles/parametermanager.parameterAccessor
--member=principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/default/sa/mypodserviceaccount

$ ./scripts/pm_example.sh

wait for pod to be in running state

$ kubectl exec -it mypod -- cat /var/secrets/good1.txt

Security Considerations

This plugin is built to ensure compatibility between Secret Manager and Kubernetes workloads that need to load secrets from the filesystem. It also enables syncing of those secrets to Kubernetes-native secrets for consumption as environment variables.

When evaluating this plugin consider the following threats:

For these reasons, when possible we recommend using the Secret Manager API directly (using one of the provided client libraries, or by following the REST or GRPC documentation).

Contributing

Please see the contributing guidelines.

Support

This is not an officially supported Google product.

For supportplease search open issues here, and if your issue isn't already represented pleaseopen a new one. Pull requests and issues will be triaged weekly.

We close issues after 30 days if there's been no response or action taken.