Repository navigation
feat(fluentd): add ports to expose inputs the operator can't derive ports for - #2090
Conversation
joshuabaird
left a comment
There was a problem hiding this comment.
Thanks for this, it looks good. It follows the same pattern as the Collector, and the generated files all line up. This branch currently conflicts with master, but only in the generated CRD files (the three fluentd.fluent.io_fluentds.yaml copies and manifests/setup/setup.yaml). Rebasing onto master and rerunning make generate manifests should fix it.
A few non-blocking things:
-
Port names.
ContainerPort.nameis optional, but a Service with more than one port needs every port named. If someone sets aforwardinput and adds an unnamed entry tospec.ports, creating the Service will fail. Could we either requirename(a CEL rule on the field would work) or at least mention it in the field description? -
Duplicate ports. If an entry in
spec.portsuses the same port and protocol as theforwardorhttpinput, the pod is accepted but the Service is rejected. A short note in the docs would probably be enough here. -
Test coverage. Could you add a case that combines a
forwardinput withspec.ports? That would cover port ordering and the multi-port Service, which is where issue 1 shows up. A table-driven test would also make it easier to add cases later.
…orts for Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
eef61f3 to
693bb99
Compare
|
Thanks for the review! Rebased onto master and regenerated with
I didn't run the tests locally this time and am relying on CI. |
joshuabaird
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround, LGTM.
What this PR does / why we need it:
Adds
spec.portsto the Fluentd CRD, a list ofContainerPorts like the FluentBit and Collector CRDs already have. Each port is added to the fluentd container (StatefulSet and DaemonSet) and to the fluentd Service.The operator only opens ports for the
forwardandhttpglobal inputs, because those are the only inputs whose port it knows. Any other input, such as a syslog source in acustomPlugin, listens on a port that is neither exposed on the container nor reachable through the Service. #1610 asks for exactly this ("or the fluentd CRD allows to specify ports like the fluentbit CRD"):The Service port uses the same
name,protocoland number as the container port, matching how the FluentBit Service handlesspec.ports. Whenportsisn't set, nothing changes.Which issue(s) this PR fixes:
Fixes #1610
Does this PR introduced a user-facing change?
Notes
@cw-Guo suggested on the issue that managed plugins should get their ports derived automatically, and that still works as before. This PR covers the inputs the operator can't derive a port for, the same way FluentBit and Collector do.
I ran the generators (
make generate manifests docs-update, in a golang:1.26 container) rather than editing generated files by hand. They updated the deepcopy, the Fluentd CRDs (config, both charts,manifests/setup/setup.yaml) anddocs/fluentd.md.Tested locally:
go test ./pkg/operator/ ./apis/fluentd/... ./controllers/passes, including the newTestFluentdAdditionalPorts, which checks the container port and the Service port.go vetandgofmtare clean. I haven't run it against a live cluster.