Add base kubernetes support final
This commit is contained in:
103
cleanup-https.sh
Executable file
103
cleanup-https.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Bakery IA HTTPS Cleanup Script
|
||||
# This script removes HTTPS configuration and cert-manager
|
||||
|
||||
set -e
|
||||
|
||||
echo "🧹 Cleaning up HTTPS setup for Bakery IA"
|
||||
echo "========================================"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
# Remove application
|
||||
cleanup_application() {
|
||||
print_status "Removing Bakery IA application..."
|
||||
|
||||
# Try Skaffold cleanup first (if available and was used)
|
||||
if command -v skaffold &> /dev/null; then
|
||||
print_status "Cleaning up Skaffold deployment..."
|
||||
skaffold delete --profile=dev --ignore-not-found=true 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Fallback to manual cleanup
|
||||
print_status "Cleaning up remaining resources..."
|
||||
kubectl delete -k infrastructure/kubernetes/overlays/dev/ --ignore-not-found=true
|
||||
|
||||
print_success "Application removed"
|
||||
}
|
||||
|
||||
# Remove certificates and issuers
|
||||
cleanup_certificates() {
|
||||
print_status "Removing certificates and issuers..."
|
||||
kubectl delete clusterissuers --all --ignore-not-found=true
|
||||
kubectl delete certificates --all -n cert-manager --ignore-not-found=true
|
||||
kubectl delete secrets local-ca-key-pair -n cert-manager --ignore-not-found=true
|
||||
print_success "Certificates and issuers removed"
|
||||
}
|
||||
|
||||
# Remove cert-manager
|
||||
cleanup_cert_manager() {
|
||||
print_status "Removing cert-manager..."
|
||||
kubectl delete -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.yaml --ignore-not-found=true
|
||||
print_success "cert-manager removed"
|
||||
}
|
||||
|
||||
# Remove ingress controller
|
||||
cleanup_ingress() {
|
||||
print_status "Removing NGINX Ingress Controller..."
|
||||
kubectl delete -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml --ignore-not-found=true
|
||||
print_success "NGINX Ingress Controller removed"
|
||||
}
|
||||
|
||||
# Remove local files
|
||||
cleanup_local_files() {
|
||||
print_status "Removing local certificate files..."
|
||||
rm -f bakery-ia-ca.crt
|
||||
print_success "Local files cleaned up"
|
||||
}
|
||||
|
||||
# Main cleanup
|
||||
main() {
|
||||
print_warning "This will remove all HTTPS configuration and cert-manager from your cluster."
|
||||
read -p "Are you sure you want to continue? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
print_status "Cleanup cancelled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cleanup_application
|
||||
cleanup_certificates
|
||||
cleanup_cert_manager
|
||||
cleanup_ingress
|
||||
cleanup_local_files
|
||||
|
||||
print_success "🎉 Cleanup completed!"
|
||||
echo ""
|
||||
echo "Additional cleanup commands (if needed):"
|
||||
echo " 🗂️ Remove hosts entries: sudo sed -i '' '/bakery-ia.local/d' /etc/hosts"
|
||||
echo " 🐳 Stop Colima: colima stop --profile k8s-local"
|
||||
echo " 🗑️ Delete Kind cluster: kind delete cluster --name bakery-ia-local"
|
||||
echo ""
|
||||
print_warning "Note: Hosts file entries and CA certificate may need manual cleanup"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user