版本ArgoCD v3.2.1

方案 1:用 Kind 快速搭建轻量 K8s 集群(推荐,最贴近真实场景)

Kind(Kubernetes IN Docker)可在单机快速创建轻量 K8s 集群,完美适配 ArgoCD 运行,且步骤简单:
步骤 1:安装 Kind
# Linux/macOS 安装 Kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/
步骤 2:创建单节点 K8s 集群
# 创建集群配置文件
cat > kind-config.yaml << EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30080  # 映射 ArgoCD 的 NodePort 端口
    hostPort: 8080
    listenAddress: "0.0.0.0"
EOF

# 启动集群(约1分钟)
kind create cluster --config kind-config.yaml --name argocd-test
步骤 3:在 Kind 集群部署 ArgoCD v3.2.1
# 下载 ArgoCD v3.2.1 官方部署清单
curl -Lo argocd-install.yaml https://raw.githubusercontent.com/argoproj/argo-cd/v3.2.1/manifests/install.yaml

# 部署 ArgoCD 到集群
kubectl apply -f argocd-install.yaml -n argocd --create-namespace

# 等待 Pod 启动(约2分钟)
kubectl wait --for=condition=Ready pods -n argocd --all --timeout=300s

# 暴露 ArgoCD 端口(映射到主机 8080)
kubectl patch svc argocd-server -n argocd -p '{"spec":{"type":"NodePort","ports":[{"port":8080,"nodePort":30080,"name":"http"}]}}'
步骤 4:配置 OIDC 第三方登录(正常 K8s 方式)
# 编辑 argocd-cm ConfigMap 配置 OIDC
kubectl edit configmap argocd-cm -n argocd

 添加 OIDC 配置(与之前的 oidc.config 内容一致):

data:
  oidc.config: |
    name: Keycloak
    issuer: https://你的Keycloak地址:8080/realms/你的Realm
    clientID: argocd-client
    clientSecret: 你的客户端密钥
    redirectURI: https://localhost:8080/api/dex/callback
    requestedScopes: ["openid", "email", "profile"]
步骤 5:测试登录
  • 访问 https://localhost:8080(Kind 已映射端口);
  • 初始密码:kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

 

 

 

 posted on 2025-12-18 18:20  boye169  阅读(3)  评论(0)    收藏  举报