Connect to kubernetes-aerospike mesh cluster from golang

4/20/2018

I am new to kubernetes. I successfully created a headless service for aerospike-kubernetes. I logged into docker container and verified that the mesh contains all the replicas. I have used https://github.com/aerospike/aerospike-kubernetes/blob/master/aerospike-statefulset.yaml for the same.

Now since its a headless service clusterIP is "none" and i am writing a golang program to connect to the aerospike. I am puzzled as to what should go in the IPaddress to connect to aerospike. What should i give in place of xxx-xxx-xxx-xxx ? how can i generate an Internal IP so that i can connect to the entire mesh?

client, err := as.NewClient("xxx-xxx-xxx-xxx", 3000)
if err != nil {
    log.Fatal(err)
}

This golang project will be deployed as a pod so an internal IP would suffice.

-- tony
aerospike
go
kubernetes

1 Answer

4/23/2018

headless service clusterIP is "none"

This simply means we don't use the load balancer/reverse proxy mode, but rather DNS Round-Robin mode for the service endpoint.

By default, visibility of the Aerospike cluster is limited to within the Kubernetes environment. You can use the service name generated by kube-dns to connect. The address would take the form of: <service>.<namespace>.svc.cluster.local. In other words: aerospike.aerospike-cluster-1.svc.cluster.local if you've left it as defaults.

-- Richard
Source: StackOverflow