<p>I  have made a service.yaml and have created the service.</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: cass-operator-service
spec:
  type: LoadBalancer
  ports:
    - port: 9042
      targetPort: 9042
  selector:
    name: cass-operator
</code></pre>
<p>Is there a way to check on which pods the service has been applied?</p>
<p>I want that using the above service, I connect to a cluster in Google Cloud running Kubernetes/Cassandra on external_ip/port (9042 port). But using the above service, I am not able to.</p>
<p><code>kubectl get svc</code> shows</p>
<pre><code>NAME                    TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)          AGE
cass-operator-service   LoadBalancer   10.51.247.82   34.91.214.233   9042:31902/TCP   73s
</code></pre>
<p>So probably the service is listening on 9042 but is forwarding to pods in 31902. I want both ports to be 9042. Is it possible to do?</p>

Manu Chadha
<p>The best way is to follow labels and selectors.</p>
<p>Your pod has a label section, and the service uses it in the selector section. You can find some examples in the <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">official documentation for services</a>.</p>
<p>You can find the selectors of your service with:</p>
<pre><code>kubectl describe svc cass-operator-service
</code></pre>
<p>You can list your labels with:</p>
<pre><code>kubectl get pods --show-labels
</code></pre>
