项目作者: masonwr

项目描述 :
A CRD to map Google Cloud managed secrets to k8s
高级语言: Go
项目地址: git://github.com/masonwr/CloudSecret.git
创建时间: 2019-12-23T23:33:01Z
项目社区:https://github.com/masonwr/CloudSecret

开源协议:

下载


CloudSecret

Map GCP Secret Manager secrets to Kubernetes Secrets.

Implemented as a simple CRD. You define CloudSecrets:

  1. apiVersion: secrets.masonwr.dev/v1
  2. kind: CloudSecret
  3. metadata:
  4. name: cloudsecret-sample
  5. spec:
  6. data:
  7. SECRET_DATA: projects/<PROJECT_ID>/secrets/test/versions/latest

CloudSecrets map a key to a Secret Manager Path, and produces a matching Kubernetes secret with the resolved secret data.

For example, if we apply the above CloudSecret, this would result in the creation of the following Kubernetes secret:

  1. apiVersion: v1
  2. data:
  3. SECRET_DATA: a2VlcCB0...
  4. kind: Secret

Install

NB: The service account running the deployment must have the “Secret Manager Secret Accessor” role. And the Secret Manager API must be enabled.

Deploy (public image)

Dependencies

  1. $ git clone https://github.com/masonwr/CloudSecret && cd CloudSecret
  2. $ make install # install CRD
  3. $ make deploy # deploy using the public image built from this repo (gcr.io/public-263420/cloudsecret-controller)

Build (build from source)

Dependencies

  1. $ git clone https://github.com/masonwr/CloudSecret && cd CloudSecret
  2. $ export IMG=your/image/repo:tag
  3. $ make install
  4. $ make docker-build docker-push
  5. $ make deploy

Tutorial

Dependencies

Create the GCP Secret, and get its path

  1. $ cd $(mktemp -d)
  2. $ export PROJECT_ID=some_project_id
  3. $ echo "keep this secret, keep this safe" > secret.data.txt
  4. $ gcloud beta secrets create loc-of-ring \
  5. --data-file=secret.data.txt \
  6. --project=$PROJECT_ID \
  7. --replication-policy=automatic
  8. $ gcloud beta secrets describe loc-of-ring --project=$PROJECT_ID
  9. createTime: '2019-12-23T21:11:34.245558Z'
  10. name: projects/<PROJECT_ID>/secrets/loc-of-ring
  11. replication:
  12. automatic: {}

Note the fully qualified secret name.

Define a CloudSecret

  1. $ cat << EOF > cloudSecretExample.yaml
  2. apiVersion: secrets.masonwr.dev/v1
  3. kind: CloudSecret
  4. metadata:
  5. name: example
  6. spec:
  7. data:
  8. SECRET_DATA: <Fully qulified secret path>/versions/latest
  9. EOF
  10. $ kubectl apply -f cloudSecretExample.yaml

Verify

  1. $ kubectl get secrets example -o json | jq -r .data.SECRET_DATA | base64 -d
  2. keep this secret, keep this safe

TODO:

  • Implement controls for handling when secret lookup fails

NOTE

Built with the awesome kubebuilder.