Skip to content

add sts regional endpoint logic - #313

Merged
k8s-ci-robot merged 4 commits into
kubernetes:masterfrom
prasita123:dev_branch_1
Mar 3, 2022
Merged

add sts regional endpoint logic#313
k8s-ci-robot merged 4 commits into
kubernetes:masterfrom
prasita123:dev_branch_1

Conversation

@prasita123

@prasita123 prasita123 commented Mar 3, 2022

Copy link
Copy Markdown
Contributor

What type of PR is this?

kind bug

What this PR does / why we need it:
STS suggests using regional endpoints. (source)

AWS recommends using Regional STS endpoints to reduce latency, build in redundancy, and increase session token validity.

The PR uses sts regional endpoints, fetched using the metadata, instead of global endpoints.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Updates to the cloud-controller-manager to use regional endpoint instead of global endpoint, as AWS recommends using Regional STS endpoints to reduce latency, build in redundancy, and increase session token validity.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Mar 3, 2022
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @prasita123!

It looks like this is your first PR to kubernetes/cloud-provider-aws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/cloud-provider-aws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 3, 2022
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @prasita123. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 3, 2022
Comment thread pkg/providers/v1/aws.go Outdated
return eni.NetworkInterfaces[0], nil
}

func getRegionFromMetadata(cfg *CloudConfig) (string, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

since this is almost identical to the passage

metadata, err := awsServices.Metadata()
if err != nil {
return nil, fmt.Errorf("error creating AWS metadata client: %q", err)
}
err = updateConfigZone(&cfg, metadata)
if err != nil {
return nil, fmt.Errorf("unable to determine AWS zone from cloud provider config or EC2 instance metadata: %v", err)
}
zone := cfg.Global.Zone
if len(zone) <= 1 {
return nil, fmt.Errorf("invalid AWS zone in config file: %s", zone)
}
regionName, err := azToRegion(zone)
if err != nil {
return nil, err
}

could you refactor that to also use this function?

@wongma7

wongma7 commented Mar 3, 2022

Copy link
Copy Markdown

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 3, 2022
Comment thread pkg/providers/v1/aws.go Outdated
}

return regionName, nil
} No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread pkg/providers/v1/aws.go Outdated
zone string
}

func getRegionFromMetadata(cfg CloudConfig, metadata EC2Metadata) (*regionDetails, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

consider returning multiple return values like

(string, string, err)
region, zone, err 

instead. I like it better than a special struct

Comment thread pkg/providers/v1/aws.go Outdated
if err != nil {
return nil, err
}
regiondetails, err := getRegionFromMetadata(cfg, metadata)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must check for err here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the lack of err check causes TestNewAWSCloud to fail now after the refactor, try the test locally as well to verify .. https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/cloud-provider-aws/313/pull-cloud-provider-aws-test/1499235237555605504

@wongma7

wongma7 commented Mar 3, 2022

Copy link
Copy Markdown

/test pull-cloud-provider-aws-e2e

@wongma7

wongma7 commented Mar 3, 2022

Copy link
Copy Markdown

/retest

@nckturner

Copy link
Copy Markdown
Contributor

/test pull-cloud-provider-aws-e2e

Comment thread pkg/providers/v1/aws.go
@prasita123

prasita123 commented Mar 3, 2022

Copy link
Copy Markdown
Contributor Author

tested the change on a v1.22 cluster (manifest bd810fe3d5ba620f3d7cad5e4b40c11bc6efa1471d2e5075f459d29f48dca745)

  • validated the sts endpoint on a newly launched instance by terminating an existing node instance of the cluster
"tlsDetails": {
        "tlsVersion": "TLSv1.2",
        "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
        "clientProvidedHostHeader": "sts.us-west-2.amazonaws.com"
    }

https://tiny.amazon.com/a7l9nrne/IsenLink

@wongma7

wongma7 commented Mar 3, 2022

Copy link
Copy Markdown

/lgtm
but does it need a release note? maybe yes for the miniscule non-zero chance somebody has not enabled regional endpoint in opt-in region? if not put NONE in the field at the bottom of PR description

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2022
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: prasita123, wongma7

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

The pull request process is described here

Details 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 3, 2022
@nckturner

Copy link
Copy Markdown
Contributor

Yeah let's add one. Which reminds me... we need some mechanism to get release notes out of this don't we? I'm assuming that is buried in the kubernetes release automation but doesn't apply to other repositories.

@wongma7

wongma7 commented Mar 3, 2022

Copy link
Copy Markdown

@nckturner

Copy link
Copy Markdown
Contributor

/test pull-cloud-provider-aws-check

1 similar comment
@nckturner

Copy link
Copy Markdown
Contributor

/test pull-cloud-provider-aws-check

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 3, 2022
@k8s-ci-robot
k8s-ci-robot merged commit 67cbbd1 into kubernetes:master Mar 3, 2022
k8s-ci-robot added a commit that referenced this pull request Mar 4, 2022
…-upstream-release-1.22

Automated cherry pick of #313: add sts regional endpoint logic
k8s-ci-robot added a commit that referenced this pull request Jun 21, 2022
…f-#313-release-1.21

Automated cherry pick of #313: add sts regional endpoint logic
k8s-ci-robot added a commit that referenced this pull request Jun 21, 2022
…f-#313-release-1.20

Automated cherry pick of #313: add sts regional endpoint logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants