-
Notifications
You must be signed in to change notification settings - Fork 84
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: use cluster identity for using azcopy in volume cloning #1156
feat: use cluster identity for using azcopy in volume cloning #1156
Conversation
Hi @umagnus. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use config.UserAssignedIdentityID
(msi) or config.AADClientID
and config.AADClientSecret
(service principal) for volume cloning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are 3 categories:
- the azure file auth is using account name & key only (bring your own account key scenario)
- service principle auth
- managed identity auth
3.1 system assigned identity auth (you don't need to provideAZCOPY_MSI_CLIENT_ID
env)
3.2 user assigned identity auth
most folks are using System Assigned MSI in managed blob csi driver, I think you could try a local build with System Assigned MSI support first, and check whether it works in AKS managed blob csi driver in standalone env.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before copyVolume
, if secrets
is not empty, then this driver should use sas token to copy volume otherwise use cluster identity to copy volume:
blob-csi-driver/pkg/blob/controllerserver.go
Lines 420 to 422 in dedcb67
if err := d.copyVolume(ctx, req, accountKey, validContainerName, storageEndpointSuffix); err != nil { | |
return nil, err | |
} |
20fc26d
to
20a2b27
Compare
a45cd1d
to
94cce6a
Compare
pkg/blob/controllerserver.go
Outdated
if azureAuthConfig.AADClientID == "" { | ||
return []string{}, fmt.Errorf("AADClientID and AADClientSecret must be set when use service principal") | ||
} | ||
authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf(azcopySPAApplicationID+"="+azureAuthConfig.AADClientID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf("%s=%s", azcopySPAApplicationID, azureAuthConfig.AADClientID), fmt.Sprintf("%s=%s", ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/blob/controllerserver.go
Outdated
klog.V(2).Infof("use user assigned managed identity to authorize azcopy") | ||
authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf(azcopyMSIClientID+"="+azureAuthConfig.UserAssignedIdentityID)) | ||
} | ||
klog.V(2).Infof("use system-assigned managed identity to authorize azcopy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else {
klog.V(2).Infof("use system-assigned managed identity to authorize azcopy")
}
otherwise L810 & L815 would be both printed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/blob/controllerserver.go
Outdated
return []string{}, fmt.Errorf("AADClientSecret shouldn't be nil or useManagedIdentityExtension must be set to true") | ||
} | ||
|
||
// getSASToken will generate sas token for azcopy if secrets is not nil or cluster not use managed identity/service principal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// getSASToken will only generate sas token for azcopy in following conditions:
1. secrets is not empty
2. driver is not using managed identity and service principal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/util/util.go
Outdated
} | ||
|
||
func (ec *ExecCommand) RunCommand(cmd string) (string, error) { | ||
out, err := exec.Command("sh", "-c", cmd).CombinedOutput() | ||
func (ec *ExecCommand) RunCommand(cmdStr string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could make the function more generic:
RunCommand(cmdStr string, authEnv []string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(authEnv) > 0 {
cmd.Env = append(os.Environ(), ec.AuthAzcopyEnv...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
e448d3c
to
3629254
Compare
/retest |
1 similar comment
/retest |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and pls squash commits, thanks.
1d63250
to
42832f1
Compare
42832f1
to
7e0f0e9
Compare
/retest |
1 similar comment
/retest |
@umagnus: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, umagnus 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 |
/cherrypick release-1.23 |
@andyzhangx: new pull request created: #1195 In response to this:
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. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
azcopy already supports managed identity in a different way: Authorize access to blobs with AzCopy & Microsoft Entra ID | Microsoft Learn
if user only provides storage account key, then we should use sas token; otherwise we should leverage aks cluster identity(managed identity or spn) for volume cloning which is better way.
Which issue(s) this PR fixes:
Fixes #
Requirements:
Special notes for your reviewer:
use system managed identity logs:
use service principal or user assigned managed identity, it should grant it "Storage Blob Data Contributor" role, or it will return
AuthorizationPermissionMismatch
error in azcopy. If it doesn't have this role, we will fall back to generate sas token for azcopy.AuthorizationPermissionMismatch
error:Release note: