Add base kubernetes support final
This commit is contained in:
202
CLEANUP-GUIDE.md
Normal file
202
CLEANUP-GUIDE.md
Normal file
@@ -0,0 +1,202 @@
|
||||
# 🧹 Cleanup Guide for Kind + Colima + Skaffold Environment
|
||||
|
||||
This guide provides different cleanup options depending on what you want to clean up.
|
||||
|
||||
## 📋 Quick Reference
|
||||
|
||||
| Scenario | Command | What it cleans |
|
||||
|----------|---------|----------------|
|
||||
| **Stop development** | `Ctrl+C` (in skaffold dev) | Stops Skaffold, keeps everything |
|
||||
| **Clean deployment only** | `skaffold delete` | Removes K8s resources, keeps images |
|
||||
| **Clean HTTPS setup** | `./cleanup-https.sh` | Removes HTTPS + cert-manager |
|
||||
| **Complete cleanup** | `./complete-cleanup.sh` | **Everything** (interactive) |
|
||||
| **Nuclear option** | See manual commands below | Complete manual cleanup |
|
||||
|
||||
## 🚀 Quick Cleanup Commands
|
||||
|
||||
### 1. Stop Skaffold Development Mode
|
||||
```bash
|
||||
# If running skaffold dev, just press:
|
||||
Ctrl+C
|
||||
|
||||
# Or from another terminal:
|
||||
skaffold delete --profile=dev
|
||||
```
|
||||
|
||||
### 2. Clean Only Kubernetes Resources
|
||||
```bash
|
||||
# Remove all bakery-ia resources
|
||||
kubectl delete namespace bakery-ia
|
||||
|
||||
# Remove cert-manager (if installed)
|
||||
kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.yaml
|
||||
|
||||
# Remove NGINX Ingress
|
||||
kubectl delete -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
|
||||
```
|
||||
|
||||
### 3. Clean Docker Images
|
||||
```bash
|
||||
# Remove bakery images
|
||||
docker images | grep "bakery/" | awk '{print $1":"$2}' | xargs docker rmi -f
|
||||
|
||||
# Remove dangling images
|
||||
docker image prune -f
|
||||
|
||||
# Remove build cache
|
||||
docker builder prune -f
|
||||
```
|
||||
|
||||
### 4. Clean Kind Cluster
|
||||
```bash
|
||||
# Delete specific cluster
|
||||
kind delete cluster --name bakery-ia-local
|
||||
|
||||
# Delete all clusters
|
||||
kind get clusters | xargs -r -I {} kind delete cluster --name {}
|
||||
```
|
||||
|
||||
### 5. Clean Colima
|
||||
```bash
|
||||
# Stop Colima
|
||||
colima stop --profile k8s-local
|
||||
|
||||
# Delete Colima profile (removes all Docker data)
|
||||
colima delete --profile k8s-local --force
|
||||
```
|
||||
|
||||
## 🔄 Automated Cleanup Scripts
|
||||
|
||||
### Option 1: Complete Cleanup (Recommended)
|
||||
```bash
|
||||
# Interactive cleanup of everything
|
||||
./complete-cleanup.sh
|
||||
```
|
||||
|
||||
### Option 2: HTTPS-Only Cleanup
|
||||
```bash
|
||||
# Removes HTTPS setup but keeps basic environment
|
||||
./cleanup-https.sh
|
||||
```
|
||||
|
||||
### Option 3: Skaffold-Only Cleanup
|
||||
```bash
|
||||
# Quick cleanup of just the deployment
|
||||
skaffold delete --profile=dev
|
||||
```
|
||||
|
||||
## 🛠️ Manual Nuclear Cleanup
|
||||
|
||||
If scripts fail, use these manual commands:
|
||||
|
||||
```bash
|
||||
# 1. Stop all processes
|
||||
pkill -f skaffold
|
||||
pkill -f kubectl
|
||||
|
||||
# 2. Clean Kubernetes
|
||||
kubectl delete namespace bakery-ia --force --grace-period=0 2>/dev/null || true
|
||||
kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.yaml --ignore-not-found=true
|
||||
kubectl delete -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml --ignore-not-found=true
|
||||
|
||||
# 3. Clean Docker aggressively
|
||||
docker stop $(docker ps -aq) 2>/dev/null || true
|
||||
docker rm $(docker ps -aq) 2>/dev/null || true
|
||||
docker rmi $(docker images -q) -f 2>/dev/null || true
|
||||
docker system prune -a -f --volumes
|
||||
|
||||
# 4. Clean Kind completely
|
||||
kind get clusters | xargs -r -I {} kind delete cluster --name {}
|
||||
|
||||
# 5. Reset Colima completely
|
||||
colima stop --profile k8s-local 2>/dev/null || true
|
||||
colima delete --profile k8s-local --force 2>/dev/null || true
|
||||
rm -rf ~/.colima/k8s-local
|
||||
|
||||
# 6. Clean local files
|
||||
rm -f *.crt *.key bakery-ia-ca.crt
|
||||
rm -rf ~/.skaffold/cache
|
||||
|
||||
# 7. Clean hosts file (careful!)
|
||||
sudo cp /etc/hosts /etc/hosts.backup
|
||||
sudo sed -i '' '/bakery-ia.local/d' /etc/hosts
|
||||
sudo sed -i '' '/api.bakery-ia.local/d' /etc/hosts
|
||||
sudo sed -i '' '/monitoring.bakery-ia.local/d' /etc/hosts
|
||||
```
|
||||
|
||||
## 🎯 Cleanup by Use Case
|
||||
|
||||
### Daily Development
|
||||
```bash
|
||||
# Quick reset between sessions
|
||||
skaffold delete --profile=dev
|
||||
```
|
||||
|
||||
### Weekly Cleanup
|
||||
```bash
|
||||
# Clean up accumulated images and cache
|
||||
docker image prune -f
|
||||
docker builder prune -f
|
||||
```
|
||||
|
||||
### Project Finished
|
||||
```bash
|
||||
# Complete cleanup
|
||||
./complete-cleanup.sh
|
||||
```
|
||||
|
||||
### Something's Broken
|
||||
```bash
|
||||
# Nuclear reset
|
||||
kind delete cluster --name bakery-ia-local
|
||||
colima delete --profile k8s-local --force
|
||||
# Then restart with ./skaffold-dev.sh
|
||||
```
|
||||
|
||||
## 🔍 Verify Cleanup
|
||||
|
||||
After cleanup, verify with these commands:
|
||||
|
||||
```bash
|
||||
# Check Docker images
|
||||
docker images | grep bakery
|
||||
|
||||
# Check Kind clusters
|
||||
kind get clusters
|
||||
|
||||
# Check Colima status
|
||||
colima status --profile k8s-local
|
||||
|
||||
# Check Kubernetes (should fail if cluster deleted)
|
||||
kubectl get pods -n bakery-ia
|
||||
|
||||
# Check hosts file
|
||||
grep bakery /etc/hosts
|
||||
```
|
||||
|
||||
## 🚀 Restart After Cleanup
|
||||
|
||||
To restart development after cleanup:
|
||||
|
||||
```bash
|
||||
# Quick start
|
||||
./skaffold-dev.sh
|
||||
|
||||
# Or with HTTPS
|
||||
./setup-https.sh
|
||||
|
||||
# Or manual
|
||||
colima start --cpu 4 --memory 8 --disk 50 --runtime docker --profile k8s-local
|
||||
kind create cluster --name bakery-ia-local
|
||||
skaffold dev --profile=dev
|
||||
```
|
||||
|
||||
## ⚠️ Important Notes
|
||||
|
||||
1. **Always backup** important data before cleanup
|
||||
2. **The complete cleanup script is interactive** - it will ask before destructive operations
|
||||
3. **Colima profile deletion** removes ALL Docker data in that profile
|
||||
4. **Kind cluster deletion** is permanent - you'll lose all Kubernetes data
|
||||
5. **Hosts file changes** require sudo permissions
|
||||
|
||||
Choose the cleanup level that matches your needs! 🎯
|
||||
Reference in New Issue
Block a user