<p>Hello I have problem with connect directly to choosen pod from other namespace. I checked nslookup and dns for my pod is <code>kafka-0.kafka-headless-svc.message-broker.svc.cluster.local</code> and when I ping from same ns everything is ok, problem is when I try same on other ns. When I try something like this <code>kafka.message-broker.svc.cluster.local</code> everything is fine, but I want to connect to specific pod, not that choosen by balancer. My configs:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: kafka
  name: kafka
  namespace: message-broker
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kafka
    spec:
      containers:
        - env:
            - name: KAFKA_ZOOKEEPER_CONNECT
              value: zookeeper.message-broker.svc.cluster.local
            - name: KAFKA_LISTENERS
              value: PLAINTEXT://kafka-0:9092
            - name: KAFKA_ADVERTISED_LISTENERS
              value: PLAINTEXT://kafka-0:9092
          image: wurstmeister/kafka
          imagePullPolicy: IfNotPresent
          name: kafka
          ports:
            - containerPort: 9092
              name: kafka
  serviceName: &quot;kafka-headless-svc&quot;
  selector:
    matchLabels:
      app: kafka
</code></pre>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: kafka
  name: kafka
  namespace: message-broker
spec:
  clusterIP: None
  selector:
    app: kafka
  ports:
    - port: 9092
      targetPort: 9092
      protocol: TCP
</code></pre>
<p>I doing everything on minikube so maybe there is some problem with networkpolicy (I didn't set any)</p>

Lukasz
<p>Problem resolved. I had to set <code>serviceName</code> from StatefulSet (in my example &quot;kafka-headless-svc&quot;) same as <code>metadata.name</code> from my Service file</p>
