Skip to content
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

feat: add fluent bit config-reload via HTTP #1286

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ type Service struct {
EmitterName string `json:"emitterName,omitempty"`
EmitterMemBufLimit string `json:"emitterMemBufLimit,omitempty"`
EmitterStorageType string `json:"emitterStorageType,omitempty"`
// If true enable reloading via HTTP
HotReload *bool `json:"hotReload,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to utilize this flag if enabled?
In which version it's added to fluentbit?
@wanjunlei pls take a look

Copy link
Contributor Author

@jiuxia211 jiuxia211 Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On how to use this flag can see https://docs.fluentbit.io/manual/administration/hot-reload
The version added to fluentbit should be v2.1 https://fluentbit.io/announcements/v2.1.0/

Copy link
Member

@benjaminhuo benjaminhuo Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've already add --enable-hot-reload flag in fluentbit watcher:
https://github.com/fluent/fluent-operator/blob/master/cmd/fluent-watcher/fluentbit/main.go#L76C20-L76C39

And the config will be reload whenever there is a config change by sending SIGHUP signal:
https://github.com/fluent/fluent-operator/blob/master/cmd/fluent-watcher/fluentbit/main.go#L126

FluentBit doc says Fluent Bit supports the hot reloading feature when enabled via the configuration file or command line with -Y or --enable-hot-reload option. which means it's not necessary to add it to configfiles because the command line arg already works.

And fluent operator already supports HTTP settings https://github.com/fluent/fluent-operator/pull/1286/files#diff-7aad9bf9eeeaa93f3a61c5ea93ea5a30d57bcfa6307ec4ea188222fdf69f438cR99-R105

image

@wanjunlei what do you think? do we need to add the hot reload flag to configfiles?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fluentbit already supports hot reload via the --enable-hot-reload flag, so there is no need to add Hot_Reload to theconfig file.

Copy link
Member

@wenchajun wenchajun Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several main reasons for adding this parameter:

  1. The reason for debugging. Because fluent-operator wraps the watcher layer, you can only restart the process by restarting the container or changing the configuration of the CR when debugging, restarting the container will be more troublesome and changing the configuration is not easy to locate the problem, so we need a way to send a signal to restart manually for hot loading.
  2. This parameter is one of the officially recommended ways to use this can also be harmonized with the official.
  3. Historical legacy issues, before the signal for hot loading in the watcher layer has been changed, due to the fluentbit version upgrade, so the signal to trigger hot loading has also been changed, and the way through the http is compatible with the lower version, but also for the sake of unity.
  4. Compared to the practice of adding parameters in the watcher layer, I think it is also a simple way to configure directly in the configuration file.
  5. Some users have suggested using multiple hot-loading methods before, so I think this is needed for some users, and this addition does not affect the original architecture.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have nicely explained this!

}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -223,6 +225,9 @@ func (s *Service) Params() *params.KVs {
m.Insert("storage.delete_irrecoverable_chunks", s.Storage.DeleteIrrecoverableChunks)
}
}
if s.HotReload != nil {
m.Insert("Hot_Reload", fmt.Sprint(*s.HotReload))
}
return m
}

Expand Down
5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
6 changes: 6 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down Expand Up @@ -16070,6 +16073,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
6 changes: 6 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down Expand Up @@ -16070,6 +16073,9 @@ spec:
Note: Enabling this will not automatically configure kubernetes
to use fluentbit''s healthcheck endpoint'
type: boolean
hotReload:
description: If true enable reloading via HTTP
type: boolean
httpListen:
description: Address to listen
pattern: ^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$
Expand Down
Loading