Pod Keep Failing and i dont know why

Minikube Version : 1.36.0
K8S Version : 1.33.1
Docker Version : 28.1.1
OS: WSL ubuntu 24.04

Minikube is running on Docker

Hey, new to k8s here and want to put my sample app docker images into k8s. but run into problem in the process.

my sample docker image(simple-store-server) created using docker compose and contains:

  • Postgres DB
  • Golang Code
version: '3.0'
services:
  postgres:
    image: postgres:12-alpine
    environment:
      - POSTGRES_USER=alpine12
      - POSTGRES_PASSWORD=password12
      - POSTGRES_DB=simple_store
    ports:
      - "5000:5432"
    volumes:
      - postgres_db:/var/lib/postgresql/data
    networks:
      - mynetwork
  server:
      build:
        context: .
        dockerfile: Dockerfile
      ports:
        - "2000:2000"
      environment:
        - DB_CONNECTION=postgresql://alpine12:password12@postgres:5432/simple_store?sslmode=disable
      depends_on:
        - postgres
      networks:
        - mynetwork
      entrypoint: ["/app/wait-for.sh","postgres:5432","--","/app/start.sh"]
      command: ["/app/main"]

volumes:
  postgres_db:
    driver: local

networks:
  mynetwork:
    external: true

next is all the steps i done in order to put my docker image inside k8s:
1.using Kompose to create a bunch of yaml file

kompose convert -f compose.yaml
INFO Network mynetwork is detected at Source, shall be converted to equivalent NetworkPolicy at Destination 
INFO Network mynetwork is detected at Source, shall be converted to equivalent NetworkPolicy at Destination 
INFO Kubernetes file "postgres-service.yaml" created 
INFO Kubernetes file "server-service.yaml" created 
INFO Kubernetes file "postgres-deployment.yaml" created 
INFO Kubernetes file "postgres-db-persistentvolumeclaim.yaml" created 
INFO Kubernetes file "mynetwork-networkpolicy.yaml" created 
INFO Kubernetes file "server-deployment.yaml" created 

2.Modify server-deployment file to add ImagePullPolicy and changing image because its referencing to the wrong image in docker

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f compose.yaml
    kompose.version: 1.26.0 (40646f47)
  creationTimestamp: null
  labels:
    io.kompose.service: server
  name: server
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: server
  strategy: {}
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f compose.yaml
        kompose.version: 1.26.0 (40646f47)
      creationTimestamp: null
      labels:
        io.kompose.network/mynetwork: "true"
        io.kompose.service: server
    spec:
      containers:
        - args:
            - /app/main
          command: ["/app/wait-for.sh", "postgres:5432", "--", "/app/start.sh"]
          env:
            - name: DB_CONNECTION
              value: postgresql://alpine12:password12@postgres:5432/simple_store?sslmode=disable
          image: simple-store-server   ## original value=server
          imagePullPolicy: Never
          name: server
          ports:
            - containerPort: 2000
          resources: {}
      restartPolicy: Always
status: {}

3.run kubectl apply on all file

kubectl apply -f postgres-service.yaml,server-service.yaml,postgres-deployment.yaml,postgres-db-persistentvolumeclaim.yaml,mynetwork-networkpolicy.yaml,server-deployment.yaml

service/postgres configured
service/server configured
deployment.apps/postgres configured
persistentvolumeclaim/postgres-db configured
networkpolicy.networking.k8s.io/mynetwork configured
deployment.apps/server configured

kubectl get pods

NAME                        READY   STATUS    RESTARTS   AGE
postgres-6b8b56c557-sn6vl   1/1     Running   0          8s
server-6b754c9f5c-2tjf7     1/1     Running   0          8s


kubectl get pods
NAME                        READY   STATUS    RESTARTS      AGE
postgres-6b8b56c557-sn6vl   1/1     Running   0             31s
server-6b754c9f5c-2tjf7     1/1     Running   1 (15s ago)   31s

kubectl get pods
NAME                        READY   STATUS             RESTARTS      AGE
postgres-6b8b56c557-sn6vl   1/1     Running            0             118s
server-6b754c9f5c-2tjf7     0/1     CrashLoopBackOff   3 (16s ago)   118s

here is my server pod logs:

kubectl logs server-6b754c9f5c-2tjf7

Operation timed out

Question:
1.why is “server” keep failing?
2.is it because the docker image?(miss matched name in steps 2 and i have to change it)
3.is “Operation Timed out” means my app cannot connect to db?(even though it works fine outside of k8s)

Can you run the command kubectl describe pod server-6b754c9f5c-2tjf7 to check the events that caused the crash?

Hello Brandon Thanks for replying my forum, here is my kubectl describe

Name:             server-6b754c9f5c-2tjf7
Namespace:        default
Priority:         0
Service Account:  default
Node:             minikube/192.168.58.2
Start Time:       Sun, 29 Jun 2025 21:21:05 +1000
Labels:           io.kompose.network/mynetwork=true
                  io.kompose.service=server
                  pod-template-hash=6b754c9f5c
Annotations:      kompose.cmd: kompose convert -f compose.yaml
                  kompose.version: 1.26.0 (40646f47)
Status:           Running
IP:               10.244.0.62
IPs:
  IP:           10.244.0.62
Controlled By:  ReplicaSet/server-6b754c9f5c
Containers:
  server:
    Container ID:  docker://4f1d4cf6d232be36f769da8265fddf9bb6eec0ee32b87977b8d1fd692fcc2e4a
    Image:         simple-store-server
    Image ID:      docker://sha256:e91c81ad9b2a181621c43ce1f41495cc77aa9ef5e230d4c46ac5a98dc17f544d
    Port:          2000/TCP
    Host Port:     0/TCP
    Command:
      /app/wait-for.sh
      postgres:5432
      --
      /app/start.sh
    Args:
      /app/main
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Tue, 01 Jul 2025 17:53:30 +1000
      Finished:     Tue, 01 Jul 2025 17:53:31 +1000
    Ready:          False
    Restart Count:  39
    Environment:
      DB_CONNECTION:  postgresql://alpine12:password12@postgres:5432/simple_store?sslmode=disable
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tnqww (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True
  Initialized                 True
  Ready                       False
  ContainersReady             False
  PodScheduled                True
Volumes:
  kube-api-access-tnqww:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    Optional:                false
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason          Age                       From             Message
  ----     ------          ----                      ----             -------
  Normal   Pulled          42h (x27 over 44h)        kubelet          Container image "simple-store-server" already present on machine
  Warning  BackOff         42h (x475 over 44h)       kubelet          Back-off restarting failed container server in pod server-6b754c9f5c-2tjf7_default(f25a8d74-8146-4651-a4cc-6fecc2ea6f3b)
  Normal   SandboxChanged  44m                       kubelet          Pod sandbox changed, it will be killed and re-created.
  Normal   Started         20m (x8 over 44m)         kubelet          Started container server
  Warning  NodeNotReady    17m (x3 over 28m)         node-controller  Node is not ready
  Normal   Created         11m (x11 over 44m)        kubelet          Created container: server
  Warning  BackOff         3m59s (x120 over 44m)     kubelet          Back-off restarting failed container server in pod server-6b754c9f5c-2tjf7_default(f25a8d74-8146-4651-a4cc-6fecc2ea6f3b)
  Normal   Pulled          <invalid> (x16 over 44m)  kubelet          Container image "simple-store-server" already present on machine