SQL Processor Deployment
This page describes how to configure the agent to deploy and manage SQL Processors for stream processing.
Lenses can be used to define & deploy stream processing applications that read from Kafka and write back to Kafka with SQL. They are based on the Kafka Stream framework. They are known as SQL Processors.
SQL processing of real-time data can run in 2 modes:
SQL In-Process - the workload runs inside of the Lenses Agent.
SQL in Kubernetes - the workload runs & scale on your Kubernetes cluster.
Which mode the SQL Processors will run as should be defined within the lenses.conf before Lenses is started.
In-Process Mode
In this mode, SQL processors run as part of the Agent process, sharing resources, memory, and CPU time with the rest of the platform.
Set the execution configuration to IN_PROC
# Set up Lenses SQL processing engine
lenses.sql.execution.mode = "IN_PROC"Set the directory to store the internal state of the SQL Processors:
lenses.sql.state.dir = "/tmp/sql-kstream-state"TLS connections to Kafka and Schema Registries
SQL processors use the same connection details that Agent uses to speak to Kafka and Schema Registry. The following properties are mounted, if present, on the file system for each processor:
Kafka
SSLTruststore
SSLKeystore
Schema Registry
SSL Keystore
SSL Truststore
The file structure created by applications is the following: /run/[lenses_installation_id]/applications/
Kubernetes Mode
Kubernetes can be used to deploy SQL Processors. To configure Kubernetes, set the mode to KUBERNETES and configure the location of the kubeconfig file.
When the Agent is deployed inside Kubernetes, the lenses.kubernetes.config.file configuration entry should be set to an empty string. The Kubernetes client will auto-configure from the pod it is deployed in.
The SQL Processor docker image is live in Dockerhub.
Allowed images
The image of a SQL Processor can be changed after it is created. Use lenses.kubernetes.processor.image.allowed to control which images it may be changed to. When the setting is not set, any tag or digest of the repository in lenses.kubernetes.processor.image.name is allowed.
An entry without a tag or digest, such as
lensesioextra/sql-processor, allows any tag or digest of that repository. Names are normalised as Docker does, solensesioextra/sql-processoranddocker.io/lensesioextra/sql-processorare the same repository.An entry with a tag or digest allows exactly that image.
"*"allows any image. It is the only wildcard.Entries are matched exactly. An entry is not a prefix:
registry.example.com/mirrordoes not coverregistry.example.com/mirror/sql-processor, andregistry.example.com/mirror/*is invalid and stops the Agent from starting.
The Agent refuses to start if an entry is not a valid image reference, or if the list does not allow the default image (lenses.kubernetes.processor.image.name and .tag). For this reason an empty list is not a valid setting. The Agent also refuses to start when lenses.kubernetes.processor.image.name and .tag together do not form a valid image reference, even if allowed is not set. These checks apply when lenses.sql.execution.mode is KUBERNETES. A change to an image that is not allowed is rejected with a message listing the allowed images.
This is useful if you mirror the SQL Processor image in a private registry:
When running the Agent in Docker, set the value as a JSON array with each item quoted:
Set this variable only with the Lenses Agent 6.3.1 image or later. Earlier images write the value as a quoted string, and an entry with a tag or digest then makes the configuration invalid, so the Agent won't start.
Security Context
If your cluster enforces Pod Security Standards or an admission policy (e.g. OPA/Gatekeeper) that requires specific pod or container security settings, such as running as non-root or dropping Linux capabilities, you can set a securityContext on the SQL Processor pod and on its containers:
Each block accepts any field the Kubernetes API's PodSecurityContext (pod) or SecurityContext (container) types support, so it can satisfy whatever a cluster's admission policy requires.
Custom Serdes
Custom serdes should be embedded in a new Lenses SQL processor Docker image.
To build a custom Docker image, create the following directory structure:
Copy your serde jar files under processor-docker/serde.
Create Dockerfile containing:
Build the Docker.
Once the image is deployed in your registry, please set Lenses to use it (lenses.conf):
Grant the Agent Kubernetes permissions to deploy processors
The Agent needs Kubernetes API permissions to deploy and manage SQL Processors. There are two ways to grant them:
Namespace-scoped
Role/RoleBindingresources — recommended. The Agent can only deploy into, and read pod/secret information from, the namespace(s) you explicitly list.Cluster-wide RBAC (Helm's
rbacEnable: trueplusnamespaceScope: false) — grants access across every namespace in the cluster. Use this only when you cannot enumerate the target namespaces in advance; see Cluster-wide RBAC below. NotenamespaceScopedefaults totrue, sorbacEnable: truealone gives you a namespace-scoped Role, not a ClusterRole.
Namespace-scoped RBAC (recommended)
Create a Role and a RoleBinding resource in the namespace you want the processors deployed to:
example for:
Lenses namespace =
lenses-nsProcessor namespace =
lenses-proc-ns
Define in the Agent configuration which namespaces it can access. To achieve this amend values.yaml to contain the following:
example:
Cluster-wide RBAC (not recommended)
Alternatively, activate RBAC at the cluster level through Helm values.yaml. Both values are required — namespaceScope defaults to true, so rbacEnable: true on its own produces a namespace-scoped Role, not a ClusterRole:
Last updated
Was this helpful?

