API Pod Spec

Writing BookNest's API Pod Specification

Anatomy of a Pod Manifest's manifest encodes a few decisions. An explicit image tag keeps the IfNotPresent pull policy. Readiness uses /ready, which queries PostgreSQL 1,289 , and liveness /health, which does not, so a slow database takes the Pod out of service without restarting it (Probes and Resources). A memory limit caps leaks; no CPU limit avoids throttling. runAsNonRoot refuses a root image. The Pod still needs a database named db: until StatefulSets and PostgreSQL's StatefulSet, kubectl 5,150 run --expose creates a throwaway PostgreSQL Pod plus a Service (Services and Cluster DNS):

Giving the waiting API Pod a database, then querying itShell
docker tag postgres:18 localhost:33500/postgres:18
docker push -q localhost:33500/postgres:18 >/dev/null
kubectl run db --image=localhost:33500/postgres:18 --port=5432 --expose \
  --env=POSTGRES_USER=booknest --env=POSTGRES_PASSWORD=booknest
kubectl wait --for=condition=Ready pod/api --timeout=180s
kubectl get pod api -o custom-columns=NAME:.metadata.name,IP:.status.podIP,NODE:.spec.nodeName
kubectl logs api -c api
kubectl exec api -c api -- node -e "fetch('http://localhost:3000/api/books/3')
  .then(r => r.json()).then(b => console.log(b.id, b.title, b.price))"
Output
pod/db created
service/db created
pod/api condition met
NAME   IP            NODE
api    10.244.1.11   l3-booknest-worker
BookNest API listening on http://localhost:3000
3 Salt and Saffron 24

The init container saw the port open and exited; the API created the schema, seeded six books and turned Ready. This single Pod created the schema before Deployments and Rollouts starts replicas that would otherwise race to create it. But a bare Pod is fragile: delete it or lose its node, and nothing brings it back.