-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Refactor keystore interface into 3 different interfaces #16365
Conversation
Signed-off-by: chrismark <[email protected]>
486c0a1
to
bd508d6
Compare
I would recommend splitting this PR in 2:
|
Signed-off-by: chrismark <[email protected]>
Updated that, to keep only the Keystore refactoring. The implementation of k8s keystore could be retrieved by the previous commit (bd508d6). I will open it for review to start shaping it more. Also interface inheritance is something to consider, since for now I followed an approach of having "stronger" interfaces inheriting the ones with the lower privileges. |
Signed-off-by: chrismark <[email protected]>
I would avoid a common Factory for now, as you don't need it yet? Left a comment about the existing one, but it looks to me that it's file_keystore specifc. |
Signed-off-by: chrismark <[email protected]>
This is looking good, but tests seem to be failing |
Signed-off-by: chrismark <[email protected]>
Yeap @exekias , tests were failing because the refactoring was not "healthy". I had to ensure that in all places the stores are properly checked if implement the respective interfaces. Feel free to comment on it. |
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
LGTM. Let's see what CI says. |
Signed-off-by: chrismark <[email protected]>
jenkins, test this again please |
CI looks happy now. I also added manual testing notes that I used in my testing process too. |
(cherry picked from commit d99dde2)
What does this PR do?
This PR refactor keystore interface into 3 different interfaces.
This PR introduces a newKeystore
backend which isReadOnly
and retrieves passwords from k8s secrets through k8s API. In order to implement this, the basicKeystore
interface is split into 3 different interfaces,Keystore
(readonly),WritableKeystore
(Keystore + store/write/delete),ListingKeystore
(WritableKeystore + list) as proposed on #5832.The new Keystore that retrieves data from k8s secrets is ofKeystore
(readonly) type.#### Autodiscover adoptionIn order to support this k8s Keystore in Autodiscover, a keystore object is attached on every event. The keystore object is either created or retrieved if it already exists. We create only one keystore per namespace and we reuse it for events of the same namespace.
Why is it important?
This is important in order to support different keystore backends, like k8s keystore.
This is important in order to support autodiscover hints being able to refer to k8s secrets for password retrieval.How to test this PR locally
Try all the set of available commands:
./metricbeat keystore create
./metricbeat keystore add ES_PWD
./metricbeat keystore add ES_PWD --force
echo "passpass" | ./metricbeat keystore add ES_PWD --stdin --for
./metricbeat keystore list
./metricbeat keystore remove ES_PWD
Create a key and consume it (Elastic Cloud auth or any other ES setting can be used as an example):
./metricbeat keystore add ES_PWD
./metricbeat -e -d "*" -E "cloud.id=testkeys:xxxx" -E "cloud.auth=\${ES_PWD}"
or
./metricbeat keystore add ES_HOST
./metricbeat -e -d "*" -E output.elasticsearch.hosts=["\${ES_HOST}"]
Related issues