-
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
Add kubernetes composable inputs provider #21480
Conversation
|
||
p.logger.Debugf("Initializing a new Kubernetes watcher using node: %v", p.config.Node) | ||
|
||
watcher, err := kubernetes.NewWatcher(client, &kubernetes.Pod{}, kubernetes.WatchOptions{ |
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.
Do we have in mind how/if we will handle different resources other than Pods? Like Services and Nodes?
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.
Not yet, I'm only adding Pods in this PR as a first step. I will open an issue to discuss more resources
e608e99
to
9875eb9
Compare
0f75d9f
to
bd3d009
Compare
Pinging @elastic/integrations-platforms (Team:Platforms) |
client, err := kubernetes.GetKubernetesClient(p.config.KubeConfig) | ||
if err != nil { | ||
// info only; return nil (do nothing) | ||
p.logger.Infof("Kubernetes provider skipped, unable to connect: %s", err) |
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.
Being that this will occur on most hosts not in Kubernetes, should this be Debugf
?
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.
good point, I added a message for the cases where this succeeds
composable.Providers.AddDynamicProvider("kubernetes", DynamicProviderBuilder) | ||
} | ||
|
||
type kubernertesContainerData struct { |
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 struct seems to be unused.
// Emit all containers in the pod | ||
p.emitContainers(pod, pod.Spec.Containers, pod.Status.ContainerStatuses) | ||
|
||
// TODO deal with init containers stopping after initialization |
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.
Whats the TODO mean here? Does this mean that AddOrUpdate
will be called for InitContainers but the Remove
will never be called? That seems like it will leak then in the provider, if that is correct.
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.
No, right now Remove
will be called when the Pod stops, so inputs won't leak.
The thing is that these containers may stop before the Pod itself, we should be able to detect this and stop them earlier.
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.
Ah, okay.
Pinging @elastic/ingest-management (Team:Ingest Management) |
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 is looking good, I like how providers can be implemented in the agent.
Is there a place to add the documentation?
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.
Looks good. Seems like a good start.
// Emit all containers in the pod | ||
p.emitContainers(pod, pod.Spec.Containers, pod.Status.ContainerStatuses) | ||
|
||
// TODO deal with init containers stopping after initialization |
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.
Ah, okay.
@exekias looks good what are the remaining steps/next steps for this? |
Thanks for the reviews! @ph my plan was to get this in for 7.10 and open some follow up issues to discuss next steps. Does that sound good to you? |
I am ok to merge it as is and do followup after. |
* Add kubernetes composable inputs provider (cherry picked from commit d6ee968)
What does this PR do?
Add
kubernetes
dynamic provider for Pods, this will allow to launch input configurations for discovered Pods in a Kubernetes cluster. Example config:Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Closes #19271