Transport Nginx Access Logs into Kafka with Logging operator

This guide describes how to collect application and container logs in Kubernetes using the Logging operator, and how to send them to Kafka.
The following figure gives you an overview about how the system works. The Logging operator collects the logs from the application, selects which logs to forward to the output, and sends the selected log messages to the output. For more details about the Logging operator, see the Logging operator overview.

Deploy Kafka
This demo uses Koperator to create an Apache Kafka cluster in Kubernetes. For details on installing it, see the Koperator installation guide.
Deploy the Logging operator and a demo Application
Install the Logging operator and a demo application to provide sample log messages.
Deploy the Logging operator with Helm
To install the Logging operator using Helm, complete the following steps.
Note: You need Helm v3.8 or later to be able to install the chart from an OCI registry.
- 
Install the Logging operator into the logging namespace:
Expected output:
Note:
- 
Helm has a known issue in version 3.13.0 that requires users to log in to the registry, even though the repo is public.
Upgrade to 3.13.1 or higher to avoid having to log in, see: https://github.com/kube-logging/logging-operator/issues/1522
 - 
If you’re installing the Helm chart from Terraform, reference the repository as
repository = "oci://ghcr.io/kube-logging/helm-charts/"(without thelogging-operatorsuffix). Otherwise, you’ll get a 403 Forbidden error. 
 - 
 - 
Create the
loggingresource.Note: You can use the
ClusterOutputandClusterFlowresources only in thecontrolNamespace. - 
Create a Kafka
outputdefinition.Note: In production environment, use a longer
timekeyinterval to avoid generating too many objects. - 
Create a
flowresource. - 
Install log-generator to produce logs with the label
app.kubernetes.io/name: log-generator 
Validate the deployment
Run the following command to consume some log messages from Kafka:
Expected output:
If you don’t get the expected result you can find help in the troubleshooting section.