Search code examples
kubernetesdocker-desktop

Kuberentes deployment Pod not getting created


My spring is deployed on kubernetes using docker desktop it was working ok its scale up and down suddenly the deployement get stuck in 0/1 with 0 availebal pod

kubectl describe replicaset consumer-deployment-8487d9fdf6^C shows

 Service Account:  spring-boot
  Containers:
   consumer-container:
    Image:      myrepo/repo:tagname
    Port:       8087/TCP
    Host Port:  0/TCP
    Requests:
      cpu:     500m
      memory:  512Mi
    Environment:
      SPRING_RABBITMQ_HOST:          172.17.0.2
      SPRING_RABBITMQ_USERNAME:      guest
      SPRING_RABBITMQ_PASSWORD:      guest
      SPRING_RABBITMQ_VIRTUAL_HOST:  /
    Mounts:                          <none>
  Volumes:                           <none>
Conditions:
  Type             Status  Reason
  ----             ------  ------
  ReplicaFailure   True    FailedCreate
Events:
  Type     Reason        Age                 From                   Message
  ----     ------        ----                ----                   -------
  Warning  FailedCreate  94s (x18 over 12m)  replicaset-controller  Error creating: pods "consumer-deployment-8487d9fdf6-" is forbidden: error looking up service account default/spring-boot: serviceaccount "spring-boot" not found

Kubectl describe nodes shows this

  Normal   NodeHasNoDiskPressure    44m (x8 over 44m)    kubelet          Node docker-desktop status is now: NodeHasNoDiskPressure
  Normal   NodeHasSufficientMemory  44m (x8 over 44m)    kubelet          Node docker-desktop status is now: NodeHasSufficientMemory
  Normal   RegisteredNode           43m                  node-controller  Node docker-desktop event: Registered Node docker-desktop in Controller
  Normal   Starting                 34m                  kubelet          Starting kubelet.
  Normal   NodeAllocatableEnforced  34m                  kubelet          Updated Node Allocatable limit across pods
  Normal   NodeHasSufficientMemory  34m (x8 over 34m)    kubelet          Node docker-desktop status is now: NodeHasSufficientMemory
  Normal   NodeHasNoDiskPressure    34m (x8 over 34m)    kubelet          Node docker-desktop status is now: NodeHasNoDiskPressure
  Normal   NodeHasSufficientPID     34m (x7 over 34m)    kubelet          Node docker-desktop status is now: NodeHasSufficientPID
  Normal   RegisteredNode           33m                  node-controller  Node docker-desktop event: Registered Node docker-desktop in Controller


I tryed prune command and it remove about 6GB but the probleme still persist

docker system prune

k describe deployment gives this

kubectl describe deployment/consumer-deployment
Name:                   consumer-deployment
Namespace:              default
CreationTimestamp:      Mon, 12 Jun 2023 11:08:13 +0100
Labels:                 app=consumer-app
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=consumer-app
Replicas:               1 desired | 0 updated | 0 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:           app=consumer-app
  Service Account:  spring-boot
  Containers:
   consumer-container:
    Image:      repo/myrepo:tagname
    Port:       8087/TCP
    Host Port:  0/TCP
    Requests:
      cpu:     500m
      memory:  512Mi
    Environment:
      SPRING_RABBITMQ_HOST:          172.17.0.2
      SPRING_RABBITMQ_USERNAME:      guest
      SPRING_RABBITMQ_PASSWORD:      guest
      SPRING_RABBITMQ_VIRTUAL_HOST:  /
    Mounts:                          <none>
  Volumes:                           <none>
Conditions:
  Type             Status  Reason
  ----             ------  ------
  Progressing      True    NewReplicaSetCreated
  Available        False   MinimumReplicasUnavailable
  ReplicaFailure   True    FailedCreate
OldReplicaSets:    <none>
NewReplicaSet:     consumer-deployment-8487d9fdf6 (0/1 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  9m38s  deployment-controller  Scaled up replica set consumer-deployment-8487d9fdf6 to 1

Is there anythin else i need to look into it ??


Solution

  • The error is in the appended output you provided

      Warning  FailedCreate  94s (x18 over 12m)  replicaset-controller  Error creating: pods "consumer-deployment-8487d9fdf6-" is forbidden: error looking up service account default/spring-boot: serviceaccount "spring-boot" not found
    

    You are trying to create the deployment using a service account which, presumably, doesn't exist.