-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve SDS file watching docs #10979
Comments
The current behaviour is intentional. The basis is how Kubernetes secret volume mounts and atomic secret updates happen: Assume we have a secret with two files The initial state of the directory, files and symlinks are set up by Kubernetes like this:
The directory
The watch can only catch this by watching moves in directory In your case, appending You can see more detailed discussion here #9359 (comment) and a test case that shows the currently expected behaviour
|
So are we actually watching for any move within the directory, not moves to the directory itself? We're watching the parent directory for moves to any files within the directory and then re-reading the secrets when that happens? It feels a bit non-intuitive (and under-documented). I wonder if it would make sense to add a config option to the SDS resource that indicates what kind of semantics should be used when doing file watches? @envoyproxy/api-shepherds |
At minimum let's please start by getting the behavior well documented. After that we can pursue additional config/changes if needed? |
Yeah that sounds like a good first step, I imagine most people would be able to work with the current behavior with proper documentation. |
We are watching all moves in/to/from that directory. In your example, the watched directory would be Currently the documentation says Envoy will only watch the file path for moves. |
I don't think the current documentation is wrong per se, but rather incomplete and makes it hard for an operator to understand what is required for performing atomic updates to certs. It would be great if we had an example (outside of unit tests) that explained the setup necessary. Not all use cases use Kuberentes, so ideally we document the way it works with some detail so that operators using other deployment models can understand how to set this up. |
See here for the docs we have on the runtime config swap: https://www.envoyproxy.io/docs/envoy/latest/configuration/operations/runtime#updating-runtime-values-via-symbolic-link-swap. It would be great to have good docs/examples of this in either the operations guide or the config docs somewhere. |
Example method for certificate rotation specifically is of course good to have in the docs. I wonder should we also replace the runtime config swap method link in |
The swap method documented definitely works for file based runtime, but I'm not sure if it works for config sources or not. It would be good to clean this up and perhaps have a docs section in operations (https://www.envoyproxy.io/docs/envoy/latest/operations/operations) around file swapping and the various use cases, and then link there as needed? |
I am trying to get CDS file based watch to work with a configmap and failing so far (because it seems the directory change isn't detected) - any idea what I am doing wrong?
and
changes to config map don't get detected |
tried
|
If you would have a real file Note that the topic discussed in this issue is specifically certificate and key file hot-reload, which was added in PR #10163. It was a special case since it was new logic and it could be implemented in a way that works with Kubernetes symlink swap approach. If you are interested, the fundamental problem is described in "Problem 1" here #9359 (comment). In your case the code expects to see inotify MOVE_TO event in directory |
@tsaarni thank you for the detailed reply (and I realize I'm hijacking a bit a SDS thread but I would hope all file based *DS would work the same) - in the same vein, we claim envoy is built to work well with kubernetes, so it seems supporting/detecting the way kubernetes does atomic updates would be beneficial (and I do realize many people use full fledged control planes like istio but I believe there are valid use case for file base boostrap/simpler setup, yet allowing the basic of 1990s like kill -1 for config reload / some way to do dynamic config out of the box, using the standard image) So I have 2 choices if I understand, a) write a wrapper script that duplicates a watch for change and moves the files into a writeable copy that envoy detects; b) find how to hack the envoy code to support k8s configmap's way of doing atomic changes. I think b) would be better - do we agree it's worth doing? |
There are a few limitations in our existing support for symlink-based key rotation: We don't atomically resolve symlinks, so a single snapshot might have inconsistent symlink resolutions for different watched files. Watches are on parent directories, e.g. for /foo/bar/baz on /foo/bar, which doesn't support common key rotation schemes were /foo/new/baz is rotated via a mv -Tf /foo/new /foo/bar. The solution is to provide a structured WatchedDirectory for Secrets to opt into when monitoring DataSources. SDS will used WatchedDirectory to setup the inotify watch instead of the DataSource path. On update, it will read key/cert twice, verifying file content hash consistency. Risk level: Low (opt-in feature) Testing: Unit and integration tests added. Fixes #13663 Fixes #10979 Fixes #13370 Signed-off-by: Harvey Tuch <[email protected]>
…3721) There are a few limitations in our existing support for symlink-based key rotation: We don't atomically resolve symlinks, so a single snapshot might have inconsistent symlink resolutions for different watched files. Watches are on parent directories, e.g. for /foo/bar/baz on /foo/bar, which doesn't support common key rotation schemes were /foo/new/baz is rotated via a mv -Tf /foo/new /foo/bar. The solution is to provide a structured WatchedDirectory for Secrets to opt into when monitoring DataSources. SDS will used WatchedDirectory to setup the inotify watch instead of the DataSource path. On update, it will read key/cert twice, verifying file content hash consistency. Risk level: Low (opt-in feature) Testing: Unit and integration tests added. Fixes envoyproxy#13663 Fixes envoyproxy#10979 Fixes envoyproxy#13370 Signed-off-by: Harvey Tuch <[email protected]> Signed-off-by: Qin Qin <[email protected]>
I ran into this issue also trying to send RTDS over a k8s config map. I'm going to fix this. I discussed with @htuch and we think the right solution is to:
This should allow us to solve this in the general case for any xDS. cc @snowp |
For xDS over the file system, sometimes more control is required over what directory/file is watched for symbolic link swaps. Specifically, in order to deliver xDS over a Kubernetes ConfigMap, this extra configuration is required. Fixes #10979 Signed-off-by: Matt Klein <[email protected]>
For xDS over the file system, sometimes more control is required over what directory/file is watched for symbolic link swaps. Specifically, in order to deliver xDS over a Kubernetes ConfigMap, this extra configuration is required. Fixes #10979 Signed-off-by: Matt Klein <[email protected]>
For xDS over the file system, sometimes more control is required over what directory/file is watched for symbolic link swaps. Specifically, in order to deliver xDS over a Kubernetes ConfigMap, this extra configuration is required. Fixes envoyproxy/envoy#10979 Signed-off-by: Matt Klein <[email protected]> Mirrored from https://github.com/envoyproxy/envoy @ 8670309bce9a488ccfc04a87d0c4367ca59c4179
The comments in sds_api.cc imply that we're watching the directory to allow for atomic updates of the cert/key (https://github.com/envoyproxy/envoy/blob/master/source/common/secret/sds_api.cc#L66-L67), but from testing this by referencing certs in
/secrets/current/cert.crt
and repointing thecurrent
symlink to another directory, no file watches are triggered.I'm not sure if this is a bug, inconsistent docs or perhaps I'm just misunderstanding the feature. Applying the following diff made this behave the way I expected it to:
cc @lizan @tsaarni
The text was updated successfully, but these errors were encountered: