Change:
The namespace seems to be hard coded :
cc:
Thanks. We can improve it after v1 release.

Discussion:
There are a few things to note in this description.  First is that we are running the ```kubernetes/cassandra``` image.  This is a standard Cassandra installation on top of Debian.  However it also adds a custom [```SeedProvider```](https://svn.apache.org/repos/asf/cassandra/trunk/src/java/org/apache/cassandra/locator/SeedProvider.java) to Cassandra.  In Cassandra, a ```SeedProvider``` bootstraps the gossip protocol that Cassandra uses to find other nodes.  The ```KubernetesSeedProvider``` discovers the Kubernetes API Server using the built in Kubernetes discovery service, and then uses the Kubernetes API to find new nodes (more on this later) <del> You may also note that we are setting some Cassandra parameters (```MAX_HEAP_SIZE``` and ```HEAP_NEWSIZE```).  We also tell Kubernetes that the container exposes both the ```CQL``` and ```Thrift``` API ports.  Finally, we tell the cluster manager that we need 0.5 cpu (0.5 core). </del> <ins> You may also note that we are setting some Cassandra parameters (```MAX_HEAP_SIZE``` and ```HEAP_NEWSIZE```) and adding information about the [namespace](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/namespaces.md).  We also tell Kubernetes that the container exposes both the ```CQL``` and ```Thrift``` API ports.  Finally, we tell the cluster manager that we need 0.5 cpu (0.5 core). </ins> Given this configuration, we can create the pod from a file specification as follows

value: 512M - name: HEAP_NEWSIZE value: 100M <ins> - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace </ins> image: gcr.io/google_containers/cassandra:v4 name: cassandra ports:

value: 512M - name: HEAP_NEWSIZE value: 100M <ins> - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace </ins> volumes: - name: data emptyDir: {}

@JsonIgnoreProperties(ignoreUnknown = true) static class Address { <del> public String IP; </del> <ins> public String ip; </ins> } @JsonIgnoreProperties(ignoreUnknown = true)

List<InetAddress> list = new ArrayList<InetAddress>(); String host = "https://kubernetes.default.cluster.local"; String serviceName = getEnvOrDefault("CASSANDRA_SERVICE", "cassandra"); <del> String path = "/api/v1/namespaces/default/endpoints/"; </del> <ins> String podNamespace = getEnvOrDefault("POD_NAMESPACE", "default"); String path = String.format("/api/v1/namespaces/%s/endpoints/", podNamespace); </ins> try { String token = getServiceAccountToken();

ctx.init(null, trustAll, new SecureRandom()); URL url = new URL(host + path + serviceName); <ins> logger.info("Getting endpoints from " + url); </ins> HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); // TODO: Remove this once the CA cert is propogated everywhere, and replace

if (endpoints.subsets != null && !endpoints.subsets.isEmpty()){ for (Subset subset : endpoints.subsets) { for (Address address : subset.addresses) { <del> list.add(InetAddress.getByName(address.IP)); </del> <ins> list.add(InetAddress.getByName(address.ip)); </ins> } } } <del> } </del> <ins> logger.info("Available endpoints: " + list); } else { logger.warn("Endpoints are not available"); } </ins> } catch (IOException | NoSuchAlgorithmException | KeyManagementException ex) { logger.warn("Request to kubernetes apiserver failed", ex); }