-
Notifications
You must be signed in to change notification settings - Fork 351
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
MSK IAM auth without rotating short term keys/tokens? #275
Comments
@tooptoop4 I'm unsure what you mean, the default is an IAM role? |
if I don't set KAFKA_SASL_AWSMSKIAM_SESSIONTOKEN and the other 2 variables I get sasl error |
Access key and secret key are required, that's effectively your use and pass. Session token is not. |
but for java clients the access/secret key are not required |
AFAIK, Java clients still load the access key / secret key, they just do this automatically by checking relevant environment variables or checking your ~/.aws/credentials automatically. The aws Go library can do this as well -- kowl just does not use that currently to auto-detect credentials. When using a Java client, do you have any credentials at ~/.aws/credentials? |
no ~/.aws/credentials or env variables |
Do you have any of the credentials located anywhere in options 1 through 7 as described in https://github.com/aws/aws-msk-iam-auth#configuring-a-kafka-client-to-use-aws-iam ? |
just 7 (http://169.254.169.254/latest/meta-data/iam/security-credentials/ returns a role) but I don't have to call that endpoint for the java client to work |
Ok, so this is specific to the AWS library doing a lot of magic behind the scenes to try every possible way to load keys. The aws-sdk-go package provides some ways to automagically load creds, if @weeco wants to add them to kowl. |
@weeco is anyone working on adding this feature? |
Hello, @weeco |
anyone got this working? I wonder if dpkp/kafka-python#2255 (comment) works |
I'm using AWS_MSK_IAM and IRSA that provide web identity and role arn is that supported ? I get the following failure
Using
|
This is preventing us from using Console in our environment, otherwise it looks super handy. Basically, we use IRSA to assign roles to K8s service accounts, and currently the accessKey and secretKey are hard-coded as the only AWS_MSK_IAM way to authenticate. Could you fall back to the default AWS SDK functionality if the access key and secret key aren't provided? |
Can somebody lay down what is required to help you guys? Im not very familiar with AWS, but possibly open to pull request after a quick discussion on how to do it. |
@weeco thanks for the quick response! From what I understand after some quick looking, the library in use already has support for reading from the environment, as outlined at https://github.com/twmb/franz-go/tree/master/examples/sasl/aws_msk_iam. I'm pretty sure that as long as Console doesn't require the access key, secret, and session token, it will look them up in the environment using the AWS SDK, and will pick them up automatically. |
@jaredtbates Thank you. By looking at the code I dont think it requires you to set the access key, see: console/backend/pkg/config/kafka_sasl_aws_iam.go Lines 41 to 44 in 0ba44b2
What error do you get if you set the SASL mechanism to use MSK IAM but not specify any of these properties? |
Hey sorry to jump in. But I'm in a similar situation with Console from Redpanda and I get the following error:
|
Hi. We're using Redpanda Console as a k8s deployment on EKS deployed using the official Helm chart, with IRSA authentication. Everything works well after initial deployment, but after exactly 1 hour, we start getting By default, the IRSA token has duration of 1h and I guess the problem is that there is no token refresh implemented. Looking at the code here, it looks like that is indeed the case - token is fetched at startup and reused for all subsequent requests. That works until the token expires, after which all requests fail as unauthenticated. Here is the config we use for Redpanda Console and for the service account: console:
config:
kafka:
brokers:
- b-1.xxx.yyyyyy.zz.kafka.eu-central-1.amazonaws.com:9098
- b-2.xxx.yyyyyy.zz.kafka.eu-central-1.amazonaws.com:9098
- b-3.xxx.yyyyyy.zz.kafka.eu-central-1.amazonaws.com:9098
sasl:
enabled: true
mechanism: AWS_MSK_IAM
tls:
enabled: true Here is the config we use for service account: serviceAccount:
create: true
automountServiceAccountToken: true
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/something And here is the error log after one hour, once the token expires:
We could increase token expiry duration, but that would just reduce the frequency of the problem, as we can't make it non-expire. it would be better to change the code to not persist and reuse the same token. I'm willing to make a PR with this change, if you confirm that the assessment is correct and suggested improvement is the way to go. |
Same case here. Did you find any solution? |
I can confirm #1253 resolved the issue, thanks @mislavmandaricaxilis! Here is my custom Helm chart values.yaml: image:
registry: docker.redpanda.com
repository: redpandadata/console
# https://hub.docker.com/r/redpandadata/console/tags
tag: v2.6.1
console:
config:
kafka:
brokers:
- b-1.hmkafka.xxxxxx.xx.kafka.us-west-2.amazonaws.com:9098
- b-2.hmkafka.xxxxxx.xx.kafka.us-west-2.amazonaws.com:9098
- b-3.hmkafka.xxxxxx.xx.kafka.us-west-2.amazonaws.com:9098
sasl:
enabled: true
mechanism: AWS_MSK_IAM
tls:
enabled: true
serviceAccount:
create: true
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::xxxxxxxxxxxx:role/RedpandaConsoleRole-hm-redpanda-console Note the latest Helm chart |
currently kowl works with:
export KAFKA_SASL_AWSMSKIAM_SESSIONTOKEN='...redact'
export KAFKA_SASL_AWSMSKIAM_SECRETKEY='..redact'
export KAFKA_SASL_AWSMSKIAM_ACCESSKEY='..redact'
does it work with IAM role (like for java clients) instead of supplying aws keys/tokens that need to be rotated?
The text was updated successfully, but these errors were encountered: