How to expose a headless service for a StatefulSet cassandra cluster externally in Kubernetes
It depends on what exactly you are trying to do. If you need an external IP then in general you'd need to create an additional Service object (probably type: LoadBalancer
) like this:
apiVersion: v1kind: Servicemetadata: labels: app: cassandra name: cassandra-extspec: type: LoadBalancer ports: - port: 9042 selector: app: cassandra
If you need to reach it from within the cluster then use the DNS name cassandra-0.cassandra.default
from the other pod (if the StatefulSet was deployed in the default namespace)
apiVersion: v1kind: Servicemetadata: labels: app: cassandra name: cassandra-extspec: type: LoadBalancer ports: - port: 9042 selector: app: cassandra
Using the additonal service gave me a External IP and because if which i started connecting my spark or devcenter application to cassandra cluster.