diff --git a/apis/fluentbit/v1alpha2/clusterinput_types.go b/apis/fluentbit/v1alpha2/clusterinput_types.go index 91b92b433..c7abc3d2f 100644 --- a/apis/fluentbit/v1alpha2/clusterinput_types.go +++ b/apis/fluentbit/v1alpha2/clusterinput_types.go @@ -19,14 +19,15 @@ package v1alpha2 import ( "bytes" "fmt" + "reflect" + "sort" + "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins" "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/custom" "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/input" "github.com/fluent/fluent-operator/v2/pkg/utils" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "reflect" "sigs.k8s.io/yaml" - "sort" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -75,6 +76,8 @@ type InputSpec struct { UDP *input.UDP `json:"udp,omitempty"` // KubernetesEvents defines the KubernetesEvents input plugin configuration KubernetesEvents *input.KubernetesEvents `json:"kubernetesEvents,omitempty"` + // ExecWasi defines the exec wasi input plugin configuration + ExecWasi *input.ExecWasi `json:"execWasi,omitempty"` // Processors defines the processors configuration // +kubebuilder:pruning:PreserveUnknownFields Processors *plugins.Config `json:"processors,omitempty"` diff --git a/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go b/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go new file mode 100644 index 000000000..e17233aa6 --- /dev/null +++ b/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go @@ -0,0 +1,73 @@ +package input + +import ( + "fmt" + + "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins" + "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params" +) + +// +kubebuilder:object:generate:=true + +// The exec_wasi input plugin, allows to execute WASM program that is WASI target like as external program and collects event logs from there. +// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/exec-wasi** +type ExecWasi struct { + // The place of a WASM program file. + WASIPath string `json:"wasiPath,omitempty"` + // Specify the name of a parser to interpret the entry as a structured message. + Parser string `json:"parser,omitempty"` + // Specify the whitelist of paths to be able to access paths from WASM programs. + AccessiblePaths []string `json:"accessiblePaths,omitempty"` + // Polling interval (seconds). + IntervalSec *int32 `json:"intervalSec,omitempty"` + // Polling interval (nanoseconds). + IntervalNSec *int64 `json:"intervalNSec,omitempty"` + // +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$" + WasmHeapSize string `json:"wasmHeapSize,omitempty"` + // Size of the stack size of Wasm execution. Review unit sizes for allowed values. + // +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$" + WasmStackSize string `json:"wasmStackSize,omitempty"` + // Size of the buffer (check unit sizes for allowed values) + // +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$" + BufSize string `json:"bufSize,omitempty"` + // Indicates whether to run this input in its own thread. Default: false. + Threaded *bool `json:"threaded,omitempty"` +} + +func (_ *ExecWasi) Name() string { + return "exec_wasi" +} + +// Params implement Section() method +func (w *ExecWasi) Params(_ plugins.SecretLoader) (*params.KVs, error) { + kvs := params.NewKVs() + + if w.WASIPath != "" { + kvs.Insert("WASI_Path", w.WASIPath) + } + if w.Parser != "" { + kvs.Insert("Parser", w.Parser) + } + for _, p := range w.AccessiblePaths { + kvs.Insert("Accessible_Paths", p) + } + if w.IntervalSec != nil { + kvs.Insert("Interval_Sec", fmt.Sprint(*w.IntervalSec)) + } + if w.IntervalNSec != nil { + kvs.Insert("Interval_NSec", fmt.Sprint(*w.IntervalNSec)) + } + if w.WasmHeapSize != "" { + kvs.Insert("Wasm_Heap_Size", w.WasmHeapSize) + } + if w.WasmStackSize != "" { + kvs.Insert("Wasm_Stack_Size", w.WasmStackSize) + } + if w.BufSize != "" { + kvs.Insert("Buf_Size", w.BufSize) + } + if w.Threaded != nil { + kvs.Insert("Threaded", fmt.Sprint(*w.Threaded)) + } + return kvs, nil +} diff --git a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go index ad10d8aeb..0f7b7f388 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go @@ -69,6 +69,41 @@ func (in *Dummy) DeepCopy() *Dummy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExecWasi) DeepCopyInto(out *ExecWasi) { + *out = *in + if in.AccessiblePaths != nil { + in, out := &in.AccessiblePaths, &out.AccessiblePaths + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.IntervalSec != nil { + in, out := &in.IntervalSec, &out.IntervalSec + *out = new(int32) + **out = **in + } + if in.IntervalNSec != nil { + in, out := &in.IntervalNSec, &out.IntervalNSec + *out = new(int64) + **out = **in + } + if in.Threaded != nil { + in, out := &in.Threaded, &out.Threaded + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExecWasi. +func (in *ExecWasi) DeepCopy() *ExecWasi { + if in == nil { + return nil + } + out := new(ExecWasi) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FluentbitMetrics) DeepCopyInto(out *FluentbitMetrics) { *out = *in diff --git a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go index f1122ec80..8942d1cae 100644 --- a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go @@ -1207,6 +1207,11 @@ func (in *InputSpec) DeepCopyInto(out *InputSpec) { *out = new(input.KubernetesEvents) (*in).DeepCopyInto(*out) } + if in.ExecWasi != nil { + in, out := &in.ExecWasi, &out.ExecWasi + *out = new(input.ExecWasi) + (*in).DeepCopyInto(*out) + } if in.Processors != nil { in, out := &in.Processors, &out.Processors *out = (*in).DeepCopy() diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml index 6e0b230b4..cdbaaaee3 100644 --- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml +++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml @@ -95,6 +95,48 @@ spec: plugin. type: string type: object + execWasi: + description: ExecWasi defines the exec wasi input plugin configuration + properties: + accessiblePaths: + description: Specify the whitelist of paths to be able to access + paths from WASM programs. + items: + type: string + type: array + bufSize: + description: Size of the buffer (check unit sizes for allowed + values) + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + intervalNSec: + description: Polling interval (nanoseconds). + format: int64 + type: integer + intervalSec: + description: Polling interval (seconds). + format: int32 + type: integer + parser: + description: Specify the name of a parser to interpret the entry + as a structured message. + type: string + threaded: + description: 'Indicates whether to run this input in its own thread. + Default: false.' + type: boolean + wasiPath: + description: The place of a WASM program file. + type: string + wasmHeapSize: + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + wasmStackSize: + description: Size of the stack size of Wasm execution. Review + unit sizes for allowed values. + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + type: object fluentBitMetrics: description: FluentBitMetrics defines Fluent Bit Metrics Input configuration. properties: diff --git a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml index 6e0b230b4..cdbaaaee3 100644 --- a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml @@ -95,6 +95,48 @@ spec: plugin. type: string type: object + execWasi: + description: ExecWasi defines the exec wasi input plugin configuration + properties: + accessiblePaths: + description: Specify the whitelist of paths to be able to access + paths from WASM programs. + items: + type: string + type: array + bufSize: + description: Size of the buffer (check unit sizes for allowed + values) + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + intervalNSec: + description: Polling interval (nanoseconds). + format: int64 + type: integer + intervalSec: + description: Polling interval (seconds). + format: int32 + type: integer + parser: + description: Specify the name of a parser to interpret the entry + as a structured message. + type: string + threaded: + description: 'Indicates whether to run this input in its own thread. + Default: false.' + type: boolean + wasiPath: + description: The place of a WASM program file. + type: string + wasmHeapSize: + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + wasmStackSize: + description: Size of the stack size of Wasm execution. Review + unit sizes for allowed values. + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + type: object fluentBitMetrics: description: FluentBitMetrics defines Fluent Bit Metrics Input configuration. properties: diff --git a/docs/fluentbit.md b/docs/fluentbit.md index 9d0ce1f43..d0c4218c1 100644 --- a/docs/fluentbit.md +++ b/docs/fluentbit.md @@ -461,6 +461,7 @@ InputSpec defines the desired state of ClusterInput | tcp | TCP defines the TCP input plugin configuration | *[input.TCP](plugins/input/tcp.md) | | udp | UDP defines the UDP input plugin configuration | *[input.UDP](plugins/input/udp.md) | | kubernetesEvents | KubernetesEvents defines the KubernetesEvents input plugin configuration | *[input.KubernetesEvents](plugins/input/kubernetesevents.md) | +| execWasi | ExecWasi defines the exec wasi input plugin configuration | *[input.ExecWasi](plugins/input/execwasi.md) | | processors | Processors defines the processors configuration | *plugins.Config | [Back to TOC](#table-of-contents) diff --git a/docs/plugins/fluentbit/filter/wasm.md b/docs/plugins/fluentbit/filter/wasm.md index 413aab784..fb565d86c 100644 --- a/docs/plugins/fluentbit/filter/wasm.md +++ b/docs/plugins/fluentbit/filter/wasm.md @@ -1,6 +1,6 @@ -# WASM +# Wasm -The Wasm Filter allows you to modify the incoming records using Wasm technology.
**For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/filters/wasm** +Wasm Filter allows you to modify the incoming records using Wasm technology. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/filters/wasm** | Field | Description | Scheme | @@ -8,7 +8,6 @@ The Wasm Filter allows you to modify the incoming records using Wasm technology. | wasmPath | Path to the built Wasm program that will be used. This can be a relative path against the main configuration file. | string | | eventFormat | Define event format to interact with Wasm programs: msgpack or json. Default: json | string | | functionName | Wasm function name that will be triggered to do filtering. It's assumed that the function is built inside the Wasm program specified above. | string | -| accessiblePaths | Specify the whitelist of paths to be able to access paths from WASM programs. | string | +| accessiblePaths | Specify the whitelist of paths to be able to access paths from WASM programs. | []string | | wasmHeapSize | Size of the heap size of Wasm execution. Review unit sizes for allowed values. | string | | wasmStackSize | Size of the stack size of Wasm execution. Review unit sizes for allowed values. | string | - diff --git a/docs/plugins/fluentbit/input/exec_wasi.md b/docs/plugins/fluentbit/input/exec_wasi.md new file mode 100644 index 000000000..f54a6863f --- /dev/null +++ b/docs/plugins/fluentbit/input/exec_wasi.md @@ -0,0 +1,16 @@ +# ExecWasi + +The exec_wasi input plugin, allows to execute WASM program that is WASI target like as external program and collects event logs from there. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/exec-wasi** + + +| Field | Description | Scheme | +| ----- | ----------- | ------ | +| wasiPath | The place of a WASM program file. | string | +| parser | Specify the name of a parser to interpret the entry as a structured message. | string | +| accessiblePaths | Specify the whitelist of paths to be able to access paths from WASM programs. | []string | +| intervalSec | Polling interval (seconds). | *int32 | +| intervalNSec | Polling interval (nanoseconds). | *int64 | +| wasmHeapSize | | string | +| wasmStackSize | Size of the stack size of Wasm execution. Review unit sizes for allowed values. | string | +| bufSize | Size of the buffer (check unit sizes for allowed values) | string | +| threaded | Indicates whether to run this input in its own thread. Default: false. | *bool | diff --git a/manifests/setup/fluent-operator-crd.yaml b/manifests/setup/fluent-operator-crd.yaml index fc8d3b0be..baba69777 100644 --- a/manifests/setup/fluent-operator-crd.yaml +++ b/manifests/setup/fluent-operator-crd.yaml @@ -2208,6 +2208,48 @@ spec: plugin. type: string type: object + execWasi: + description: ExecWasi defines the exec wasi input plugin configuration + properties: + accessiblePaths: + description: Specify the whitelist of paths to be able to access + paths from WASM programs. + items: + type: string + type: array + bufSize: + description: Size of the buffer (check unit sizes for allowed + values) + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + intervalNSec: + description: Polling interval (nanoseconds). + format: int64 + type: integer + intervalSec: + description: Polling interval (seconds). + format: int32 + type: integer + parser: + description: Specify the name of a parser to interpret the entry + as a structured message. + type: string + threaded: + description: 'Indicates whether to run this input in its own thread. + Default: false.' + type: boolean + wasiPath: + description: The place of a WASM program file. + type: string + wasmHeapSize: + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + wasmStackSize: + description: Size of the stack size of Wasm execution. Review + unit sizes for allowed values. + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + type: object fluentBitMetrics: description: FluentBitMetrics defines Fluent Bit Metrics Input configuration. properties: diff --git a/manifests/setup/setup.yaml b/manifests/setup/setup.yaml index e3cd82eca..10962ed81 100644 --- a/manifests/setup/setup.yaml +++ b/manifests/setup/setup.yaml @@ -2208,6 +2208,48 @@ spec: plugin. type: string type: object + execWasi: + description: ExecWasi defines the exec wasi input plugin configuration + properties: + accessiblePaths: + description: Specify the whitelist of paths to be able to access + paths from WASM programs. + items: + type: string + type: array + bufSize: + description: Size of the buffer (check unit sizes for allowed + values) + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + intervalNSec: + description: Polling interval (nanoseconds). + format: int64 + type: integer + intervalSec: + description: Polling interval (seconds). + format: int32 + type: integer + parser: + description: Specify the name of a parser to interpret the entry + as a structured message. + type: string + threaded: + description: 'Indicates whether to run this input in its own thread. + Default: false.' + type: boolean + wasiPath: + description: The place of a WASM program file. + type: string + wasmHeapSize: + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + wasmStackSize: + description: Size of the stack size of Wasm execution. Review + unit sizes for allowed values. + pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$ + type: string + type: object fluentBitMetrics: description: FluentBitMetrics defines Fluent Bit Metrics Input configuration. properties: