fix: 将 k3s-ansible 作为普通目录添加
This commit is contained in:
70
scripts/deploy-gitea.sh
Executable file
70
scripts/deploy-gitea.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
CONFIG_FILE="$PROJECT_DIR/config/cluster-vars.yml"
|
||||
|
||||
echo "=== 部署Gitea私有Git服务器 ==="
|
||||
|
||||
# 安装yq(如果未安装)
|
||||
if ! command -v yq &> /dev/null; then
|
||||
echo "📦 安装yq..."
|
||||
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
|
||||
sudo chmod +x /usr/local/bin/yq
|
||||
fi
|
||||
|
||||
# 安装Helm(如果未安装)
|
||||
if ! command -v helm &> /dev/null; then
|
||||
echo "📦 安装Helm..."
|
||||
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
|
||||
fi
|
||||
|
||||
# 读取配置
|
||||
GITEA_DOMAIN=$(yq eval '.gitea_domain' "$CONFIG_FILE")
|
||||
GITEA_ADMIN_USER=$(yq eval '.gitea_admin_user' "$CONFIG_FILE")
|
||||
GITEA_ADMIN_PASSWORD=$(yq eval '.gitea_admin_password' "$CONFIG_FILE")
|
||||
GITEA_ADMIN_EMAIL=$(yq eval '.gitea_admin_email' "$CONFIG_FILE")
|
||||
|
||||
# 创建命名空间
|
||||
kubectl create namespace gitea --dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
# 添加Gitea Helm仓库
|
||||
helm repo add gitea-charts https://dl.gitea.com/charts/
|
||||
helm repo update
|
||||
|
||||
# 部署Gitea
|
||||
echo "📦 部署Gitea..."
|
||||
helm upgrade --install gitea gitea-charts/gitea \
|
||||
--namespace gitea \
|
||||
--set gitea.admin.username="$GITEA_ADMIN_USER" \
|
||||
--set gitea.admin.password="$GITEA_ADMIN_PASSWORD" \
|
||||
--set gitea.admin.email="$GITEA_ADMIN_EMAIL" \
|
||||
--set service.http.type=NodePort \
|
||||
--set service.ssh.type=NodePort \
|
||||
--set gitea.config.server.DOMAIN="$GITEA_DOMAIN" \
|
||||
--set gitea.config.server.ROOT_URL="http://$GITEA_DOMAIN" \
|
||||
--set persistence.enabled=true \
|
||||
--set persistence.size=10Gi \
|
||||
--wait --timeout=10m
|
||||
|
||||
# 等待Gitea就绪
|
||||
echo "⏳ 等待Gitea就绪..."
|
||||
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=gitea -n gitea --timeout=600s
|
||||
|
||||
# 获取访问信息
|
||||
HTTP_NODEPORT=$(kubectl get svc gitea-http -n gitea -o jsonpath='{.spec.ports[0].nodePort}')
|
||||
SSH_NODEPORT=$(kubectl get svc gitea-ssh -n gitea -o jsonpath='{.spec.ports[0].nodePort}')
|
||||
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="ExternalIP")].address}')
|
||||
if [ -z "$NODE_IP" ]; then
|
||||
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
|
||||
fi
|
||||
|
||||
echo "=== Gitea部署完成 ==="
|
||||
echo "🌐 HTTP访问: http://$NODE_IP:$HTTP_NODEPORT"
|
||||
echo "🌐 域名访问: http://$GITEA_DOMAIN (需配置Ingress)"
|
||||
echo "🔐 SSH端口: $SSH_NODEPORT"
|
||||
echo "👤 管理员用户: $GITEA_ADMIN_USER"
|
||||
echo "🔑 管理员密码: $GITEA_ADMIN_PASSWORD"
|
||||
echo ""
|
||||
echo "⚠️ 请运行 ./scripts/setup-gitea.sh 完成初始化配置"
|
||||
Reference in New Issue
Block a user