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(k8s): add service account and irsa support for in-cluster-builder #3384

Merged
merged 28 commits into from
Nov 14, 2023

Conversation

stefreak
Copy link
Member

@stefreak stefreak commented Nov 25, 2022

What this PR does / why we need it:
This PR introduces a new service account, and makes the annotations
configurable in kaniko and buildkit in-cluster-builders.

This change enables the use of IRSA for in-cluter-building which makes
in-cluster building more secure.

Which issue(s) this PR fixes:

Fixes #2931

Special notes for your reviewer:

@stefreak stefreak changed the title irsa feat(k8s): add service account and irsa support for in-cluster-builder Nov 25, 2022
@stefreak stefreak force-pushed the irsa branch 3 times, most recently from b733634 to fff9644 Compare December 1, 2022 11:19
@stefreak stefreak force-pushed the irsa branch 2 times, most recently from a79e55b to da9bebd Compare December 15, 2022 08:51
@stefreak stefreak marked this pull request as ready for review December 15, 2022 08:56
@stefreak stefreak requested a review from vvagaytsev December 15, 2022 09:27
Copy link
Collaborator

@vvagaytsev vvagaytsev left a comment

Choose a reason for hiding this comment

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

Thanks, great job! 💪 I've left a few comments and questions, please check.

core/src/plugins/kubernetes/container/build/common.ts Outdated Show resolved Hide resolved
core/src/plugins/kubernetes/container/build/common.ts Outdated Show resolved Hide resolved
core/src/plugins/kubernetes/container/build/common.ts Outdated Show resolved Hide resolved
core/src/plugins/kubernetes/container/build/buildkit.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

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

Reviewed the docs! Thanks for implementing this, this is super useful!
I have two suggestions concerning the structure of the docs as they contain significantly more content now than before:

  1. Split into documentation about pulling images and pushing images.
  2. For pushing images, keep the existing docs on how to allow all nodes to push to ECR and display using IRSA as an improved and recommended alternative.

docs/guides/in-cluster-building.md Outdated Show resolved Hide resolved
docs/guides/in-cluster-building.md Outdated Show resolved Hide resolved
docs/guides/in-cluster-building.md Outdated Show resolved Hide resolved
buildMode: kaniko
kaniko:
serviceAccountAnnotations:
eks.amazonaws.com/role-arn: arn:aws:iam::<account-id>:role/<web-identity-role-name>
Copy link
Collaborator

Choose a reason for hiding this comment

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

So nice 🎉

@stefreak stefreak dismissed twelvemo’s stale review December 16, 2022 17:59

Dismissing Annas review, because she's on vacation until next year and I implemented her suggestions

@jamesloosli
Copy link

This PR solves an issue we're having as well.

Any chance this will make the next release?

@stefreak
Copy link
Member Author

stefreak commented May 5, 2023

@jamesloosli I absolutely want to finish this but we won't make it before the 0.13 release (will happen this month).

@vvagaytsev vvagaytsev changed the base branch from main to 0.12 May 19, 2023 11:57
@stefreak stefreak changed the base branch from 0.12 to main May 22, 2023 17:41
@stefreak
Copy link
Member Author

Changed the base back to main, as this would need to land in main and not 0.12

1 similar comment
@stefreak
Copy link
Member Author

Changed the base back to main, as this would need to land in main and not 0.12

@highb
Copy link
Contributor

highb commented Aug 4, 2023

@stefreak @twelvemo Any ideas of when this PR will land and ship? This would be a massive improvement for our security posture during in-cluster builds.

@stefreak
Copy link
Member Author

stefreak commented Aug 7, 2023

@highb right now we are focused on bug fixes and stability improvements– but this is definitely something I want to look back into in the coming months.
Sorry for the delay here.

@twelvemo
Copy link
Collaborator

twelvemo commented Nov 1, 2023

Picking this up again now and also making sure this works with GCP workload identity for the in-cluster builders as well.

@twelvemo twelvemo force-pushed the irsa branch 2 times, most recently from c9c994e to 436a8b2 Compare November 14, 2023 09:44
@twelvemo twelvemo requested a review from vvagaytsev November 14, 2023 10:09
log,
})
// Both annotations should be present
expect(isEqualAnnotations(originalServiceAccount, status.remoteResources[0]))
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if expect will actually fail if you do not explicitly assert for true

Suggested change
expect(isEqualAnnotations(originalServiceAccount, status.remoteResources[0]))
expect(isEqualAnnotations(originalServiceAccount, status.remoteResources[0])).to.be.true

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@twelvemo twelvemo Nov 14, 2023

Choose a reason for hiding this comment

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

Fixed the missing assertions, but will create a new PR for adding the chai expect linter plugin because some existing tests fail the new linter rules.

Copy link
Member Author

@stefreak stefreak left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@@ -2,6 +2,6 @@ kind: Module
type: container
name: skopeo
description: Used by the kubernetes provider for interacting with container registries within a cluster
image: gardendev/skopeo:1.41.0-3
image: gardendev/skopeo:1.41.0-4
Copy link
Member Author

Choose a reason for hiding this comment

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

We do not seem to reference this image from Garden, but this can be cleaned up in a separate PR

@twelvemo
Copy link
Collaborator

Addressed all comments, could you take a look again @vvagaytsev ?

@vvagaytsev
Copy link
Collaborator

@twelvemo LGTM, thank you! 💯 I've left a minor comment, and there is one suggestion from @stefreak. Please ping me when this is ready for the final review.

@twelvemo twelvemo added this pull request to the merge queue Nov 14, 2023
Merged via the queue into main with commit 9f6b137 Nov 14, 2023
3 checks passed
@twelvemo twelvemo deleted the irsa branch November 14, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Allow custom annotations for image builders so that IRSA can be used
6 participants