Kubernetes部署Pod未能创建。

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

Kuberentes deployment Pod not getting created

问题

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

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

  1. Service Account: spring-boot
  2. Containers:
  3. consumer-container:
  4. Image: myrepo/repo:tagname
  5. Port: 8087/TCP
  6. Host Port: 0/TCP
  7. Requests:
  8. cpu: 500m
  9. memory: 512Mi
  10. Environment:
  11. SPRING_RABBITMQ_HOST: 172.17.0.2
  12. SPRING_RABBITMQ_USERNAME: guest
  13. SPRING_RABBITMQ_PASSWORD: guest
  14. SPRING_RABBITMQ_VIRTUAL_HOST: /
  15. Mounts: <none>
  16. Volumes: <none>
  17. Conditions:
  18. Type Status Reason
  19. ---- ------ ------
  20. ReplicaFailure True FailedCreate
  21. Events:
  22. Type Reason Age From Message
  23. ---- ------ ---- ---- -------
  24. 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 显示如下:

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

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

  1. docker system prune

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

  1. kubectl describe deployment/consumer-deployment
  2. Name: consumer-deployment
  3. Namespace: default
  4. CreationTimestamp: Mon, 12 Jun 2023 11:08:13 +0100
  5. Labels: app=consumer-app
  6. Annotations: deployment.kubernetes.io/revision: 1
  7. Selector: app=consumer-app
  8. Replicas: 1 desired | 0 updated | 0 total | 0 available | 1 unavailable
  9. StrategyType: RollingUpdate
  10. MinReadySeconds: 0
  11. RollingUpdateStrategy: 25% max unavailable, 25% max surge
  12. Pod Template:
  13. Labels: app=consumer-app
  14. Service Account: spring-boot
  15. Containers:
  16. consumer-container:
  17. Image: repo/myrepo:tagname
  18. Port: 8087/TCP
  19. Host Port: 0/TCP
  20. Requests:
  21. cpu: 500m
  22. memory: 512Mi
  23. Environment:
  24. SPRING_RABBITMQ_HOST: 172.17.0.2
  25. SPRING_RABBITMQ_USERNAME: guest
  26. SPRING_RABBITMQ_PASSWORD: guest
  27. SPRING_RABBITMQ_VIRTUAL_HOST: /
  28. Mounts: <none>
  29. Volumes: <none>
  30. Conditions:
  31. Type Status Reason
  32. ---- ------ ------
  33. Progressing True NewReplicaSetCreated
  34. Available False MinimumReplicasUnavailable
  35. ReplicaFailure True FailedCreate
  36. OldReplicaSets: <none>
  37. NewReplicaSet: consumer-deployment-8487d9fdf6 (0/1 replicas created)
  38. Events:
  39. Type Reason Age From Message
  40. ---- ------ ---- ---- -------
  41. 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

  1. Service Account: spring-boot
  2. Containers:
  3. consumer-container:
  4. Image: myrepo/repo:tagname
  5. Port: 8087/TCP
  6. Host Port: 0/TCP
  7. Requests:
  8. cpu: 500m
  9. memory: 512Mi
  10. Environment:
  11. SPRING_RABBITMQ_HOST: 172.17.0.2
  12. SPRING_RABBITMQ_USERNAME: guest
  13. SPRING_RABBITMQ_PASSWORD: guest
  14. SPRING_RABBITMQ_VIRTUAL_HOST: /
  15. Mounts: <none>
  16. Volumes: <none>
  17. Conditions:
  18. Type Status Reason
  19. ---- ------ ------
  20. ReplicaFailure True FailedCreate
  21. Events:
  22. Type Reason Age From Message
  23. ---- ------ ---- ---- -------
  24. 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

  1. Normal NodeHasNoDiskPressure 44m (x8 over 44m) kubelet Node docker-desktop status is now: NodeHasNoDiskPressure
  2. Normal NodeHasSufficientMemory 44m (x8 over 44m) kubelet Node docker-desktop status is now: NodeHasSufficientMemory
  3. Normal RegisteredNode 43m node-controller Node docker-desktop event: Registered Node docker-desktop in Controller
  4. Normal Starting 34m kubelet Starting kubelet.
  5. Normal NodeAllocatableEnforced 34m kubelet Updated Node Allocatable limit across pods
  6. Normal NodeHasSufficientMemory 34m (x8 over 34m) kubelet Node docker-desktop status is now: NodeHasSufficientMemory
  7. Normal NodeHasNoDiskPressure 34m (x8 over 34m) kubelet Node docker-desktop status is now: NodeHasNoDiskPressure
  8. Normal NodeHasSufficientPID 34m (x7 over 34m) kubelet Node docker-desktop status is now: NodeHasSufficientPID
  9. 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

  1. docker system prune

k describe deployment gives this

  1. kubectl describe deployment/consumer-deployment
  2. Name: consumer-deployment
  3. Namespace: default
  4. CreationTimestamp: Mon, 12 Jun 2023 11:08:13 +0100
  5. Labels: app=consumer-app
  6. Annotations: deployment.kubernetes.io/revision: 1
  7. Selector: app=consumer-app
  8. Replicas: 1 desired | 0 updated | 0 total | 0 available | 1 unavailable
  9. StrategyType: RollingUpdate
  10. MinReadySeconds: 0
  11. RollingUpdateStrategy: 25% max unavailable, 25% max surge
  12. Pod Template:
  13. Labels: app=consumer-app
  14. Service Account: spring-boot
  15. Containers:
  16. consumer-container:
  17. Image: repo/myrepo:tagname
  18. Port: 8087/TCP
  19. Host Port: 0/TCP
  20. Requests:
  21. cpu: 500m
  22. memory: 512Mi
  23. Environment:
  24. SPRING_RABBITMQ_HOST: 172.17.0.2
  25. SPRING_RABBITMQ_USERNAME: guest
  26. SPRING_RABBITMQ_PASSWORD: guest
  27. SPRING_RABBITMQ_VIRTUAL_HOST: /
  28. Mounts: <none>
  29. Volumes: <none>
  30. Conditions:
  31. Type Status Reason
  32. ---- ------ ------
  33. Progressing True NewReplicaSetCreated
  34. Available False MinimumReplicasUnavailable
  35. ReplicaFailure True FailedCreate
  36. OldReplicaSets: <none>
  37. NewReplicaSet: consumer-deployment-8487d9fdf6 (0/1 replicas created)
  38. Events:
  39. Type Reason Age From Message
  40. ---- ------ ---- ---- -------
  41. 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

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

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

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

英文:

The error is in the appended output you provided

  1. 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:

确定