Search code examples
kubernetesdevopsrancherargocd

How to add new cluster in ArgoCD (use config file of Rancher)? - the server has asked for the client to provide credentials


I want to add a new cluster in addition to the default cluster on ArgoCD but when I add it, I get an error:
FATA[0001] rpc error: code = Unknown desc = REST config invalid: the server has asked for the client to provide credentials
I use the command argocd cluster add cluster-name
I download config file k8s of Rancher.
Thanks!


Solution

  • I solved my problem but welcome other solutions from everyone :D
    First, create a secret with the following content:

    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>" 
          }
        }
    

    bearerToken - Get from users - user - token field in config k8s file.
    caData - Get from clusters - name - cluster - certificate-authority-data field in config k8s file.
    Then, apply this yaml file and the new cluster will be automatically added to ArgoCD.
    I found the solution on github:
    https://gist.github.com/janeczku/b16154194f7f03f772645303af8e9f80