删除Deployment后没有删除Replicaset和Pods

what 发表于: 2023-06-28   最后更新时间: 2023-06-28 11:41:41   1,086 游览

Kubernetes版本是: 1.27.2
安装方式: kubeadm
主机OS: Ubuntu 20.04.4 LTS
CNI和版本: calico v3.26.0
CRI和版本: containerd v1.6.2

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: stacksimplify/kube-nginxapp1:1.0.0
        ports:
        - containerPort: 80

部署后输出:

NAME                                              READY   STATUS    RESTARTS   AGE
pod/nginx-deployment-7d94b5f487-7q2hd             1/1     Running   0          8s

NAME                                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx-deployment             1/1     1            1           8s

NAME                                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-deployment-7d94b5f487             1         1         1       8s

之后我运行:kubectl delete deploy nginx-deployment

NAME                                              READY   STATUS    RESTARTS   AGE
pod/nginx-deployment-7d94b5f487-7q2hd             1/1     Running   0          5m22s

NAME                                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-deployment-7d94b5f487             1         1         1       5m23s

即使我运行:kubectl delete deploy nginx-deployment --cascade=background, replicasets 和 pods 也不会被删除。

我该怎么做呢?

谢谢!

发表于 2023-06-28

Calico的问题。
从 v3.26.0 升级到 v3.26.1 解决了这个问题。

你的答案

查看kubernetes相关的其他问题或提一个您自己的问题