项目作者: edithcare

项目描述 :
Simple tool, that fetches a secret from AWS Secret Manager and pipes it into a kubernetes sealed secret
高级语言: Python
项目地址: git://github.com/edithcare/kubernetes-secret-sealer.git
创建时间: 2020-04-01T13:48:02Z
项目社区:https://github.com/edithcare/kubernetes-secret-sealer

开源协议:MIT License

下载


kubernetes-secret-sealer

Python application

Simple tool, that fetches a secret from AWS Secret Manager and pipes it into a kubernetes sealed secret

prerequesites

for kubernetes-secret-sealer to work as intended, several prerequesites have to be fulfilled:

installation

  1. pipx install . # will install to `$HOME/.local/bin/kubernetes-secret-sealer`. set PATH
  2. # legacy: pipsi is no longer maintained. See pipx for an actively maintained alternative
  3. pipsi install .
  4. pipsi install --python /opt/local/bin/python3.7 . # on macos

usage

  1. kubernetes-secret-sealer --help # show help message and exit
  2. # get secret from aws-secretsmanager and generate sealed-secret.yml
  3. kubernetes-secret-sealer \
  4. -p $AWS_PROFILE \
  5. -n $AWS_SECRETS_NAME \
  6. -kns $KUBERNETES_NAMESPACE \
  7. --cert ./path/to/sealed-secret-cert.pem \
  8. -o yaml \
  9. -f ./path/to/sealed-secret.yaml \
  10. -b accountJsonAsString \
  11. -tt Opaque

handling of secrets and workflow

secrets are only stored in the AWS Secretsmanager. This tools writes no unencrypted secrets to the filesystem. So the workflow for using this tool is, to

  • migrate your secrets into AWS Secretsmanager. It is advised, to use the names and semantics the Secret will use in the kubernetes services later.
  • create a sealed secret yaml via:
    1. kubernetes-secret-sealer \
    2. -p $AWS_PROFILE \
    3. -n supersecret \
    4. -kns $KUBERNETES_NAMESPACE \
    5. --cert ./dev-cluster.pem \
    6. -o yaml \
    7. -f supersecret_sealedsecret.yaml
  • then apply the secret via kubectl apply -f supersecret_sealedsecret.yaml

problemshooting

After updating python via homebrew, the virtual environments created with pipx might be broken,
because the symlink in the venv points to the full path for python3 are changed by Homebrew with each patch. This can be fixed via:

  1. pipx reinstall-all