如何在ArgoCD中添加新集群(使用Rancher的配置文件)?- 服务器已要求客户端提供凭据

quo*_*c9x 5 kubernetes devops rancher argocd

除了 ArgoCD 上的默认集群之外,我想添加一个新集群,但是当我添加它时,出现错误:
FATA[0001] rpc error: code = Unknown desc = REST config invalid: the server has requests for the client提供凭据
我使用命令argocd cluster add cluster-name
下载 Rancher 的 k8s 配置文件。
谢谢!

quo*_*c9x 7

我解决了我的问题,但欢迎大家提供其他解决方案:D
首先,使用以下内容创建一个秘密:

apiVersion: v1
kind: Secret
metadata:
  namespace: argocd # same namespace of argocd-app
  name: mycluster-secret
  labels:
    argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
  name: cluster-name # Get from clusters - name field in config k8s file.
  server: https://mycluster.com # Get from clusters - name - cluster - server field in config k8s file.
  config: |
    {
      "bearerToken": "<authentication token>",
      "tlsClientConfig": {
        "insecure": false,
        "caData": "<base64 encoded certificate>" 
      }
    }
Run Code Online (Sandbox Code Playgroud)

bearerToken- 从配置 k8s 文件中的用户 - 用户 - 令牌字段获取。
caData- 从配置 k8s 文件中的 cluster-name-cluster-certificate-authority-data 字段获取。
然后,应用此 yaml 文件,新集群将自动添加到 ArgoCD。
我在github上找到了解决方案:
https://gist.github.com/janeczku/b16154194f7f03f772645303af8e9f80