Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[PostgreSQL connection in Kubernetes]

Chiusa Adatta ai principianti
#417 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@github-actions ci sta già lavorando.

Dal 24/9/2026.

  • #418 di @github-actions — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, docker-compose, kubernetes, postgresql

Direzione di ricerca

Inizia individuando il file o l’indice per i contributi alle FAQ del repository relativo al corso ai-dev-tools-zoomcamp, quindi leggi le voci vicine e le eventuali indicazioni per i contributi. Documenta la spiegazione del DNS di localhost rispetto a Service, la configurazione postgres:5432 e i controlli del caricamento delle immagini di kind; il lavoro è completo quando la risposta è individuabile, accurata e coerente con il formato del repository.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
7
Fork
19
Merge medio
11g 23h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DataTalksClub/faq

Tutte le issue di DataTalksClub/faq

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.