EKS pod not accessing Kubernetes Service account for role

0

I have a issue where EKS POD is not able to access DynamoDB resource and on further analysis I found that EKS is not using the configured Kubernetes service account and instead it is trying to use the EC2 default profile to get the credentials in which it is deployed ?

I am using AWS SDK software.amazon.awssdk:: dynamodb-enhanced :: 2.20.94 in my java application.

Below error is shown when trying to access dynamoDB from POD :

software.amazon.awssdk.core.exception.SdkClientException: Profile file contained no credentials for profile 'default': ProfileFile(profilesAndSectionsMap=[]) at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:111) ~[sdk-core-2.20.94.jar!/:na] at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.lambda$createCredentialsProvider$2(ProfileCredentialsProvider.java:173) ~[auth-2.20.94.jar!/:na]

Please kindly let me know if you need any further details

Sathwik
已提問 8 個月前檢視次數 887 次
2 個答案
1
已接受的答案

Hi,

Do you use any code in your app to specify the credentials? If yes, can you detail it?

It is important to know if / how break override the credentials provided by the DefaultAWSCredentialsProviderChain. See https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html for all details on this chain of credentials

Related question: do you have the AWS STS SDK included as part of your dependencies?

i.e., if you use Maven, in our pom.xml, something like:

<dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>sts</artifactId>
        <version>2.17.108</version>
</dependency>

Best,

Didier

profile pictureAWS
專家
已回答 8 個月前
  • Hi @Didier Durand, Thanks the answer

    I did not specifying any secret and key details in the code. we are depending on the Kubernetes Service account to retrieve the role info and on further analysis I found that we have 2 different Kubernetes service account (Default, and custom) and I am expecting my Pod to access custom service account to access Dynamodb but Pod is always trying to access default service account

    Now I am checking if there is a way in java plication to specify which service account to use

0

Hello,

When using IAM roles for service accounts, the containers in your Pods must use an AWS SDK version that supports assuming an IAM role through an OpenID Connect web identity token file. Make sure that you're using the following versions, or later, for your AWS SDK:

  • Java (Version 2) – 2.10.11
  • Java – 1.11.704

https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-minimum-sdk.html

Using the AWS SDK for Java, you can build Java applications that work with DynamoDB as the SDK provides a Java API for the DynamoDB.

https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html

AWS
Olawale
已回答 8 個月前
  • Olawale-AWS, Thanks for your answer

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南