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

feat(filestore): use service account for s3 api calls #320

Merged

Conversation

Hunter-Thompson
Copy link
Contributor

Summary

Makes using a secret for S3 optional. Instead, gives an option to UseServiceAccount instead.
This feature is quite important to ensure security standards.

Ticket Link

Fixes #315

Release Note

Makes using a secret for S3 calls optional, gives an option to UseServiceAccount with IAM role instead.

@mm-cloud-bot mm-cloud-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Dec 7, 2022
@mattermod
Copy link

Hello @Hunter-Thompson,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@mirshahriar
Copy link
Contributor

How is ServiceAccount used? Not seeing that ServiceAccount has been mounted in deployment. Can you point out?

@Hunter-Thompson
Copy link
Contributor Author

How is ServiceAccount used? Not seeing that ServiceAccount has been mounted in deployment. Can you point out?

ServiceAccountName: serviceAccountName,

@mirshahriar
Copy link
Contributor

mirshahriar commented Dec 8, 2022

How is ServiceAccount used? Not seeing that ServiceAccount has been mounted in deployment. Can you point out?

ServiceAccountName: serviceAccountName,

This is for the Kubernetes Native ServiceAccount. I'm not sure if it serves our needs. As far I know, this ServiceAccount is used to access Kubernetes API server (provides RBAC permissions) and related stuffs.

@Hunter-Thompson
Copy link
Contributor Author

How is ServiceAccount used? Not seeing that ServiceAccount has been mounted in deployment. Can you point out?

ServiceAccountName: serviceAccountName,

This is for the Kubernetes Native ServiceAccount. I'm not sure if it serves our needs. As far I know, this ServiceAccount is used to access Kubernetes API server (provides RBAC permissions) and related stuffs.

@mirshahriar, AWS provides a way to attach an IAM role to a Kubernetes native ServiceAccount. Allowing a deployment to access AWS services like S3, without a secret.

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

@Hunter-Thompson
Copy link
Contributor Author

The user will have to:

  1. Create SA manually
  2. Add annotation with IAM role
  3. Deploy MM operator

MM operator wont create the SA, since it already exists.

@mirshahriar
Copy link
Contributor

@mirshahriar, AWS provides a way to attach an IAM role to a Kubernetes native ServiceAccount. Allowing a deployment to access AWS services like S3, without a secret.

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

Thank you very much. I was unaware of that.

@Hunter-Thompson Hunter-Thompson requested review from mirshahriar and removed request for fmartingr and gabrieljackson December 8, 2022 12:22
@mirshahriar mirshahriar added the 2: Dev Review Requires review by a developer label Dec 8, 2022
Copy link
Contributor

@mirshahriar mirshahriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your work.

@mirshahriar
Copy link
Contributor

@Hunter-Thompson, One more thing. Can we add a check to verify whether the ServiceAccount has a certain annotation required for AWS IAM?

@Hunter-Thompson
Copy link
Contributor Author

Hunter-Thompson commented Dec 8, 2022

@mirshahriar I added a check.

Another thing to note is that - Im skipping creating the ServiceAccount if UseServiceAccount is true.
I did this because the user has to create the ServiceAccount manually, and if the ServiceAccount exists, the function will overwrite the ServiceAccount annotations if the operator creates the ServiceAccount, so I don't create the ServiceAccount if UseServiceAccount is true.

We can give the user an option to add an Annotation through the spec, but most of the time, the ServiceAccount with IAM role is created using IaaC(Infra as code), and it would cause the operator to fight with IaaC.

Thoughts?

@mirshahriar
Copy link
Contributor

Im skipping creating the ServiceAccount if UseServiceAccount is true.

I agree. Added a comment here.

@mirshahriar
Copy link
Contributor

We can give the user an option to add an Annotation through the spec

For the time being, we can leave it up to the user to manually put this in annotation.

@Hunter-Thompson
Copy link
Contributor Author

@mirshahriar changed the layout like you requested.

Copy link
Contributor

@fmartingr fmartingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Hunter-Thompson, this LGTM overall, I only have one nit comment below regarding the use service account flow control. Apart from that 👍

Copy link
Collaborator

@gabrieljackson gabrieljackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gabrieljackson gabrieljackson merged commit 22768fa into mattermost:master Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a developer kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mattermost Operator Does Not Support AWS IAM Profile for S3 Bucket Auth
6 participants