一、安装 argocd-server

  1. 创建命名空间
1
kubectl create namespace argocd
  1. 下载资源清单文件

    非高可用安装(API server、controller、repo server、Redis 各 1)

1
wget https://raw.githubusercontent.com/argoproj/argo-cd/v3.4.3/manifests/install.yaml

​ 高可用安装(API server ×3、controller ×2(带选主)、repo server ×3、Redis 以 Sentinel 方式 ×3)

1
wget https://raw.githubusercontent.com/argoproj/argo-cd/v3.4.3/manifests/ha/install.yaml
  1. 创建资源
1
kubectl apply -n argocd --server-side --force-conflicts -f install.yaml
  1. 等待 Pod 都 Running
1
watch kubectl get pods -n argocd

二、配置证书

argocd-server 默认在 443 上用自己的自签证书做 HTTPS。你再让 Traefik 也终止 TLS,就成了”TLS 套 TLS”,会出问题。解法是让 argocd-server 跑在 insecure 模式(只提供普通 HTTP),把 TLS 完全交给 Traefiks

  1. 打开 insecure 模式,让 Traefik 接管 TLS
1
2
3
kubectl -n argocd patch configmap argocd-cmd-params-cm --type merge \
-p '{"data":{"server.insecure":"true"}}'
kubectl -n argocd rollout restart deployment argocd-server
  1. 创建 argocd-ingress 资源
1
vim argocd-ingress.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# argocd-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server
namespace: argocd
annotations:
cert-manager.io/cluster-issuer: qx-ca-issuer # ← 和 whoami 一模一样
spec:
ingressClassName: traefik
tls:
- hosts: [argocd.qx.lab]
secretName: argocd-server-tls # cert-manager 自动创建
rules:
- host: argocd.qx.lab
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
number: 80
  1. 创建资源
1
kubectl apply -f argocd-ingress.yaml
  1. 查看自动签发的证书
1
kubectl get certificate -n argocd
  1. 获取默认密码
1
2
kubectl -n argocd get secret argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d ; echo
  1. 浏览器访问

https://argocd.qx.lab

三、argocd-cli

3.1 下载安装

  1. 下载安装
1
2
3
4
5
VER=v3.4.3   # 跟服务端对齐,免得 CLI 报版本不匹配
curl -sSL -o /usr/local/bin/argocd \
https://github.com/argoproj/argo-cd/releases/download/$VER/argocd-linux-amd64
chmod +x /usr/local/bin/argocd
argocd version --client

​ 代理下载安装

1
2
3
4
5
VER=v3.4.3   # 跟服务端对齐,免得 CLI 报版本不匹配
curl -sSL -o /usr/local/bin/argocd \
https://g.bravexist.cn/https://github.com/argoproj/argo-cd/releases/download/$VER/argocd-linux-amd64
chmod +x /usr/local/bin/argocd
argocd version --client
  1. 登录
1
argocd login argocd.qx.lab
  1. 改用 gprc-web 方式。

argocd CLI 默认用”原生 gRPC”(走 HTTP/2)跟服务端通信。ArgoCD 现在是挂在 Traefik 后面、由 Traefik 终止 TLS 的——这种标准 ingress 路径不能干净地透传原生 gRPC。

1
argocd login argocd.qx.lab --grpc-web