Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[PostgreSQL connection in Kubernetes]

Cerrado Apto para principiantes
#417 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@github-actions ya está trabajando en esto.

Desde el 24/9/2026.

  • #418 de @github-actions — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, docker-compose, kubernetes, postgresql

Línea de trabajo

Comienza localizando el archivo o índice de contribuciones de las FAQ del repositorio para el curso ai-dev-tools-zoomcamp y, después, lee las entradas cercanas y cualquier guía de contribución. Documenta la explicación de DNS de localhost frente a Service, la configuración de postgres:5432 y las comprobaciones de carga de imágenes de kind; se considera terminado cuando la respuesta es fácil de encontrar, precisa y coherente con el formato del repositorio.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

faq-proposal
Course

ai-dev-tools-zoomcamp

Question

When deploying Agent Relay and PostgreSQL from Docker Compose to a local kind Kubernetes cluster, why does Agent Relay fail to connect to PostgreSQL when the database host is set to localhost, and what should be changed?

Answer

localhost refers to the current container/pod, not to another Kubernetes service. Therefore, when Agent Relay runs in its own pod, setting the PostgreSQL host to localhost makes it try to find PostgreSQL inside the Agent Relay container.

The solution is to expose PostgreSQL through a Kubernetes Service and use the Service DNS hostname as the database host.

For example, if the PostgreSQL Service is named:

apiVersion: v1
kind: Service
metadata:
  name: postgres
spec:
  selector:
    app: postgres
  ports:
    - port: 5432
      targetPort: 5432

Agent Relay should connect using:

postgres:5432

instead of:

localhost:5432

The PostgreSQL connection configuration should therefore use the Kubernetes Service name, for example:

postgresql://<user>:<password>@postgres:5432/<database>

After applying the Kubernetes manifests, the connection can be verified from the Agent Relay pod with:

kubectl get pods
kubectl get services
kubectl logs deployment/agent-relay

This is different from Docker Compose, where the Compose service name can also be used for container-to-container communication. In Kubernetes, the equivalent mechanism is the Kubernetes Service and its DNS name.

For a local kind cluster, the Agent Relay image also needs to be available inside the cluster. If the image is built locally, it can be loaded with:

docker build -t agent-relay:local .
kind load docker-image agent-relay:local

Then the Kubernetes Deployment can reference:

image: agent-relay:local
imagePullPolicy: IfNotPresent

This allows the locally built Agent Relay image to run in kind without requiring the image to be pushed to a remote registry.

Checklist
  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links
Lenguaje dominante
Python
Estrellas
7
Forks
20
Merge medio
7 d 9 h
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DataTalksClub/faq

Todos los issues de DataTalksClub/faq

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.