skip to Main Content

After deployment, the pods, replicaset, and deployment are created successfully. However, when I try to delete the Deployment using kubectl delete deploy nginx-deployment, the pods and replicaset are not deleted.

My deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # 
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

I have also tried kubectl delete deploy nginx-deployment --cascade=background, but the issue persists. How should I proceed to ensure that the ReplicaSet and Pods are properly deleted when the Deployment is deleted?

Used software:

  • Kubernetes 1.27.2
  • Installed on Ubuntu 20.04.4 LTS
  • calico 3.26.0
  • containerd 1.6.24

2

Answers


  1. Chosen as BEST ANSWER

    This issue was solved by updating the calico version. Seems that there is an incompatibility issue.


  2. Im sure you are deleting something that does not exists on the current name space. Do this:

    1-get the deployment and its namespace

    kubectl get deployments –all-namespaces

    2-pass the namespace to the delete

    kubectl delete -n NAMESPACE deployment nginx-deployment

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search