fix: 将 k3s-ansible 作为普通目录添加

This commit is contained in:
fei
2026-02-04 23:43:40 +08:00
commit 7f6c8b9b92
40 changed files with 10909 additions and 0 deletions

52
scripts/create-argocd-app.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/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 "=== 创建ArgoCD Application ==="
# 读取配置
GIT_REPO=$(yq eval '.git_repo_url' "$CONFIG_FILE")
GIT_USERNAME=$(yq eval '.gitea_user_name' "$CONFIG_FILE")
GIT_PASSWORD=$(yq eval '.gitea_user_password' "$CONFIG_FILE")
# 配置Gitea仓库凭证
echo "🔐 配置Gitea仓库凭证..."
kubectl create secret generic gitea-creds \
-n argocd \
--from-literal=username="$GIT_USERNAME" \
--from-literal=password="$GIT_PASSWORD" \
--dry-run=client -o yaml | kubectl apply -f -
# 生成Application配置
cat > /tmp/argocd-app.yaml <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: demo-app
namespace: argocd
spec:
project: default
source:
repoURL: $GIT_REPO
targetRevision: main
path: manifests
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
EOF
# 应用配置
kubectl apply -f /tmp/argocd-app.yaml
echo "✅ ArgoCD Application创建成功"
echo "📊 查看状态: kubectl get application -n argocd"
echo "🌐 访问ArgoCD查看同步状态"