Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

    1. SSLTruststore

    2. SSLKeystore

  • Schema Registry

    1. SSL Keystore

    2. 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, so lensesioextra/sql-processor and docker.io/lensesioextra/sql-processor are 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/mirror does not cover registry.example.com/mirror/sql-processor, and registry.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.

The lenses.kubernetes.processor.image.allowed setting is available from Lenses Agent 6.3.1. On earlier versions it is ignored in lenses.conf; for the Docker environment variable, see below.

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.

Deprecated: typed processor security context fields

The older lenses.kubernetes.processor.security.context.{runAsUser,runAsGroup,runAsNonRoot,fsGroup} config is deprecated in favour of lenses.kubernetes.pod.security.context above, which covers the same fields plus anything else PodSecurityContext supports. It keeps working as a fallback when pod.security.context isn't set, but new deployments should use the new property.

runAsUser and runAsGroup must both be set for this fallback to apply. If either is missing, no pod security context is applied at all.

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/RoleBinding resources — 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: true plus namespaceScope: 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. Note namespaceScope defaults to true, so rbacEnable: true alone gives you a namespace-scoped Role, not a ClusterRole.

These permissions are for the Agent. From Lenses Agent 6.3.1, SQL Processor pods do not mount a Kubernetes API token (automountServiceAccountToken: false), since processors do not call the Kubernetes API. They still run as the service account set in lenses.kubernetes.service.account, so its image pull secrets still apply. To apply this to processors deployed by an earlier Agent, stop and start them. No configuration change is needed.

Create a Role and a RoleBinding resource in the namespace you want the processors deployed to:

example for:

  • Lenses namespace = lenses-ns

  • Processor namespace = lenses-proc-ns

You can repeat this for as many namespaces you may want Lenses to have access to.

Define in the Agent configuration which namespaces it can access. To achieve this amend values.yaml to contain the following:

example:

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?