Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Secrets management workflow #1593

Closed
donspaulding opened this issue Jan 25, 2017 · 5 comments
Closed

Better Secrets management workflow #1593

donspaulding opened this issue Jan 25, 2017 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@donspaulding
Copy link

Issue details

I'm looking for ideas on how to manage secrets and configuration in kubernetes.

I work on a dev team where historically we've managed our credentials, secrets, and environment-specific config files by storing them alongside our application code in our project's source control repos. I'm tasked with updating our workflow to conform to 12-factor app best practices, and so I'm looking to have the environment provide the appropriate configuration to our containers at runtime

Environment

Our current project file structure is something like this:

project/
 |-- conf/
     |-- dev-config.py
     |-- prod-config.py
     |-- config.py      (symlink to prod-config.py or dev-config.py created by ansible)
 |-- app/
     |-- settings.py    (always imports settings from ../conf/config.py)

The k8s Way

It appears as if k8s Secrets and ConfigMaps with volume mounts are intended to solve this from the container's perspective. I've had some success with creating a Secret and then mounting it into conf/config.py. Unfortunately, there seem to be several drawbacks to this approach.

Observed result
  1. volumeMounts override all files within the project/conf/ directory.
  2. All secrets are available to any container to be mounted.
  3. The dashboard allows editing of ConfigMaps and Secrets, but not creating them?
  4. Editing secrets requires the developer to base64 decode/encode the values.
Expected result

In an ideal world, I would be able to:

  1. Create a secret from the dashboard (just the key?).
  2. Add the value of the secret with an editor (i.e. specify the contents of project/conf/config.py)
  3. Not have to use base64 from the UI.
  4. Be able to map a single secret's key/value into a single file in a directory (maybe solved in Projecting single files from volumes into a container's FS kubernetes#19764 ?)
Comments

I'm new enough to the Kubernetes world that I don't even know if I'm asking the right questions, let alone getting close to the right answers. I'd appreciate any pointers to better solutions in this space. As I go through the process of migrating these apps, I'm trying to stick close to the native k8s stack when looking for solutions to my problems. I'm pragmatic though; I'll use whatever solves the problem. And in this case, I think k8s secrets are an almost perfect mechanism for the container, it's just that they leave a lot to be desired from a dev workflow standpoint.

@jwforres
Copy link

I agree that you shouldn't need to use base64 as an end user of a UI. The UI can do the encoding/decoding for you. The one caveat is that some base64 encoded secret data can actually be binary content and won't decode to readable text. In openshift we do detection to see if the base64 decodes to valid text or not. https://github.com/openshift/origin-web-console/blob/master/app/scripts/services/secrets.js#L68

Also of note, a change was made to the API to make it easier to create/update secrets, there is now a dataText (or textData?) attribute that you can send in place of the normal data attribute, this allows you to send plain text on a create/update which will then get base64 encoded server-side and stored into the data field.

As far as what an end user should see for create/update, I would expect a multiline editor / file upload combo that lets you pick a file to send for the secret or type in the content yourself.

The issue with secrets (and config maps) as volumes overwriting the entire directory is still an issue, there are workarounds as suggested in kubernetes/kubernetes#19764
copying the file on container startup is an option (but you have to bounce the pods to pick up the change). cc'ing @pmorie who i've already been bugging about this recently :)

@cristim
Copy link

cristim commented Aug 8, 2017

The base64 is a PITA, and pretty much defeats the purpose of allowing the editing of secrets from the web interface.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 2, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 7, 2018
@maciaszczykm maciaszczykm added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Feb 27, 2018
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/enhancement labels Jun 5, 2018
@maciaszczykm maciaszczykm added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Oct 11, 2018
@maciaszczykm
Copy link
Member

This is already done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

7 participants