A newer version of this documentation is available.

View Latest

Connecting Couchbase Clients

    The Kubernetes networking model poses some challenges when interacting with a Couchbase cluster that is running on Kubernetes.

    This page outlines some of the ways that Couchbase clients can connect with the cluster.

    From a Pod in the Same Kubernetes Cluster

    The recommended network model also happens to be the simplest: Run the client from a pod in the same Kubernetes cluster.

    When a new Couchbase cluster is created, the Operator also creates a headless service which creates A records for each Couchbase node, and an SRV record for the cluster as a whole.

    To create a connection to the cluster from within the overlay (as a pod in the same Kubernetes cluster) you should use the SRV record to perform service discovery:

    from couchbase.cluster import Cluster
    c = Cluster('couchbase://{}-srv.default.svc.cluster.local'.format(cluster_name))

    Where the domain is composed of my-cluster, which is the name of the CouchbaseCluster resource, the namespace, and the domain of the cluster. Note that we use a separate service record to only advertise nodes with the Data Service enabled. This provides optimal bootstrapping of Couchbase clients.

    From Outside of the Kubernetes Cluster

    Couchbase SDKs are clients in exactly the same way as XDCR.

    Please refer to the client network requirements for a general overview of client connectivity, and the XDCR documentation for more detailed deployment scenarios and client configurations.