Kubernetes部署Pod未能创建。

huangapple go评论62阅读模式
英文:

Kuberentes deployment Pod not getting created

问题

我的Spring应用部署在Kubernetes上,使用Docker Desktop。最初正常工作,但突然之间无法扩展,部署状态停在0/1,没有可用的Pod。

kubectl describe replicaset consumer-deployment-8487d9fdf6^C 显示如下:

 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 显示如下:

  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

我尝试使用 prune 命令删除了约6GB的内容,但问题仍然存在:

docker system prune

使用 k describe deployment 命令查看部署信息如下:

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

是否还有其他需要查看的内容?

英文:

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 ??

答案1

得分: 0

错误在你提供的附加输出中。

  警告  FailedCreate  94秒(在12分钟内重复18次)  replicaset-controller  创建错误:禁止创建 pod:"consumer-deployment-8487d9fdf6-":查找服务帐户default/spring-boot时发生错误:找不到服务帐户"spring-boot"

你正在尝试使用一个可能不存在的服务帐户来创建部署。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月12日 18:22:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455698.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定