remote-task-excutor-cli/scripts/undeploy-server.sh

50 lines
1.3 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 卸载 server 从 Kubernetes 的脚本
set -e
# 配置变量
NAMESPACE="${1:-default}"
DEPLOYMENT_NAME="remote-task-executor-server"
# 颜色输出
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}========================================${NC}"
echo -e "${YELLOW}卸载 Server 从 Kubernetes${NC}"
echo -e "${YELLOW}========================================${NC}"
echo -e "命名空间: ${YELLOW}${NAMESPACE}${NC}"
echo -e "部署名称: ${YELLOW}${DEPLOYMENT_NAME}${NC}"
echo ""
# 确认
read -p "确定要删除部署吗?(y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${GREEN}已取消${NC}"
exit 0
fi
# 删除 Deployment 和 Service
echo -e "${YELLOW}删除 Deployment 和 Service...${NC}"
kubectl delete -f k8s/deployment.yaml -n ${NAMESPACE} || true
# 删除 Secret可选通常不建议删除
if [ -f "k8s/secret.yaml" ]; then
read -p "是否删除 Secret(y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
kubectl delete -f k8s/secret.yaml -n ${NAMESPACE} || true
fi
fi
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}卸载完成!${NC}"
echo -e "${GREEN}========================================${NC}"