<p>I saw that Cassandra client needs an array of hosts.</p>

<p>For example, Python uses this:</p>

<pre><code>from cassandra.cluster import Cluster

cluster = Cluster(['192.168.0.1', '192.168.0.2'])
</code></pre>

<ul>
<li>source: <a href="http://datastax.github.io/python-driver/getting_started.html" rel="nofollow noreferrer">http://datastax.github.io/python-driver/getting_started.html</a></li>
</ul>

<p>Question 1: Why do I need to pass these nodes?</p>

<p>Question 2: Do I need to pass all nodes? Or is one sufficient? (All nodes have the information about all other nodes, right?)</p>

<p>Question 3: Does the client choose the best node to connect knowing all nodes? Does the client know what data is stored in each node?</p>

<p>Question 4: I'm starting to use Cassandra for the first time, and I'm using Kubernetes for the first time. I deployed a Cassandra cluster with 3 Cassandra nodes. I deployed another one machine and in this machine, I want to connect to Cassandra by a Python Cassandra client. Do I need to pass all the Cassandra IPs to Python Cassandra client? Or is it sufficient to put the Cassandra DNS given by Kubernetes?</p>

<p>For example, when I run a <code>dig</code> command, I know all the Cassandra IPs. I don't know if it's sufficient to pass this DNS to the client</p>

<pre><code># dig cassandra.default.svc.cluster.local
</code></pre>

<p>The IPs are <code>10.32.1.19</code>, <code>10.32.1.24</code>, <code>10.32.2.24</code></p>

<pre><code>; &lt;&lt;&gt;&gt; DiG 9.10.3-P4-Debian &lt;&lt;&gt;&gt; cassandra.default.svc.cluster.local
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 18340
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;cassandra.default.svc.cluster.local. IN    A

;; ANSWER SECTION:
cassandra.default.svc.cluster.local. 30 IN A 10.32.1.19
cassandra.default.svc.cluster.local. 30 IN A 10.32.1.24
cassandra.default.svc.cluster.local. 30 IN A 10.32.2.24

;; Query time: 2 msec
;; SERVER: 10.35.240.10#53(10.35.240.10)
;; WHEN: Thu Apr 04 16:08:06 UTC 2019
;; MSG SIZE  rcvd: 125
</code></pre>

<p>What are the disadvantages of using for example:</p>

<pre><code>from cassandra.cluster import Cluster

cluster = Cluster(['cassandra.default.svc.cluster.local'])
</code></pre>

<blockquote>
  <p>Question 1: Why do I need to pass these nodes?</p>
</blockquote>

<p>To make initial contact with the cluster. If the connection is made then there is no use with these contact points.</p>

<blockquote>
  <p>Question 2: Do I need to pass all nodes? Or is one sufficient? (All
  nodes have the information about all other nodes, right?)</p>
</blockquote>

<p>You can pass only one node as contact point but the problem is if that node is down when the driver tries to contact then, it won't be able to connect to cluster. So if you provide another contact point it will try to connect with it even if the first one failed. It would be better if you use your Cassandra seed list as contact points.</p>

<blockquote>
  <p>Question 3: Does the client choose the best node to connect knowing
  all nodes? Does the client know what data is stored in each node?</p>
</blockquote>

<p>Once the initial connection is made the client driver will have the metadata about the cluster. The client will know what data is stored in each node and also which node can be queried with less latency. you can configure all these using load balancing policies</p>

<p>Refer: <a href="https://docs.datastax.com/en/developer/python-driver/3.10/api/cassandra/policies/" rel="nofollow noreferrer">https://docs.datastax.com/en/developer/python-driver/3.10/api/cassandra/policies/</a></p>

<blockquote>
  <p>Question 4: I'm starting to use cassandra for first time, and I'm
  using kubernetes for the first time. I deployed a cassandra cluster
  with 3 cassandra nodes. I deployed another one machine and in this
  machine I want to connect to cassandra by a Python Cassandra client.
  Do I need to pass all cassandra IPs to Python Cassandra client? Or is
  it sufficient to put the cassandra DNS given by Kubernetes?</p>
</blockquote>

<p>If the hostname can be resolved then it is always better to use DNS instead of IP. I don't see any disadvantage.</p>
