Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action does not support EKS pod identities #624

Open
casey-robertson-paypal opened this issue May 7, 2024 · 2 comments
Open

Action does not support EKS pod identities #624

casey-robertson-paypal opened this issue May 7, 2024 · 2 comments

Comments

@casey-robertson-paypal
Copy link

casey-robertson-paypal commented May 7, 2024

Describe the bug
We are migrating workloads to EKS - in particular Github Actions runners. The runner scalesets run as service accounts wired up to AWS EKS Pod Identities. We run v2 of the action and receive the following error:

Run aws-actions/amazon-ecr-login@v2
  with:
    mask-password: true
    registry-type: private
    skip-logout: false
Error: 169.254.170.23 is not a valid container metadata service hostname

To Reproduce

Create a test action that uses amazon-ecr-login in a pod/runner running in EKS and a service account identity.

Expected behavior
The action discovers the creds mounted in the metadata path and uses them to authenticate with ECR.

Screenshots
No screenshots but we confirmed that raw aws sts commands are returning the correct assumed role that we'd expect.

Desktop (please complete the following information):
EKS 1.29
Running 0.9.0 version of github action runner container and helm chart.

@meithon
Copy link

meithon commented Oct 3, 2024

Current Workaround
At present, one of the most effective solutions appears to be using the following action instead:

- name: Login to Amazon ECR
  id: login-ecr
  run: |
    aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin xxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com

@zarko-a
Copy link

zarko-a commented Jan 6, 2025

Another workaround that might be better if you are using kubernetes driver for buildx is to not use aws-actions/amazon-ecr-login and use https://github.com/docker/login-action instead. It supports Pod Identity out-of-the box and no extra steps are needed. Kinda disappointing that official AWS Actions are outdated compared to Docker.

If you are using Pod Identity with EKS this is needed to get buildx with k8s pushing to private ECR. Maybe this saves someone time.

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@97834a484a5ab3c40fa9e2eb40fcf8041105a573 # pinned to a specific commit to enable pod identity support. None of the existing v4 tags support it yet.  See here for details https://github.com/aws-actions/configure-aws-credentials/issues/942
        with:
          aws-region: < region >
          
      - name: Login to ECR
        uses: docker/login-action@v3
        with:
          registry:  <aws account id>.dkr.ecr.< region >.amazonaws.com

      - name: Generate Dynamic Tag
        id: tag
        run: echo "image-tag=$(date +'%Y-%m-%d-%H-%M')" >> "$GITHUB_OUTPUT"

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with:
          driver: kubernetes
          driver-opts: |
            namespace=docker-buildx
            "nodeselector=kubernetes.io/arch=amd64"
            "annotations=karpenter.sh/do-not-disrupt=true"
            "tolerations=key=node-role,value=static,effect=NoSchedule"

      - name: Build and push
        uses: docker/build-push-action@v6
        env:
          DOCKER_BUILD_SUMMARY: false
        with:
          context: ./scripts/test_image
          push: true
          provenance: false
          tags: <aws account id>.dkr.ecr.< region >.amazonaws.com/<repo name>:${{ steps.tag.outputs.image-tag }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants