Close Menu
GeekBlog

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Patrick Stewart Chose Aquamation Over Cremation. Here’s How Water Cremation Works.

    November 21, 2026

    Garmin Gives Your Dog a Profile: New Watch Update Adds Dog Workouts, Badges and Better Swim Tracking

    November 21, 2026

    Ashton Kutcher Turned $435 Million Into a $7 Billion Anthropic Stake. His Track Record Goes Back to Skype.

    November 21, 2026
    Facebook
    GeekBlog
    • Home
    • Mobile
    • Tech News
    • Blog
    • Gaming
    • Smartwatch
    • How-To Guides
    • AI & Software
    Facebook
    GeekBlog
    Home»Blog»How to Delete a Deployment in Minikube Safely
    Blog

    How to Delete a Deployment in Minikube Safely

    Ethan CaldwellBy Ethan CaldwellSeptember 4, 202610 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    Server rack in a data center
    Photo via Pexels
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link

    To delete a deployment in Minikube, run kubectl delete deployment <name>. Kubernetes removes the Deployment, then garbage collects its ReplicaSets and Pods in the background. What it does not touch is the Service you created to expose it, the ConfigMaps and Secrets it mounted, or any PersistentVolumeClaim it used. Those survive, and they are the reason a cluster you thought you cleaned up still has orphaned objects in it.

    Quick answer: Run kubectl delete deployment web -n dev. Add --cascade=orphan to keep the pods running, or --cascade=foreground to block until every pod is gone. Delete the matching Service separately with kubectl delete svc web -n dev, because deleting a Deployment never removes it.

    This guide covers deleting by name, by label and by manifest, what the three cascade strategies actually do, how to force a pod that will not terminate, and how to wipe a whole namespace when you have lost track. Commands were checked against minikube 1.38.1 running Kubernetes v1.35.1, and they are plain kubectl, so nothing here is Minikube specific.

    Deleting by name

    The simplest form. Note that kubectl prints a confirmation but never asks for one.

    # See what you have first
    kubectl get deployments -A
    
    kubectl delete deployment web
    # deployment.apps "web" deleted
    
    # In a specific namespace
    kubectl delete deployment web -n dev
    
    # Several at once
    kubectl delete deployment web api worker -n dev
    
    # Do not fail a script when it is already gone
    kubectl delete deployment web -n dev --ignore-not-found
    Tip: Add --dry-run=client to any delete command to see exactly which objects would be targeted without touching them. It is the cheapest possible insurance against deleting the right name in the wrong namespace.

    Deleting by label or by manifest

    Deleting by name breaks down as soon as an application is more than one object. Labels and manifests both scale better.

    # Everything the label selector matches
    kubectl delete deployment -l app=web -n dev
    
    # Deployment and Service and ConfigMap in one shot
    kubectl delete deployment,service,configmap -l app=web -n dev
    
    # Whatever this file created, gone
    kubectl delete -f web-deployment.yaml
    
    # A whole directory of manifests
    kubectl delete -f k8s/ --recursive
    
    # Every deployment in a namespace, which is blunt but occasionally what you want
    kubectl delete deployment --all -n dev

    The manifest form is the one to prefer in a project. If you created the resources with kubectl apply -f, deleting with the same file guarantees you remove precisely what you added, including the Service and the ConfigMap that a name based delete would have left behind.

    Cascade strategies explained

    A Deployment owns ReplicaSets, and each ReplicaSet owns Pods. The --cascade flag decides what happens to that chain. The Kubernetes documentation for kubectl delete describes it as selecting the deletion cascading strategy for the dependents, and it must be one of background, orphan or foreground.

    StrategyCommand returnsWhat happens to podsUse it when
    background (default)ImmediatelyGarbage collector removes them shortly afterAlmost always
    foregroundAfter dependents are goneDeleted first, then the DeploymentScripts that must not race the next step
    orphanImmediatelyKeep running, now unmanagedDebugging a pod after removing its controller
    # Block until the last pod is really gone
    kubectl delete deployment web -n dev --cascade=foreground
    
    # Keep the pods, drop the controller
    kubectl delete deployment web -n dev --cascade=orphan
    kubectl get pods -n dev          # still there, and now nothing will restart them
    
    # Wait explicitly instead, with a timeout
    kubectl delete deployment web -n dev --wait=true --timeout=60s

    Recommended for you:

    Can You Use Movie Clips in YouTube Videos? What the Law Actually Says
    Blog·Sep 3, 2026

    Can You Use Movie Clips in YouTube Videos? What the Law Actually Says

    Note: Orphaned pods are not adopted by anything. They keep the old ReplicaSet’s ownerReferences, they will not be rescheduled if the node goes away, and a later kubectl apply of the same Deployment may or may not adopt them depending on whether the labels still match. Treat orphan as a debugging tool, not a deployment strategy.

    What survives the delete

    This is the part that produces surprise leftovers. Deleting a Deployment removes only the Deployment and the objects that name it as an owner.

    ObjectDeleted with the Deployment?How to clean it up
    ReplicaSetsYes, they are ownedNothing to do
    PodsYes, unless you used orphanNothing to do
    ServiceNokubectl delete svc web
    ConfigMap and SecretNoDelete by name or by label
    PersistentVolumeClaimNokubectl delete pvc <name>
    IngressNoDelete by name or by manifest
    HorizontalPodAutoscalerNokubectl delete hpa <name>
    # Audit what is left after the deployment is gone
    kubectl get svc,cm,secret,pvc,ingress,hpa -n dev
    
    # A leftover PVC that still says Bound is holding a volume
    kubectl get pvc -n dev
    kubectl delete pvc data-web-0 -n dev

    On Minikube the storage class provisions from the node’s own disk, so a stale PVC is not costing you money the way it would on a cloud provider. It will still block a later apply if the new manifest asks for a different size or access mode, because those fields are immutable on an existing claim.

    Forcing a pod that will not terminate

    Occasionally a pod sits in Terminating long past its grace period. The usual causes are a container ignoring SIGTERM, a volume that will not unmount, or a finalizer waiting on a controller that no longer exists.

    # Find out why before you swing the hammer
    kubectl describe pod web-6d4b7c9f8-abcde -n dev | tail -30
    kubectl get pod web-6d4b7c9f8-abcde -n dev -o jsonpath='{.metadata.finalizers}'
    
    # Shorten the grace period, which is the polite escalation
    kubectl delete pod web-6d4b7c9f8-abcde -n dev --now
    
    # Last resort: drop it from the API server without waiting for the kubelet
    kubectl delete pod web-6d4b7c9f8-abcde -n dev --grace-period=0 --force
    
    # If a finalizer is the blocker, remove it explicitly
    kubectl patch pod web-6d4b7c9f8-abcde -n dev \
      -p '{"metadata":{"finalizers":null}}' --type=merge
    Warning: The kubectl documentation is explicit that --force is only used when grace period is zero, and that immediate deletion of some resources may result in inconsistency or data loss. It removes the object from the API server whether or not the container actually stopped. On a StatefulSet with a shared volume this can produce two writers at once. On a local Minikube cluster the blast radius is small, so it is a reasonable habit there and a bad one in production.

    --now is the gentler option: it is shorthand for a one second grace period rather than zero, so the kubelet still gets a chance to send SIGTERM before the container is killed.

    Cleaning a whole namespace or the whole cluster

    When the point is to get back to a clean slate, work at the namespace level rather than object by object.

    # Common workload kinds in one namespace
    kubectl delete all --all -n dev
    
    # The rest, which "all" does not cover
    kubectl delete cm,secret,pvc,ingress --all -n dev
    
    # Or just remove the namespace and everything in it
    kubectl delete namespace dev
    
    # Nuclear option: throw away the cluster itself
    minikube delete
    minikube delete --all --purge

    Be aware that kubectl delete all --all does not mean every object. The all shortcut covers a fixed set of workload and service kinds, and it excludes ConfigMaps, Secrets, PVCs, Ingresses and custom resources. That is why the second command is there. If you would rather start from a fresh namespace, see our guide on creating a namespace in Minikube.

    Scaling to zero instead of deleting

    Often what you actually want is to free the CPU and memory without losing the object. Scaling a Deployment to zero replicas terminates every pod and keeps the manifest, the rollout history and the Service wiring intact.

    kubectl scale deployment web --replicas=0 -n dev
    kubectl get deploy web -n dev
    # NAME   READY   UP-TO-DATE   AVAILABLE
    # web    0/0     0            0
    
    # Bring it back exactly as it was
    kubectl scale deployment web --replicas=3 -n dev

    On a laptop cluster this is usually the better move. It costs nothing to keep a Deployment at zero replicas, you avoid re applying manifests, and you keep the ability to roll back with kubectl rollout undo. Reserve deletion for when you genuinely want the object gone.

    Troubleshooting

    The deployment comes back after you delete it. Something is reconciling it. A Helm release, an Argo CD application or an operator will happily recreate the Deployment within seconds. Uninstall the release rather than deleting the object it manages.

    Pods keep restarting during the delete. You deleted the pods instead of the Deployment. The ReplicaSet immediately replaces them. Delete the Deployment itself and the ReplicaSet goes with it.

    Error: the server doesn’t have a resource type “deployment”. Almost always a typo or a missing kubeconfig. Confirm the cluster is reachable with kubectl cluster-info and that the profile is running with minikube status. You can find the cluster endpoint using our guide to getting the Minikube IP address.

    The delete hangs forever. You used --cascade=foreground and a pod is stuck terminating. Interrupt the command, force delete that pod, and the Deployment will finish on its own. Add --timeout=60s next time so a script fails instead of hanging.

    A service still resolves after the deployment is gone. Expected. The Service object survives and simply has no endpoints. Check with kubectl get endpoints web -n dev, which will show <none>, then delete the Service if you no longer need it.

    Frequently asked questions

    Recommended for you:

    Why Is Jack the Black Cat Squishmallow So Rare?
    Blog·Sep 3, 2026

    Why Is Jack the Black Cat Squishmallow So Rare?

    Does deleting a deployment delete its service?

    No. A Service is an independent object connected to pods only by a label selector, not by ownership. Delete it separately with kubectl delete svc <name>, or delete both together using a shared label or the manifest that created them.

    How do I delete a deployment without deleting its pods?

    Use kubectl delete deployment web --cascade=orphan. The pods keep running but nothing manages them any longer, so they will not be restarted or rescheduled. It is useful for inspecting a failing pod after removing whatever kept replacing it.

    Is minikube delete the same as deleting my deployments?

    No, it is far broader. minikube delete destroys the entire cluster including its virtual machine or container, every namespace, and all stored data. Use it when you want a clean cluster. Use kubectl when you want to remove one application.

    What is the difference between --now and --force?

    The first is shorthand for a one second grace period, so the container still receives SIGTERM. The second only applies with a zero grace period and removes the object from the API server without waiting for the kubelet to confirm. Try the first before the second.

    How can I see what a delete would remove before running it?

    Add --dry-run=client to the delete command. kubectl resolves the selector or file and prints the objects it would target without contacting the API server to remove them. Pair it with -o name for a clean list you can review.

    The bottom line

    For everyday work, kubectl delete deployment <name> -n <namespace> is all you need, and the default background cascade is the right choice. Reach for foreground when a script has to wait, and for orphan only when you are debugging.

    The habit worth building is deleting by manifest or by label rather than by name, because that is the only way you also catch the Service, ConfigMap and PVC that came along with the Deployment. When the cluster is truly beyond saving, minikube delete takes under a minute and you can rebuild from your manifests. If you are setting a cluster up from scratch, our walkthrough on installing Minikube on Windows 10 is the place to start.

    About this article: GeekBlog covers U.S. technology news, AI, phones, smartwatches and gaming. Every story is written and checked under our Editorial Policy. Spotted a mistake or have a story tip? Contact our editors.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email Copy Link
    Previous ArticleHow to Set Up Events in Google Analytics 4 (2026)
    Next Article How to Find Search Queries in Google Analytics 4
    Ethan Caldwell

      Ethan Caldwell is GeekBlog's resident Apple specialist, covering the entire Apple ecosystem: iPhone, iPad, Mac, Apple Watch, AirPods and the software that ties them together. A longtime iOS user and gadget collector, Ethan tracks Cupertino's every move, breaking down Apple keynotes, A- and M-series chip benchmarks, iOS feature updates and the rumor mill into clear, practical takes that help readers decide whether the latest Apple hardware is worth the upgrade.

      Related Posts

      10 Mins Read

      Google Ads Keyword Planner: How It Shows the Most Relevant Keywords

      11 Mins Read

      How to Use Remarketing Techniques for Better Conversions

      11 Mins Read

      How to Conduct A/B Testing for Marketing Campaigns

      10 Mins Read

      AMP for WP Plugin Vulnerability: What Was Fixed and What to Do

      11 Mins Read

      How to Create a Facebook Business Page in 2026

      11 Mins Read

      How to Convert GMT Time to Other Time Zones in C++

      Top Posts

      Every iPhone Camera Ranked in 2026 (Best to Worst)

      July 6, 2026393 Views

      Apple Watch Black Friday 2026: Early Deals, Prices to Beat and When to Buy

      November 8, 2026219 Views

      Best Browser for Android in 2026: Top Picks Ranked

      July 7, 2026188 Views
      Stay In Touch
      • Facebook

      Subscribe to Updates

      Get the latest tech news from FooBar about tech, design and biz.

      Most Popular

      Apple Watch Black Friday 2026: Early Deals, Prices to Beat and When to Buy

      November 8, 2026422 Views

      One UI 9 Watch: Which Galaxy Watches Get Wear OS 7, and Who Gets Left Behind

      November 6, 2026208 Views

      Garmin Lily 2 Review: Lily 2 vs Active vs Classic in 2026

      November 6, 2026118 Views
      Our Picks

      Patrick Stewart Chose Aquamation Over Cremation. Here’s How Water Cremation Works.

      November 21, 2026

      Garmin Gives Your Dog a Profile: New Watch Update Adds Dog Workouts, Badges and Better Swim Tracking

      November 21, 2026

      Ashton Kutcher Turned $435 Million Into a $7 Billion Anthropic Stake. His Track Record Goes Back to Skype.

      November 21, 2026

      Subscribe to Updates

      Get the latest creative news from FooBar about art, design and business.

      HEICJPG.online - Convert HEIC to JPG online
      Facebook
      • About GeekBlog: Our Mission, Team and Editorial Standards
      • Contact us
      • Privacy Policy
      • Disclaimer
      • Terms and Conditions
      • Editorial Policy
      • Cookie Policy
      • Your Privacy Choices
      © 2026 GeekBlog

      Type above and press Enter to search. Press Esc to cancel.