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(frontend): Implement aws-js-sdk crendentials to support IRSA for s3 #8651

Merged
merged 8 commits into from Jan 25, 2023

Conversation

ryansteakley
Copy link
Contributor

Description of your changes:

#8502 details most of the changes and reasoning in a design document.

Removing most of the aws-helper code that pertains to grabbing the credentials from the ec2 instance metadata as this code is already handled as part of the credentialProviderChain that is being imported here.

Checklist:

@ryansteakley
Copy link
Contributor Author

@ryansteakley
Copy link
Contributor Author

ryansteakley commented Jan 5, 2023

Looks like the prow job is running with node 12 installed, when it should move to using node 14? The front-end unit tests pass locally. https://github.com/GoogleCloudPlatform/oss-test-infra/blob/b3128a944261abbbc3e23b7db974f95ea6c93192/prow/prowjobs/kubeflow/pipelines/kubeflow-pipelines-presubmits.yaml#L9 and I've opened a pr GoogleCloudPlatform/oss-test-infra#1864

@zijianjoy
Copy link
Collaborator

/test kubeflow-pipeline-frontend-test

@ryansteakley
Copy link
Contributor Author

ryansteakley commented Jan 12, 2023

Good to see that the node14 update lets the tests run. Let me fix this unit-test looks like this is expected now since the prow has no credentials and it has exhausted all options. Missed this locally since my local env must have had some lingering creds somewhere.

@ryansteakley
Copy link
Contributor Author

/retest

@@ -39,22 +39,21 @@ export interface MinioClientOptionsWithOptionalSecrets extends Partial<MinioClie
export async function createMinioClient(config: MinioClientOptionsWithOptionalSecrets) {
if (!config.accessKey || !config.secretKey) {
try {
if (await awsInstanceProfileCredentials.ok()) {
const credentials = await awsInstanceProfileCredentials.getCredentials();
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the design doc, you mention that we will fail back to existing solution if the IRSA doesn't work. It doesn't look like the case in this block. Can we retain the existing solution?

return new MinioClient({ ...config, accessKey, secretKey, sessionToken });
}
console.error('unable to get credentials from AWS metadata store.');
const credentials = fromNodeProviderChain();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to detect the source of object storage is AWS first, and perform IRSA only when it is AWS S3? (Pattern like "arn:aws:s3:::$mybucket/*") If it is generic S3 API, then we shouldn't use IRSA solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zijianjoy The code that used to be in this block was checking for AWS metadata store credentials. The fromNodeProviderChain() will try to access IRSA credentials then fallback and one of those would be AWS metadata store credentials which retains the exsiting functionality.

If the option is preferred, then what I can do is call the existing

export function isS3Endpoint(endpoint: string = ''): boolean {
and have this IRSA code live as an if statement above the rest of the code in this method. i.e (if isS3Endpoint) ->my new code

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hello Ryan, thank you for replying to my comment, Sounds good on using isS3Endpoint , I would also suggest adding a comment to explain that which logic area is specific to AWS, and which logic is generic S3.

Copy link
Contributor

@surajkota surajkota Jan 18, 2023

Choose a reason for hiding this comment

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

@zijianjoy What is an example of generic S3 which has s3:// in the source/URL?
https://github.com/kubeflow/pipelines/blob/master/frontend/server/handlers/artifacts.ts#L33

Want to make sure we do not introduce a breaking change, ref #8651 (comment)

@@ -37,6 +38,25 @@ export interface MinioClientOptionsWithOptionalSecrets extends Partial<MinioClie
* @param config minio client options where `accessKey` and `secretKey` are optional.
*/
export async function createMinioClient(config: MinioClientOptionsWithOptionalSecrets) {
// This logic is AWS S3 specific
if (isS3Endpoint(config.endPoint)) {
Copy link
Contributor

@surajkota surajkota Jan 18, 2023

Choose a reason for hiding this comment

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

I think this would be a breaking change. Please correct me if my understanding is not correct

as of now no endpoint is set when running on an AWS by default. Afaik, it hits the s3 case based of the URL of the object i.e. source being s3 s3://

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When createMinioClient is called in the s3 case it passes in the aws artifactsConfig which contains endpoint, that resolves to the default value of s3.amazonaws.com or the env variable of AWS_S3_ENDPOINT. I'm not sure what you mean by breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

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

endPoint: AWS_S3_ENDPOINT || 's3.amazonaws.com',

Got it, thanks

frontend/server/aws-helper.test.ts Show resolved Hide resolved
frontend/server/minio-helper.test.ts Outdated Show resolved Hide resolved
@ryansteakley
Copy link
Contributor Author

/test kubeflow-pipeline-frontend-test

Copy link
Contributor

@surajkota surajkota left a comment

Choose a reason for hiding this comment

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

Good work

}
}

// This logic is S3 generic
if (!config.accessKey || !config.secretKey) {
try {
if (await awsInstanceProfileCredentials.ok()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is outdated and should be removed since there is an updated implementation for AWS S3. New implementation supports multiple ways to provide credentials including better security practices.

Better to discuss it in a separate PR

@ryansteakley
Copy link
Contributor Author

@zijianjoy Can you take another look?

@surajkota
Copy link
Contributor

friendly reminder @zijianjoy since next release might be planned soon. We want to test this as part of distribution testing. Thanks

@jlyaoyuli
Copy link
Collaborator

Hi @surajkota @ryansteakley ,
This is Joe from KFP frontend, I will review the PR as soon as possible. Thank you!

@jlyaoyuli
Copy link
Collaborator

/lgtm
/approve
Thank you @ryansteakley and @surajkota for this implementation.

@google-oss-prow google-oss-prow bot added the lgtm label Jan 25, 2023
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jlyaoyuli, mvoitko, surajkota

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 9b9b3ac into kubeflow:master Jan 25, 2023
chensun pushed a commit that referenced this pull request Mar 8, 2023
… s3 (#8651)

* use aws js sdk for credentials concerning aws

* format code

* catch exception if no credentials are found after using credentialchain

* revert changes and add section for specific aws changes

* revert deleting aws-helper mock

* add privatelink test for isS3endpiont

* fix try block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
KFP Runtime Triage
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

5 participants