Skip to content

Config Maps and Secrets usage within Configurations #1504

Closed

Description

@dprotaso

Expected Behavior

As an app/function developer, when I have a config map or secrets, I need the ability for my application/function to be updated when the config map or secret changes

Actual Behavior

An approached used by Kubernetes users is to use read-only volume mounts. But the Knative webhook currently prevents the use of volumes. Secondly, I could use the downward API to expose these properties as environment variables but it doesn't propagate updates.

Steps to Reproduce the Problem

  1. Create a configuration with a volume mount providing a config map or secret
  2. Try to create this configuration
  3. It will fail with an error message from the web hook

Additional Info

Start of the discussion: https://knative.slack.com/archives/C93E33SN8/p1530880996000208

Immutability is a concern

  • ie. should a update to a config map trigger reconciliation & a new revision? or update existing revisions

Activity

  1. added
    area/API
    kind/feature
    on Jul 6, 2018
  2. changed the title [-]Knative should allow read only ConfigMap & Secret Volumes[/-] [+]Knative should allow apps/functions to use ConfigMap & Secret Volumes[/+] on Jul 6, 2018
  3. changed the title [-]Knative should allow apps/functions to use ConfigMap & Secret Volumes[/-] [+]Config Maps and Secrets should be able to be referenced by a Configuration [/+] on Jul 6, 2018
  4. changed the title [-]Config Maps and Secrets should be able to be referenced by a Configuration [/-] [+]Config Maps and Secrets usage within Configurations[/+] on Jul 6, 2018
  5. mattmoor commented on Jul 6, 2018

    @mattmoor
    Contributor

    On the agenda for API QG 7/11. thanks for leading this @dprotaso

  6. evankanderson commented on Jul 6, 2018

    @evankanderson
    Member

    /assign evankanderson

  7. evankanderson commented on Jul 6, 2018

    @evankanderson
    Member

    I probably won't be able to make the 7/11 WG. @cooperneil should be there for the discussion at a minimum.

  8. evankanderson commented on Jul 6, 2018

    @evankanderson
    Member

    A few additional considerations:

    1. A Volume, ConfigMap or Secret is basically an external source of "state" which isn't snapshotted from the Configuration the way that a Docker container or a Revision is. This makes rollback and determining "what changed" more difficult, as there are more places to look, and it's not immediately obvious how to rollback a ConfigMap or Secret update if you didn't save the object definition before update.
    2. Out-of-band updates to the application's state need to be rolled out in some fashion to the running Pods/containers. It's not clear:
      1. How to express a desire to do this. Since the state of the object hasn't changed, the controller would need to understand all the possible additional references which might be changed to update the state. Waiting for the revision to scale to zero is one option. Another option would be to have a max lifetime on each Pod spawned by the Revision.
      2. How to control the rate of rollout to allow this to be done "safely". Typically, we rely on the user's configuration of Route to determine how fast they are willing to rollout changes, but this bypasses that mechanism.

    There are a number of parallels here between changing configuration references and using a docker image tag and/or git repo reference without a revision tag (in that the Configuration spec may not change, but the user would like a new Revision to be snapshotted).

  9. winmillwill commented on Aug 13, 2018

    @winmillwill

    I stumbled here after I realized that Revisions don't capture configmaps, and I started thinking why we need anything outside the container at all. For configmaps, it's possible to take advantage of the volume being reloaded without the pod being rescheduled if your application supports that. For secrets, you may want the same thing, and/or you may not want to store any secrets in the container image.

    If a "soft reload" isn't an important consideration, then it seems like the answer would be a sidecar or init container for fetching secrets and simply building all your config files into your container image and/or setting the environment variables in the container spec. I like the idea of a sidecar for secrets even more than trying to track secrets in a revision because secrets have their own lifecycle, ie certs expire so rolling back to a working config and having to also take an expired cert is probably not desirable.

  10. evankanderson commented on Aug 13, 2018

    @evankanderson
    Member

    I agree that a sidecar and/or external interface (ala Vault) is probably the way to go.

    My personal preference would be to steer users towards using container-level identity
    from Kubernetes SIG
    and the Vault for secrets which can't be managed via the identity service. Unfortunately, this doesn't have a great kicking-the-tires setup experience, as anything involving credentials and external storage sucks.

    I think there is an interesting question of how to support mounting a ConfigMap or Secret into the container via the downwards API.

  11. evankanderson commented on Aug 13, 2018

    @evankanderson
    Member

    Note that you can use environment variables today; this would produce a smeared update as new pods are created. We may want to consider adding a "max age killer" which would remove knative pods older than a certain age so that secret and configmap changes are picked up within a certain maximum amount of time.

  12. 8 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/APIkind/feature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions