-
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
Implement k8s secrets provider for Agent #24789
Merged
Merged
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
996850e
wip
ChrsMark fa16391
save dynamic provider working state
ChrsMark 0b582b3
Working state
ChrsMark a0ad168
fix config
ChrsMark bb4fc0c
fixes
ChrsMark a2d9051
Add code to fetch secret from k8s api
ChrsMark 5e1dad2
fmt
ChrsMark be9f7b1
fix function call
ChrsMark 898e9cb
clear code parts
ChrsMark c731628
improvements
ChrsMark 5d20635
break when matched
ChrsMark da4a3d8
fix docstring
ChrsMark 68d3ea7
fix broken tests
ChrsMark 5db6cad
review changes
ChrsMark 5a85afb
Add interface implementation guard
ChrsMark eea350a
Remove comment
ChrsMark f023688
wip
ChrsMark 72cccc7
Add lookupNode function
ChrsMark ae81eb1
Fix package name
ChrsMark fb8a33e
Add changelog
ChrsMark 2332aec
Add vars test
ChrsMark 7a0bdcf
Merge remote-tracking branch 'upstream/master' into add_k8s_secrets
ChrsMark 22b5857
Add test for k8s_secrets provider
ChrsMark 7551ef5
Add extra test
ChrsMark e47bb5a
lint
ChrsMark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
x-pack/elastic-agent/pkg/composable/providers/kubernetes_secrets/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
// TODO review the need for this | ||
// +build linux darwin windows | ||
|
||
package kubernetes_secrets | ||
|
||
// Config for kubernetes provider | ||
type Config struct { | ||
KubeConfig string `config:"kube_config"` | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that getting a value from a fetch context provider returns something other than a string?
Below you can see that it will replace full objects if its a
varString
. I worry based on placing this before theswitch val.(type)
we are missing that as a possibility with a fetch context provider.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, however no strong opinion here since I'm not super familiar with the combinations that could occur. Do you think that removing
continue
and being able to get to theswitch
block after theFetch()
action would be sth that we want?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I took a closer look at this file. This is definitely in the wrong place. At its current location it would try to find a constant string in a fetch context provider, we do not want that.
Looking at it, this needs to be removed from here and moved into the:
Leaving this function untouched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blakerouse I tried to move (see f023688) the code inside
func (v *Vars) Lookup(name string) (interface{}, bool)
method of the same file but it does not seem to work (using same configuration so far) and I'm not sure that I can follow the flow here. I see that the method is called atbeats/x-pack/elastic-agent/pkg/eql/visitor.go
Line 281 in 01eb297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see the issue. You need to do the following:
Add the following function to
Vars
:Then change
node, ok := Lookup(v.tree, val.Value())
tonode, ok := v.lookupNode(val.Value())
.See if that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 This fixes the issue, thank you!