argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.58k stars 5.35k forks source link

Support EKS Pod Identity #17064

Open csantanapr opened 8 months ago

csantanapr commented 8 months ago

Summary

EKS released in Nov/2023 EKS Pod Identity, this is an alternative to IAM roles for service accounts (IRSA)

Motivation

Have additional options on how ArgoCD authenticates with AWS other than using IRSA.

Proposal

To support EKS Pod Identity the change is transparent if your using the aws-sdk, the version of the sdk needs to be updated to a recent version that supports EKS Pod Identity.

csantanapr commented 8 months ago

The PR that bumps the aws-sdk version is https://github.com/argoproj/argo-cd/pull/17063

A follow up PR will have the docs on how to configure ArgoCD to leverage the EKS Pod Identity

todaywasawesome commented 8 months ago

@csantanapr leaving this open until the docs are done

csantanapr commented 7 months ago

Sounds good @csantanapr I will be working on docs

csantanapr commented 7 months ago

@daniel-codefresh I was trying to work on docs but they were broken to build and preview, here is a fix https://github.com/argoproj/argo-cd/pull/17313

tybook commented 5 months ago

Hey @csantanapr do you have a branch with your in-progress docs? Or generally any rough guidance on how to configure ArgoCD to use EKS Pod Identity?

isikdos commented 5 months ago

Hey @csantanapr do you have a branch with your in-progress docs? Or generally any rough guidance on how to configure ArgoCD to use EKS Pod Identity?

I'm not him obvi, but the solution is to just use a more recent release of argo-cd. The only necessary changes to support EKS Pod Identity are to have a more recent version of the AWS SDK running. If you are asking how to configure EKS Pod Identity in general, this guide has a bunch of information: https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html

tybook commented 5 months ago

Hey @csantanapr do you have a branch with your in-progress docs? Or generally any rough guidance on how to configure ArgoCD to use EKS Pod Identity?

I'm not him obvi, but the solution is to just use a more recent release of argo-cd. The only necessary changes to support EKS Pod Identity are to have a more recent version of the AWS SDK running. If you are asking how to configure EKS Pod Identity in general, this guide has a bunch of information: https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html

I'm wondering specifically about how to configure an EKS cluster secret such that ArgoCD can authenticate with it via EKS Pod Identity instead of IRSA. The existing instructions at https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#eks assume the use of IRSA.

AnubhavSabharwa commented 2 months ago

Does argocd cluster secret support EKS Pod Identity

magic-madrigal commented 2 months ago

I've been trying to find a way to get it work for the past day and a half and haven't been successful.

I feel I'm going to revert to IRSA, and then perhaps try using eksctl's migration command to see what it suggests.

AnubhavSabharwa commented 2 months ago

@magic-madrigal We install argocd via another argocd as helm based application. We are not allowed to save any token on the repository. I have been trying this setup but at the end getting below error

getting credentials: exec: executable argocd-k8s-auth failed with exit code 20

Would you mind suggesting something here? IRSA

isikdos commented 2 months ago

If you do all of that, it should work happily, I don't think I've forgotten any steps. You can always make sure of different components by looking at the pod running in EKS and seeing if it has the hallmark signs of using EKS pod identity, and also you can check the logs on the pod identity daemon to see what's going on

Remember to kick pods after updating their configuration for EKS pod identity, as this whole process works when the pod is coming up, not when the pod is already up

magic-madrigal commented 2 months ago

I appreciate the information @isikdos, but the application controller is still requesting additional credentials after going thought your write up.

I'm quite certain that the roles are assuming each other, but they don't seem to be able to get the creds they need to deploy to the cluster.

I've tried going the IRSA route, but yielded similar results.

I just rebuilt my test clusters and I'm going to attempt a slightly different approach.

AnubhavSabharwa commented 1 month ago

@magic-madrigal I tried the IRSA thing, it is looking for additional credentials

magic-madrigal commented 1 month ago

@abhishekjiitr same here. All of the roles are assuming each other; I continue to get an error stating that the cluster is looking for credentials. What Version are you running? I'm on v2.11.7 I'm going to try the newly released v2.12 today.

magic-madrigal commented 1 month ago

@abhishekjiitr - Progress!!!

I updated to 2.12.0, but I don't think this was important to my success.

I followed the IRSA instructions and was still having several issues with my implementation until I discovered an issue with my Cluster Secret. I had mistyped my clusterName in my secret, and once that was correct, it's now connecting correctly.

metadata:
  name: prod-1
  labels:
    argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
  name: prod-1
  server: <SERVER_URL_REDACTED>
  config: |
    {
      "awsAuthConfig": {
          "clusterName": "prod-1",
          "roleARN": "arn:aws:iam::<AWS_ACCT_REDATED>:role/Deployer"
      },
      "tlsClientConfig": {
        "caData": "<REDACTED>"
      }
    }

I'm now going to attempt to get this working with Pod Identities, now that I have a working solution

AnubhavSabharwa commented 1 month ago

@magic-madrigal Can you pleae help me out, I tried every way possible but at the end I am getting error

the server has asked for the client to provide credentials OR getting credentials: exec: executable argocd-k8s-auth failed with exit code 20 (Client.Timeout exceeded while awaiting headers)

"tlsClientConfig": { "insecure": "true" }

ARGOCD VERSION: 2.10.10 Please suggest.

When running the command directly on argocd-server pod to add the cluster

argocd-k8s-auth aws --cluster-name test-didev --role-arn arn:aws:iam::123456789:role/argocd-pod-identity-west-2 FATA[0120] timeout while trying to get signed aws request: last error: error presigning AWS request: RequestError: send request failed caused by: Post "https://sts.amazonaws.com/": dial tcp 12.17.16:443: i/o timeout

mikestef9 commented 1 month ago

I have Pod Identity working with Argo CD, need to be using at least v2.10

  ArgoCDDeployerRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: "ArgoCDDeployerRole"
      Description: "Role for Argo CD deployment"
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              AWS: "arn:aws:iam::123456789012:role/ArgoCDPodIdentityRole"
            Action:
              - "sts:AssumeRole"
              - "sts:TagSession"

  ArgoCDPodIdentityRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: "ArgoCDPodIdentityRole"
      Description: "Role to give Argo CD Access"
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: "AllowEksAuthToAssumeRoleForPodIdentity"
            Effect: "Allow"
            Principal:
              Service: "pods.eks.amazonaws.com"
            Action:
              - "sts:AssumeRole"
              - "sts:TagSession"
      Policies:
        - PolicyName: AssumeRole
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Sid: "AssumeRole"
                Effect: "Allow"
                Action: "sts:AssumeRole"
                Resource: "arn:aws:iam::123456789012:role/ArgoCDDeployerRole"

Then in Helm chart config

configs:
  clusterCredentials:
    ipv4:
      server: "https://redacted.sk1.us-west-2.eks.amazonaws.com"
      labels:
        cluster-name: "ipv4"
      config:
        awsAuthConfig:
          clusterName: "ipv4"
          roleARN: "arn:aws:iam::123456789012:role/ArgoCDDeployerRole"
        tlsClientConfig:
          insecure: false
          caData: "redacted"
AnubhavSabharwa commented 1 month ago

@mikestef9 Thank you for sharing the things, I have same config now but argocd is not able to add the cluster

exec: executable argocd-k8s-auth failed with exit code 20

argocd-k8s-auth aws --cluster-name test-didev --role-arn arn:aws:iam::123456789:role/argocd-pod-identity-west-2 Able to resolve this error by adding region AWS_REGION=us-west-2

Now argocd-k8s-auth aws --cluster-name test-didev --role-arn arn:aws:iam::123456789:role/argocd-pod-identity-west-2 gives me the token however, if i only run argocd-k8s-auth aws --cluster-name test-didev also returns the same thing. Running in argocd-server pod Not sure whether the arn is required or not. However, when deploying the secret it is giving timeout while getting the credentials which is totally not understandable.

the server has asked for the client to provide credentials

This is the error.

aws-auth for target cluster has been updated. Can someone please help me what am I missing?