簡體   English   中英

如何使用 aws 命令獲取 EKS Pod 角色

[英]How to get EKS Pod role with aws command

我需要 eks pod 角色而不是工作節點角色但是,當我嘗試以下命令時,我只能獲得 eks 工作節點角色..

=> curl http://169.254.169.254/latest/meta-data/iam/security-credentials; 回聲

我怎樣才能獲得 Pod 角色?

我需要 pod 角色來設置 GOOGLE_APPLICATION_CREDENTIALS 配置文件。

{
  "type": "external_account",
  "audience": "~~~~~~~~",
  "subject_token_type": "~~~~~~~",
  "token_url": "https://sts.googleapis.com/v1/token",
  "credential_source": {
    "environment_id": "aws1",
    "region_url": "http://169.254.169.254/latest/meta-data/placement/availability-zone",
    "url": "http://169.254.169.254/latest/meta-data/iam/security-credentials", ====> return worker node role
    "regional_cred_verification_url": "https://sts.{region}.amazonaws.comAction=GetCallerIdentity&Version=2011-06-15"
  },
  "service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/!@#$!@#$!@#$.iam.gserviceaccount.com:generateAccessToken"
}

請幫幫我。 太感謝了。

yes i already assume a role in GCP

然后,您可以使用eksctl為您的 pod 創建一個與上述 IAM 角色具有相同策略的服務帳戶:

eksctl create iamserviceaccount \
  --name <name of the service account> \
  --namespace <where the service account resides> \
  --cluster <cluster name> \
  --attach-policy-arn arn:aws:iam::<account>:policy/<name of the IAM policy> \
  --approve

請參考您的規范中的服務帳戶:

...
spec:
  serviceAccountName: <name of the service account>
  ...

現在您的 pod 將承擔 IAM 角色而不是節點角色。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM