<p>I am a newbie to Kubernetes. Recently, I am asked to set up Scylla on AWS. I followed the tutorial to deploy Scylla on EKS (<a href="http://operator.docs.scylladb.com/master/eks.html" rel="nofollow noreferrer">http://operator.docs.scylladb.com/master/eks.html</a>). Everything went well.</p>
<p>Then, I followed <em>Accessing the Database</em> section in another related tutorial (<a href="http://operator.docs.scylladb.com/master/generic.html" rel="nofollow noreferrer">http://operator.docs.scylladb.com/master/generic.html</a>).</p>
<p>I was able to run the commands for the first two steps:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl exec -n scylla -it scylla-cluster-us-east-1-us-east-1a-0 -- cqlsh
&gt; DESCRIBE KEYSPACES;
</code></pre>
<pre class="lang-sh prettyprint-override"><code>kubectl -n scylla describe service scylla-cluster-client
</code></pre>
<p>However, I don't know how to perform the last step, which said:</p>
<blockquote>
<p>Pods running inside the Kubernetes cluster can use this Service to connect to Scylla. Here’s an example using the Python Driver:</p>
<pre class="lang-py prettyprint-override"><code>from cassandra.cluster import Cluster
cluster = Cluster(['scylla-cluster-client.scylla.svc'])
session = cluster.connect()
</code></pre>
</blockquote>
<p>The script fails to resolve <code>scylla-cluster-client.scylla.svc</code>.
Therefore, I also tried different IPs, but <code>cassandra.cluster.NoHostAvailable</code> error is encountered.</p>
<p>In addition, I found that <code>pip</code> is not installed after connecting to the cluster via</p>
<pre class="lang-sh prettyprint-override"><code>kubectl exec -n scylla -it scylla-cluster-us-east-1-us-east-1a-0 -- /bin/bash
</code></pre>
<p>Can anyone help me solve the connection issue using Python driver?</p>
<p>It would be great if you can tell me:</p>
<ol>
<li>Why scylla-cluster-client.scylla.svc does not work for me?</li>
<li>What is the different between <code>kubectl exec -n ...</code>  and Cassandra drivers?</li>
<li>Which IPs should I use? I noticed that there are cluster IPs from Kubernetes, internal IPs from Kubernetes, and public IPs of the EC2 machines from AWS. If public IP is needed, do I need to open the ports (e.g. 9042) on AWS? How to make it more secure?</li>
</ol>
<p>Thanks in advance.</p>

Paco Wong
<ol>
<li><code>scylla-cluster-client.scylla.svc</code> is a k8s resolvable DNS address, so only works from pods hosted on the same cluster (and namespace). You can't use it from the outside</li>
<li><code>kubectl</code> exec runs a command on one of the Scylla pods, so essentially you are running the command on the Scylla node itself and connecting to <code>localhost</code> on that node. In contrast, <code>scylla-cluster-client.scylla.svc</code> is connecting remotely (but within the k8s network)</li>
<li>You don't need to use an IP - use the <code>scylla-cluster-client.scylla.svc</code> DNS name. If you want to use IP addresses you can manually resolve the DNS name or read the IP addresses of the Scylla pods using the k8s API - but there's really no reason to do that.
If you want to connect from outside the cluster you would need a public service or something like that - basically a k8s managed proxy. In theory you could allow the public pods but that's highly inadvisable.</li>
</ol>
