---
slug: "kubernetes-name-resolv-dns-another-pod"
title: "Communicating with Other Pods in Kubernetes"
description: "If within the same namespace, name resolution can be performed using the metadata.name of the Service."
url: "https://www.ytyng.com/en/blog/kubernetes-name-resolv-dns-another-pod"
publish_date: "2023-10-07T09:46:45Z"
created: "2023-10-07T09:46:45Z"
updated: "2026-02-26T05:20:57.906Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20250615/24cec32d468b4be7a087bc74cd27c774.png.webp?width=768"
has_video: true
has_music: true
video_urls: ["https://media.ytyng.net/ytyng-blog/293/featured-video-1.mp4", "https://media.ytyng.net/ytyng-blog/293/featured-video-2.mp4", "https://media.ytyng.net/ytyng-blog/293/featured-video-3.mp4"]
music_urls: ["https://media.ytyng.net/ytyng-blog/293/featured-music-293-3.mp3", "https://media.ytyng.net/ytyng-blog/293/featured-music-293-4.mp3"]
lang: "en"
---

# Communicating with Other Pods in Kubernetes

If it is within the same namespace, name resolution can be done using the `metadata.name` of the Service.

## Service

```yaml
apiVersion: v1
kind: Service
metadata:
  name: redis
  namespace: airflow
spec:
  ports:
    - name: "6379"
      port: 6379
      targetPort: 6379
```

With this configuration, you can resolve the name `redis` from other Pods.

```
redis://:@redis:6379/0
```

Similarly,

```yaml
apiVersion: v1
kind: Service
metadata:
  name: postgres
  namespace: airflow
spec:
  ports:
    - name: "5432"
      port: 5432
      targetPort: 5432
```

With this setup, you can resolve the name `postgres` as follows:

```
db+postgresql://username:password@postgres/airflow
postgresql+psycopg2://username:password@postgres/airflow
```
