我们在AWS上运行kubernetes集群 .
当我尝试删除部署时 - 副本集也会被删除 - 但是该pod仍然存在并且未被删除 .
当我重新部署时,我得到一个新的部署,新的副本集和一个新的pod(所以现在有2个可用...)
apiVersion: v1
kind: Service
metadata:
name: helloworld
labels:
app: helloworld
spec:
ports:
-
port: 80
targetPort: 10000
selector:
service: helloworld
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld
spec:
replicas: 1
revisionHistoryLimit: 0
selector:
matchLabels:
service: helloworld
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
service: helloworld
spec:
containers:
-
name: helloworld
image: 'my.service.io/service/helloworld:latest'
imagePullPolicy: Always
ports:
- containerPort: 10000
command:
- node
args:
- "app.js"
imagePullSecrets:
- name: my-screts
restartPolicy: Always
terminationGracePeriodSeconds: 30
删除部署和副本集时,为什么不删除pod?
5 回答
可能是pod未部署在Deployment对象中?你有没有机会手动部署这个Pod?如果是这种情况,则在删除部署时不会删除它 . 您是否可以尝试手动删除Pod并查看问题是否仍然存在?
您可能需要强制删除该窗格 . 运行命令
kubectl delete pod NAME --force --grace-period=0
取决于使用
- cascade [= true]
时是否删除我有同样的问题,可以通过手动删除它来解决它,如下所示:
1.获取部署
删除复制控制器/复制集后,您可以手动删除窗格和服务,与部署或rc相同 .
terminationGracePeriodSeconds: 30
表示删除部署后,pod将保留在列表中30秒 . 它将status: Terminating
.你确定你有足够的时间让pod正常终止吗?
您还可以将部署缩小到0个副本(
replicas: 0
),然后将其删除 .