简体   繁体   English

K8S 上的 Snowplow Collector 不使用服务帐户

[英]Snowplow Collector on K8S does not use service account

It seems that we cannot make the Snowplow container (snowplow/scala-stream-collector-kinesis) use the service account we provide.似乎我们无法让 Snowplow 容器 (snowplow/scala-stream-collector-kinesis) 使用我们提供的服务帐户。 It always uses the shared-eks-node-role but not the provided service account.它始终使用shared-eks-node-role但不使用提供的服务帐户。 The config is set to default for both the accessKey as the secretKey . accessKeysecretKey的配置都设置为default

This is the service account part we use:这是我们使用的服务帐户部分:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: thijs-service-account
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123:role/thijs-eks-service-account-role-snowplow

And when I inspect the pod I can see the account:当我检查 pod 时,我可以看到该帐户:

AWS_ROLE_ARN:                 arn:aws:iam::123:role/thijs-eks-service-account-role-snowplow

The error then shows not the right account.然后错误显示不正确的帐户。

Exception in thread "main" com.amazonaws.services.kinesis.model.AmazonKinesisException: User: arn:aws:sts::123:assumed-role/shared-eks-node-role/i-123 is not authorized to perform: kinesis:DescribeStream on resource: arn:aws:kinesis:eu-west-1:123:stream/snowplow-good (Service: AmazonKinesis; Status Code: 400; Error Code: AccessDeniedException; Request ID: 123-123-123; Proxy: null)

The collector itself doesn't do any role swapping.收集器本身不进行任何角色交换。 It only cares to receive credentials via one of three methods:它只关心通过以下三种方法之一接收凭据:

  • the default creds provider chain默认信用提供者链
  • a specific IAM role特定的 IAM 角色
  • environment variables.环境变量。

The most popular deployment is on an EC2 instance, in which case the default EC2 role can be used to access other resources in the account.最流行的部署是在 EC2 实例上,在这种情况下,默认的 EC2 角色可用于访问帐户中的其他资源。

It looks like when you are deploying it on EKS things are not as straightforward.看起来当您在 EKS 上部署它时,事情并不那么简单。 The collector seems to work with this assumed role: arn:aws:sts::123:assumed-role/shared-eks-node-role/i-123 but it is not authorised with Kinesis permissions.收集器似乎使用此假定角色: arn:aws:sts::123:assumed-role/shared-eks-node-role/i-123但未获得 Kinesis 权限授权。 Do you know what process creates that role?你知道什么过程创造了那个角色吗? Perhaps you could add the missing Kinesis policies there?也许您可以在那里添加缺少的 Kinesis 策略?

I had the same issue.我遇到过同样的问题。 First make sure you have the IAM role setup correctly according to https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html .首先确保您根据https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html正确设置了 IAM 角色。 Make sure the names are consistent and it has the right permissions.确保名称一致并且具有正确的权限。

Once you've double-checked that, make sure you are on a recent version of snowplow.仔细检查后,请确保您使用的是最新版本的扫雪机。 An old version might not have the right version of the AWS SDK. You need at least AWS SDK v1.12.128 or for AWS SDK v2, 2.10.11 [link] .旧版本可能没有正确版本的 AWS SDK。您至少需要 AWS SDK v1.12.128 或 AWS SDK v2, 2.10.11 [链接]

Finally set the aws accessKey and secretKey in your snowplow configuration file to default .最后将扫雪机配置文件中的 aws accessKey 和 secretKey 设置为default Redeploy and make sure the pod and service account has been recreated.重新部署并确保 Pod 和服务帐户已重新创建。 You should be good at this point.你应该擅长这一点。

Reference:参考:

https://github.com/snowplow/stream-collector/issues/186 https://github.com/snowplow/stream-collector/issues/186

I have the same issue.我有同样的问题。

It can't use env for the values, because those are not set.它不能将env用于值,因为这些值未设置。 However, the collector is runnning as a container - it should use the default credential chain.但是,收集器作为容器运行——它应该使用默认的凭证链。

From the notes, it looks like without the the env variables being set, i should use iam - which when I do this, it uses the IAM Instance Profile, which loads the underlying nodes role - not the role specified by the SA.从注释来看,似乎没有设置env变量,我应该使用iam - 当我这样做时,它使用 IAM 实例配置文件,它加载底层节点角色 - 而不是 SA 指定的角色。

The SDK supports IRSA (i have updated snowplow collector container image to 1 that has supported SDK of greater than 1.11.704 as per supported versions ), and from what I can see from the collector docs, the streams config needs an aws block with either env or iam as values... but I want to use the default credential chain without specifying a method.... SDK 支持 IRSA(我已将扫雪机收集器容器映像更新为支持 SDK 大于 1.11.704 的支持版本的 1),从收集器文档中我可以看到,流配置需要一个awsenviam作为值...但我想在不指定方法的情况下使用默认凭证链...

If i connect to the container, i can see that the creds are set up as per the SA:如果我连接到容器,我可以看到信用是根据 SA 设置的:

$ env | grep -i aws
AWS_REGION=my-region
AWS_DEFAULT_REGION=my-region
AWS_ROLE_ARN=arn:aws:iam::<redacted>:role/sp-collector-role
AWS_WEB_IDENTITY_TOKEN_FILE=/var/run/secrets/eks.amazonaws.com/serviceaccount/token

But when I run the collector, it still uses the nodes IAM Instance profile, and I don't see any activity under sp-collector-role .但是当我运行收集器时,它仍然使用节点 IAM 实例配置文件,并且我没有看到sp-collector-role下的任何活动。 Is there a way to use the default credential chain?有没有办法使用默认的凭证链? eg with aws CLI in on a container in the same service account, I don't specify any credentials, but when I run aws sts get-caller-identity the SDK resolves the IRSA role correctly.例如,在同一服务帐户的容器中使用 aws CLI,我没有指定任何凭据,但是当我运行aws sts get-caller-identity时,SDK 正确解析了IRSA角色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM