Usage
The Listener Operator is used differently depending on whether you are using Stackable data platform operators or building custom applications.
For Stackable Data Platform Users
If you are using Stackable data platform operators (NiFi, Kafka, Druid, etc.), the Listener Operator works automatically behind the scenes when you specify a listenerClass
in your cluster configuration.
This example shows how it works for NiFi. Check the specific operator’s documentation for the exact configuration syntax:
apiVersion: nifi.stackable.tech/v1alpha1
kind: NifiCluster
metadata:
name: my-nifi
spec:
nodes:
roleConfig:
listenerClass: external-stable (1)
1 | The operator automatically creates listener volumes and configures networking |
What Happens Automatically
The Stackable operator will automatically:
-
Create Listener and Service resources based on your
listenerClass
-
Configure the appropriate service type (LoadBalancer, NodePort, ClusterIP) for your environment
-
Handle port remapping and expose the correct ports
-
Inject connection details into the application pods, making them aware of their own external addresses and ports
Finding Your Services
After deployment, you can find your services and connection information using the cluster and role names:
# List all services - look for services matching your cluster
kubectl get services
# For a NiFi cluster named "nifi", the service will typically be named:
# nifi-node (for the node role)
# List listeners (same names as services)
kubectl get listeners
# Get detailed connection information from the listener
kubectl get listener nifi-node -o yaml
The Listener status shows the exact addresses and ports for connections:
status:
ingressAddresses:
- address: 172.21.0.3
addressType: IP
ports:
https: 8443
-
From within Kubernetes: Use the service name (
nifi-node.<namespace>.svc.cluster.local
) -
From outside Kubernetes: Use the ingress addresses shown in the Listener status
Adapting Across Environments
The Stackable platform uses presets to automatically configure the right ListenerClasses for your environment. When installing the Listener Operator, you choose a preset that matches your infrastructure. You can change this preset or create entirely custom ListenerClasses.
Please see the dedicated ListenerClass documentation for details on the presets and how to customize ListenerClasses.
For Custom Applications
The operator creates a Listener for each mounted CSI volume with storageClassName: listeners.stackable.tech
.
A minimal exposed Pod
looks like this:
---
apiVersion: v1
kind: Pod
metadata:
name: example-public-pod
spec:
volumes:
- name: listener
ephemeral: (1)
volumeClaimTemplate:
metadata:
annotations:
listeners.stackable.tech/listener-class: external-stable (2)
spec:
storageClassName: listeners.stackable.tech
accessModes:
- ReadWriteMany
resources:
requests:
storage: "1"
containers:
- name: nginx
image: nginx
ports:
- name: http
containerPort: 80
volumeMounts:
- name: listener
mountPath: /listener (3)
1 | Defines an ephemeral listener, meaning that it will automatically be deleted when the Pod is. |
2 | Defines the accessibility of this pod by automatically creating a service according to the ListenerClass external-stable . |
3 | Mounts metadata about the Listener (such as the port mapping and IP address) into the pod’s /listener directory.
The volume must be mounted, even if this data is never used by the Pod itself. |
The exact ListenerClass is going to depend on the Kubernetes environment, but should often look like this for public clouds:
---
apiVersion: listeners.stackable.tech/v1alpha1
kind: ListenerClass
metadata:
name: external-stable
spec:
serviceType: LoadBalancer
Or like this for on-premise environments:
---
apiVersion: listeners.stackable.tech/v1alpha1
kind: ListenerClass
metadata:
name: external-stable
spec:
serviceType: NodePort
These are normally installed by the appropriate preset.