Skip to main content

Cluster Deletion

This guide covers the safe deletion of Kubernetes clusters, including pre-deletion planning, the deletion process, and post-deletion cleanup.

Overview

Cluster deletion is a permanent, irreversible operation that completely removes the cluster and all its resources. The system includes multiple safety measures to prevent accidental deletions and ensure users understand the consequences.

What Gets Deleted

  • All Cluster Nodes: Worker and master nodes are terminated
  • Control Plane: Kubernetes control plane components removed
  • Workloads: All pods, services, and applications destroyed
  • Storage: System volumes and cluster-managed storage deleted
  • Network Resources: Load balancers and network configurations removed
  • Cluster Configuration: All cluster settings and metadata destroyed
Irreversible Operation

Cluster deletion cannot be undone. Once deleted, all data and configurations are permanently lost unless backed up externally.

Pre-deletion Planning

Impact Assessment

Workload Inventory

Before deleting a cluster, create a comprehensive inventory:

  1. Application Assessment

    • List all running applications and services
    • Identify critical vs. non-critical workloads
    • Document application dependencies
    • Note any external integrations
  2. Data Evaluation

    • Identify persistent data that needs preservation
    • List databases and stateful applications
    • Document data backup requirements
    • Note any shared storage dependencies
  3. User Impact Analysis

    • Identify who uses the cluster
    • Assess impact on development/production workflows
    • Plan user notification timeline
    • Coordinate with affected teams

Dependency Checking

External Dependencies

# Check for external services pointing to cluster
kubectl get services --all-namespaces -o wide

# List ingress resources with external access
kubectl get ingress --all-namespaces

# Check for persistent volumes
kubectl get pv

Integration Points

  • DNS Records: External DNS pointing to cluster services
  • Load Balancers: External load balancers routing to cluster
  • Monitoring: External monitoring systems collecting cluster metrics
  • CI/CD Pipelines: Deployment pipelines targeting the cluster

Data Backup

Application Data Backup

# Backup persistent volume data
kubectl get pvc --all-namespaces

# Export application configurations
kubectl get deployments,services,configmaps,secrets --all-namespaces -o yaml > cluster-backup.yaml

# Database backups (example for PostgreSQL)
kubectl exec postgres-pod -- pg_dump database_name > database_backup.sql

Configuration Export

# Export cluster configurations
kubectl get nodes -o yaml > nodes-config.yaml
kubectl get namespaces -o yaml > namespaces-config.yaml

# Export custom resources
kubectl get crd -o yaml > custom-resources.yaml

# Export RBAC configurations
kubectl get roles,rolebindings,clusterroles,clusterrolebindings --all-namespaces -o yaml > rbac-config.yaml

Documentation Backup

  • Cluster Architecture: Document cluster setup and configuration
  • Application Manifests: Save all Kubernetes manifests
  • Custom Scripts: Backup any custom deployment or management scripts
  • Network Configuration: Document network setup and integrations

Deletion Process

Safety Requirements

Before deletion can proceed, the cluster must meet safety requirements:

Cluster State Requirements

  • Accessibility: Cluster must be accessible through the dashboard
  • Permissions: Users must have cluster deletion permissions
  • Confirmation: User must complete all confirmation steps

Verify Cluster Information

  1. Double-check Cluster Name: Ensure the correct cluster is being deleted
  2. Review Cluster Details: Check cluster ID, creation date, and configuration
  3. Confirm Intent: Ensure this is the cluster intended for deletion
  4. Final Verification: Verify with team members if this is a shared cluster

Final Confirmation

  1. Verify Input: Ensure the typed name matches exactly
  2. Review Warnings: Read final warning messages
  3. Confirm Deletion: Click the final "Delete" or "Confirm" button
  4. Process Begins: Deletion process starts immediately

![Figure Needed] Final confirmation dialog showing "Terminate Cluster" with warning message about deleting 'k8s-c-berniepro', name verification input field with placeholder text, and Cancel/Accept buttons

Deletion Timeline

Phase 1: Initiation (0-30 seconds)

  • Process Start: Deletion process begins
  • Status Change: Cluster status changes to "Terminating"
  • API Lockdown: Cluster API becomes read-only
  • User Notification: Confirmation that deletion has started

Phase 2: Workload Termination (30 seconds - 5 minutes)

  • Graceful Shutdown: Pods receive termination signals
  • Drain Process: Nodes are drained of workloads
  • Service Cleanup: Services and endpoints are removed
  • Pod Eviction: All pods are gracefully terminated

Status Indicators

  • Cluster List: Cluster status shows "Terminating" with red spinner
  • Progress Tracking: Monitor deletion progress through cluster list
  • Status Updates: Status updates automatically every 30 seconds
  • Completion: Cluster disappears from list when deletion is complete

Deletion Stuck in "Terminating"

Symptoms:

  • Cluster remains in "Terminating" state for extended period (over 20 minutes)
  • No progress in deletion process
  • Cluster still appears in list after expected completion time

Possible Causes:

  • Resource Dependencies: External resources preventing cleanup
  • Storage Issues: Persistent volumes with protection policies
  • Network Dependencies: Load balancers or network resources stuck

Solutions:

  1. Wait Longer: Allow up to 30 minutes for complex clusters
  2. Check Dependencies: Verify no external systems are holding references
  3. Contact Support: Escalate if stuck for over 30 minutes
  4. Manual Intervention: Support may need to manually clean up resources