From cc636da9cfd37d201c56cf4a7440dbf507166640 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Wed, 6 Mar 2024 22:32:02 +0800 Subject: [PATCH] add scripts/argocd_all_in_one.sh --- scripts/argocd_all_in_one.sh | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripts/argocd_all_in_one.sh diff --git a/scripts/argocd_all_in_one.sh b/scripts/argocd_all_in_one.sh new file mode 100644 index 0000000..f9f5fc2 --- /dev/null +++ b/scripts/argocd_all_in_one.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# 添加 Argo CD 的 Helm 仓库 +helm repo add argo https://argoproj.github.io/argo-helm +helm repo update + +# 使用 Helm 部署 Argo CD +helm install argocd argo/argo-cd -n argocd --create-namespace + +# 等待 Argo CD 完全启动 +echo "Waiting for Argo CD to be ready..." +kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=argocd-server -n argocd --timeout=180s + +# 创建 Argo CD Application 配置文件 +cat < argocd-application.yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: helmfile-application + namespace: argocd +spec: + project: default + source: + repoURL: <你的 Git 仓库 URL> + path: <存放 Helmfile 的路径> + targetRevision: HEAD + helm: + releaseName: helmfile-application + destination: + server: https://kubernetes.default.svc + namespace: default + syncPolicy: + automated: + prune: true + selfHeal: true +EOF + +# 替换占位符为实际值 +sed -i 's|<你的 Git 仓库 URL>|你的实际 Git 仓库 URL|g' argocd-application.yaml +sed -i 's|<存放 Helmfile 的路径>|你的实际 Helmfile 路径|g' argocd-application.yaml + +# 应用 Argo CD Application 配置 +kubectl apply -f argocd-application.yaml + +echo "Argo CD deployment and configuration complete."