Skip to content

✨ Add AWS IAM support #677

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

Merged

Conversation

suvaanshkumar
Copy link
Contributor

@suvaanshkumar suvaanshkumar commented Oct 27, 2024

Summary

The PR adds changes for AWS IAM based authentication support for Open Cluster Management (OCM) for Amazon EKS clusters. This change updates the Klusterletconfig object by adding the registration driver for awsirsa when the value of registration-auth flag is set as awsirsa from clusteradm join command.

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from elgnay and xuezhaojun October 27, 2024 20:51
@suvaanshkumar suvaanshkumar changed the title ✨ Add AWS IRSA support ✨ Add AWS IAM support Oct 27, 2024
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 27.10843% with 121 lines in your changes missing coverage. Please review.

Project coverage is 63.37%. Comparing base (603b405) to head (2e2bd19).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pkg/registration/register/aws_irsa/aws_irsa.go 26.66% 33 Missing ⚠️
...kg/registration/spoke/registration/registration.go 0.00% 28 Missing ⚠️
pkg/registration/spoke/spokeagent.go 42.22% 23 Missing and 3 partials ⚠️
pkg/registration/register/aws_irsa/aws.go 0.00% 16 Missing ⚠️
pkg/registration/helpers/helpers.go 0.00% 10 Missing ⚠️
pkg/registration/spoke/options.go 0.00% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
- Coverage   63.72%   63.37%   -0.35%     
==========================================
  Files         182      185       +3     
  Lines       17611    17765     +154     
==========================================
+ Hits        11222    11258      +36     
- Misses       5460     5576     +116     
- Partials      929      931       +2     
Flag Coverage Δ
unit 63.37% <27.10%> (-0.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mikeshng mikeshng left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

It's currently failing at this check. Could you please make sure it works locally make update-gofmt?

Also, could you please update the PR summary with more details?

@mikeshng
Copy link
Member

mikeshng commented Nov 1, 2024

@dtclxy64 @suvaanshkumar could you please take a look at the merge conflict and rebase?

I think you could try deleting the following, based on the PR #658


		reSelectChecker: &reSelectChecker{shouldReSelect: false},
		bootstrapKubeconfigEventHandler: &bootstrapKubeconfigEventHandler{
			bootstrapKubeconfigSecretName: &opts.BootstrapKubeconfigSecret,
			cancel:                        cancel,
		},

@mikeshng
Copy link
Member

mikeshng commented Nov 4, 2024

@dtclxy64 thanks for the rebase. It's now failing at the DCO check and make update-gofmt check.
For DCO you could try:
git commit -s --amend then force push.

@mikeshng
Copy link
Member

mikeshng commented Nov 6, 2024

All the PR checks seem to be ok now. Great job @dtclxy64 and @suvaanshkumar

/assign @qiujian16

Copy link
Member

@qiujian16 qiujian16 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 in general, just some minor comments

@@ -74,6 +76,10 @@ func (o *SpokeAgentOptions) AddFlags(fs *pflag.FlagSet) {
"the value of --cluster-signing-duration command-line flag of the kube-controller-manager will be used.")
fs.StringToStringVar(&o.ClusterAnnotations, "cluster-annotations", o.ClusterAnnotations, `the annotations with the reserve
prefix "agent.open-cluster-management.io" set on ManagedCluster when creating only, other actors can update it afterwards.`)
fs.StringVar(&o.RegistrationAuth, "registration-auth", o.RegistrationAuth,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have a drivers Options and we just need to AddFlags here?

Copy link
Member

Choose a reason for hiding this comment

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

@qiujian16 We are currently using the registration-auth flag to determine the type of registerDriver to set up. See lines 199-202 in pkg/registration/spoke/spokeagent.go.

Are you suggesting that we should add another flag to capture the type of the registration driver as well?

Copy link
Member

@qiujian16 qiujian16 Nov 11, 2024

Choose a reason for hiding this comment

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

the flag name is fine. I think you could put all these flags adding func to the register directory with a new Option struct. And the code here just to call driverOptions.AddFlags(fs), but this is not outstanding. We could do code restructure as a followup.

)

const (
// TLSKeyFile is the name of tls key file in kubeconfigSecret
Copy link
Member

Choose a reason for hiding this comment

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

nit you would not need these files. This are only for mtls

Copy link
Member

Choose a reason for hiding this comment

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

These constants are currently referenced by the BuildKubeConfigFromTemplate function in the aws-irso.go, the implementation is just a placeholder for now, so we'll remove these constants in one of the upcoming PRs once we have the function fully implemented for the AWSIRSADriver.

Copy link
Member

Choose a reason for hiding this comment

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

Add a //TODO here so we do not forget to remove these later.

@@ -421,6 +421,9 @@ type TestCert struct {
Key []byte
}

type TestIrsaRequest struct {
}
Copy link
Member

Choose a reason for hiding this comment

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

might add some TODO or comment here, I am not quite sure why this is added.

Copy link
Member

Choose a reason for hiding this comment

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

We are using the struct in aws_irsa_test.go on lines 38 and 64, which is setting up a test irsa driver for each test case.

Copy link
Member

Choose a reason for hiding this comment

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

I see, I think we could add a //TODO here so we will not forget the followup task later :)

@@ -158,3 +159,12 @@ func IsCSRSupported(nativeClient kubernetes.Interface) (bool, bool, error) {
}
return v1CSRSupported, v1beta1CSRSupported, nil
}

func IsEksArnWellFormed(eksArn string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

add some comment for this func, it will be easier to understand what is the format for the arn.

@@ -54,7 +59,8 @@ type SpokeAgentConfig struct {

internalHubConfigValidFunc wait.ConditionWithContextFunc

hubKubeConfigChecker *hubKubeConfigHealthChecker
hubKubeConfigChecker *hubKubeConfigHealthChecker
bootstrapKubeconfigEventHandler *bootstrapKubeconfigEventHandler
Copy link
Member

Choose a reason for hiding this comment

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

why this is added? I did not see where it is used

Copy link
Member

Choose a reason for hiding this comment

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

We got the change from the main branch which was introduced as part of PR #630, but we see in the latest main branch, it's no longer used. We removed it to match the main branch as requested.

…d from the NewSpokeAgentConfig function based on code review comments.

Signed-off-by: Suvaansh <[email protected]>
@qiujian16
Copy link
Member

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 13, 2024
Copy link
Contributor

openshift-ci bot commented Nov 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, suvaanshkumar

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

@openshift-merge-bot openshift-merge-bot bot merged commit 67b4f1a into open-cluster-management-io:main Nov 13, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants