<p>I've read like a dozen tutorials like <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">these</a> and many answers like <a href="https://stackoverflow.com/questions/46535057/how-do-pods-on-the-same-node-communicate-with-each-other">these</a> but they couldn't help me. I have a service like</p>
<ul>
<li>if I have this said service, what do I need to do/use to send the files?</li>
</ul>
<p>For clarification: I have 2 pods <strong>A</strong> and <strong>B</strong> (both have 1 container each with standard Python Docker images) and wish to send files back and forth. So if I have the service, I have the port(s) and then I can use the combination of IP:port to send the files e.g. by creating a (TCP) server and a client Python? Or is there a &quot;more Kubernetes-like&quot; way to do this?</p>
<p>The service I created using Python:</p>
<pre><code>def create_service(core_v1_api):
    body = client.V1Service(
        api_version=&quot;v1&quot;,
        kind=&quot;Service&quot;,
        metadata=client.V1ObjectMeta(
            name=&quot;banking-svc&quot;
        ),

        spec=kube_setup.client.V1ServiceSpec(
            selector={&quot;app&quot;: &quot;my_app&quot;},
            type=&quot;ClusterIP&quot;,
            ports=[client.V1ServicePort(
                port=6666,
                target_port=6666,
                protocol=&quot;TCP&quot;
            )]
        )
    )
    core_v1_api.create_namespaced_service(namespace=&quot;default&quot;, body =body)
</code></pre>

topkek
<p>First, I would suggest reading <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">the official documentation</a>, which is a reasonably good introduction to the idea of a service in kubernetes.</p>
<blockquote>
<p>I have only roughly idea what to put into this service file (or these service files?)</p>
</blockquote>
<p>A service is just a pointer to one (or more) network services provided by your pods.</p>
<p>For example, if you have a pod running Postgres on port 5432, you might create a service named &quot;database&quot; that will map connections to <code>database:5432</code> to port 5432 on your pod:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: database
spec:
  selector:
    app: postgres
  ports:
    - name: postgres
      port: 5432
</code></pre>
<p>There are two main parts to <code>service.spec</code>:</p>
<ul>
<li><p><code>selector</code> identifies the pod or pods that actually provide the
service. Here, we're saying that this service will round-robin among
any pods with label <code>app</code> equal to <code>postgres</code>.</p>
</li>
<li><p><code>ports</code> describes the ports on which we listen and the correspond
port in the pod. Here, we're mapping port <code>5432</code> to a port named
<code>postgres</code> in matching pods. That assumes you've set up your ports
with names, like this:</p>
<pre><code>...
ports:
  - name: postgres
    containerPort: 5432
...
</code></pre>
<p>If you haven't assigned names to your ports, you can use
<code>targetPort</code> instead in your service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: database
spec:
  selector:
    app: postgres
  ports:
    - targetPort: 5432
      port: 5432
</code></pre>
</li>
</ul>
<p>With the above service in place, pods in the same namespace can connect to the host <code>database</code> on port <code>5432</code> in order to interact with Postgres.</p>
<blockquote>
<p>if I have this said service, what do I need to do/use to send the files?</p>
</blockquote>
<p>If you have two pods (let's call them <code>pod1</code> and <code>pod2</code>), and you want each pod to initiate connections to the other pod, create two services, one with a selector that matches <code>pod1</code> and the other with a selector that matches <code>pod2</code>.</p>
<p>The name you give your service is the hostname to which you will connect from inside a pod.</p>
