LoggingTrait
The LoggingTrait custom resource contains the configuration for an additional logging sidecar with a custom image and Fluentd configuration file. Here is a sample ApplicationConfiguration that includes a LoggingTrait. To deploy an example application with this LoggingTrait, replace the ApplicationConfiguration of the ToDo-List example application with the following sample.
apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
name: todo-appconf
namespace: todo-list
annotations:
version: v1.0.0
description: "ToDo List example application"
spec:
components:
- componentName: todo-domain
traits:
- trait:
apiVersion: oam.verrazzano.io/v1alpha1
kind: LoggingTrait
metadata:
name: logging-trait-example
namespace: todo-list
spec:
loggingImage: fluent/fleuntd-example-image # Replace with custom Fluentd Image
loggingConfig: |-
# Replace with Fluentd config file
<match **>
@type stdout
</match>
- componentName: todo-jdbc-configmap
- componentName: todo-mysql-configmap
- componentName: todo-mysql-service
- componentName: todo-mysql-deployment
In this sample configuration, the LoggingTrait logging-trait-example
is set on the todo-domain
application component and defines a logging sidecar with the given Fluentd image and configuration file.
This sidecar will be attached to the component’s pod and will gather logs according to the given Fluentd configuration file.
In order for the Fluentd DaemonSet to collect the custom logs, the Fluentd configuration file needs to direct the logs to STDOUT
, as demonstrated in the previous example.
For example, when the ToDo-List example ApplicationConfiguration is successfully deployed with a LoggingTrait, the tododomain-adminserver
pod will have a container named logging-stdout
.
$ kubectl get pods tododomain-adminserver -n todo-list -o jsonpath='{.spec.containers[*].name}'
... logging-stdout ...
In this example, the logging-stdout
container will run the image given in the LoggingTrait and a ConfigMap named logging-stdout-todo-domain-domain
will be created with the custom Fluentd configuration file.
LoggingTrait
Field | Type | Description | Required |
---|---|---|---|
apiVersion |
string | oam.verrazzano.io/v1alpha1 |
Yes |
kind |
string | LoggingTrait | Yes |
metadata |
ObjectMeta | Refer to Kubernetes API documentation for fields of metadata. | No |
spec |
LoggingTraitSpec | The desired state of a logging trait. | Yes |
LoggingTraitSpec
LoggingTraitSpec specifies the desired state of a logging trait.
Field | Type | Description | Required |
---|---|---|---|
loggingConfig |
string | A string representation of the Fluentd configuration. | Yes |
loggingImage |
string | The name of the custom Fluentd image. | Yes |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.