amazon-web-servicesamazon-eksargocdgitops

Issue in adding eks cluster as a remote in argocd


I am facing issue while add my eks cluster in argocd as remote cluster for application deployment.

I am using below YAML for adding cluster in argocd.

apiVersion: v1
kind: Secret
metadata:
  namespace: default
  name: remotecluster
  labels:
    argocd.argoproj.io/secret-type: cluster
    environment: "demo"
    provider: "AWS"
type: Opaque
stringData:
  name: remotetcluster
  server: https://ABC7503B6A7F01DA3D25354C99DBC06A.gr7.ap-south-1.eks.amazonaws.com
  config: |
    {
      "bearerToken": "",
      "tlsClientConfig": {
        "insecure": false,
        "caData": ""
      }
    }

Here have created token using below commands,

aws eks get-token --cluster-name myDemo --region ap-south-1

ERROR I face like below, error

Failed to load target state: failed to get cluster version for cluster "xxxx": failed to get cluster info for "xxxx": error synchronizing cache state : Get "xxx/version?timeout=32s": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

Anyone have idea please do let me know.

Thank You...


Solution

  • If you don't have a specific reason to use the declarative yaml, you can simply add the cluster on to your local context with:

    aws eks update-kubeconfig --region ap-south-1 --name remotecluster
    

    Then use the ArgoCD CLI:

    argocd cluster add remotecluster
    

    This is the simplest way to add a cluster on to ArgoCD. You will have to use argocd login to login to your ArgoCD instance before you run the above command.