For developers
This documentation helps to set-up a developer environment and writing plugins for the Logging operator.
Setting up Kind
-
Install Kind on your computer
-
Create cluster
-
Install prerequisites (this is a Kubebuilder makefile that will generate and install crds)
-
Run the Operator
Writing a plugin
To add a plugin
to the logging operator you need to define the plugin struct.
Note: Place your plugin in the corresponding directory
pkg/sdk/logging/model/filter
orpkg/sdk/logging/model/output
The plugin uses the JSON tags to parse and validate configuration. Without tags the configuration is not valid. The fluent
parameter name must match with the JSON tag. Don’t forget to use omitempty
for non required parameters.
Implement ToDirective
To render the configuration you have to implement the ToDirective
function.
For simple Plugins you can use the NewFlatDirective
function.
For more example please check the available plugins.
Reuse existing Plugin sections
You can embed existing configuration for your plugins. For example modern Output
plugins have Buffer
section.
If you are using embedded sections you must call its ToDirective
method manually and append it as a SubDirective
Special plugin tags
To document the plugins logging-operator uses the Go tags
(like JSON tags). Logging operator uses plugin
named tags for special instructions.
Special tag default
The default tag helps to give default
values for parameters. These parameters are explicitly set in the generated fluentd configuration.
Special tag required
The required tag ensures that the attribute cannot be empty
Add plugin to the Logging operator API
Enable your plugin for users when using the output/flow
CRDs by adding it to the proper Logging operator API type.
- Output Plugin - OutputSpec
- Filter Plugin - Filter
Generate documentation for Plugin
The operator parse the docstrings
for the documentation.
Will generate the following Markdown
Variable Name | Default | Applied function |
---|---|---|
AwsAccessKey | AWS access key id |
You can hint default values in docstring via (default: value)
. This is useful if you don’t want to set default explicitly with tag
. However during rendering defaults in tags
have priority over docstring.
Special docstrings
+docName:"Title for the plugin section"
+docLink:"Buffer,./buffer.md"
You can declare document title and description above the type _doc* interface{}
variable declaration.
Example Document headings:
Example Plugin headings:
Example linking embedded sections
Generate resources for your Plugin
Run the following command to generate updated docs and CRDs for your new plugin.