-
Notifications
You must be signed in to change notification settings - Fork 192
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
CCO-318: Enable Azure Workload Identity authentication. #906
Conversation
8c1e78d
to
97d0dbd
Compare
@jstuever: This pull request references CCO-318 which is a valid jira issue. 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. |
@jstuever: This pull request references CCO-318 which is a valid jira issue. 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. |
@jstuever: This pull request references CCO-318 which is a valid jira issue. 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. |
@jstuever: This pull request references CCO-318 which is a valid jira issue. 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. |
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.
I've made some minor suggestions, but this looks fine to me overall.
/approve
pkg/dns/azure/client/auth.go
Outdated
var ( | ||
cred azcore.TokenCredential | ||
err error | ||
) | ||
if config.AzureWorkloadIdentityEnabled && strings.TrimSpace(config.ClientSecret) == "" { | ||
options := azidentity.WorkloadIdentityCredentialOptions{ | ||
ClientOptions: azcore.ClientOptions{ | ||
Cloud: cloudConfig, | ||
}, | ||
ClientID: config.ClientID, | ||
TenantID: config.TenantID, | ||
TokenFilePath: config.FederatedTokenFile, | ||
} | ||
cred, err = azidentity.NewWorkloadIdentityCredential(&options) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} else { | ||
options := azidentity.ClientSecretCredentialOptions{ | ||
ClientOptions: azcore.ClientOptions{ | ||
Cloud: cloudConfig, | ||
}, | ||
} | ||
cred, err = azidentity.NewClientSecretCredential(config.TenantID, config.ClientID, config.ClientSecret, &options) |
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.
Is there a reason to declare err
in the outer scope?
var ( | |
cred azcore.TokenCredential | |
err error | |
) | |
if config.AzureWorkloadIdentityEnabled && strings.TrimSpace(config.ClientSecret) == "" { | |
options := azidentity.WorkloadIdentityCredentialOptions{ | |
ClientOptions: azcore.ClientOptions{ | |
Cloud: cloudConfig, | |
}, | |
ClientID: config.ClientID, | |
TenantID: config.TenantID, | |
TokenFilePath: config.FederatedTokenFile, | |
} | |
cred, err = azidentity.NewWorkloadIdentityCredential(&options) | |
if err != nil { | |
return nil, err | |
} | |
} else { | |
options := azidentity.ClientSecretCredentialOptions{ | |
ClientOptions: azcore.ClientOptions{ | |
Cloud: cloudConfig, | |
}, | |
} | |
cred, err = azidentity.NewClientSecretCredential(config.TenantID, config.ClientID, config.ClientSecret, &options) | |
var cred azcore.TokenCredential | |
if config.AzureWorkloadIdentityEnabled && strings.TrimSpace(config.ClientSecret) == "" { | |
options := azidentity.WorkloadIdentityCredentialOptions{ | |
ClientOptions: azcore.ClientOptions{ | |
Cloud: cloudConfig, | |
}, | |
ClientID: config.ClientID, | |
TenantID: config.TenantID, | |
TokenFilePath: config.FederatedTokenFile, | |
} | |
var err error | |
cred, err = azidentity.NewWorkloadIdentityCredential(&options) | |
if err != nil { | |
return nil, err | |
} | |
} else { | |
options := azidentity.ClientSecretCredentialOptions{ | |
ClientOptions: azcore.ClientOptions{ | |
Cloud: cloudConfig, | |
}, | |
} | |
var err error | |
cred, err = azidentity.NewClientSecretCredential(config.TenantID, config.ClientID, config.ClientSecret, &options) |
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.
No reason, was just blindly following the enhancement.
Updated.
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.
Did you mean to delete config.AzureWorkloadIdentityEnabled &&
in https://github.com/openshift/cluster-ingress-operator/compare/02a3c1434367c4ce82e84f3a42b393de92765541..d8c1cafad42eff9f781248a166e6e591a203ff24?
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.
No, I did not. I must have fumbled it during a rebase. Fixed. Thanks!
pkg/dns/azure/client/client.go
Outdated
Environment azure.Environment | ||
SubscriptionID string | ||
ClientID string | ||
ClientSecret string | ||
FederatedTokenFile string | ||
TenantID string | ||
AzureWorkloadIdentityEnabled bool |
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.
Would you mind adding godoc for these fields? In particular, it's getting confusing which fields are used in what situations. Looks like SubscriptionID
, ClientID
, and TenantID
are always required; FederatedTokenFile
is required when using workload identity; and ClientSecret
is required when not using workload identity. Is that correct? Following is my attempt at describing these fields—please check for errors and discard or modify as necessary:
Environment azure.Environment | |
SubscriptionID string | |
ClientID string | |
ClientSecret string | |
FederatedTokenFile string | |
TenantID string | |
AzureWorkloadIdentityEnabled bool | |
// Environment describes the Azure environment: ChinaCloud, | |
// USGovernmentCloud, PublicCloud, or AzureStackCloud. If empty, | |
// AzureStackCloud is assumed. | |
Environment azure.Environment | |
// SubscriptionID is the subscription id for the Azure identity. | |
SubscriptionID string | |
// ClientID is an Azure application client id. | |
ClientID string | |
// ClientSecret is an Azure application client secret. It is required | |
// if Azure workload identity is not used. | |
ClientSecret string | |
// FederatedTokenFile is the path to a file containing a workload | |
// identity token. If FederatedTokenFile is specified and | |
// AzureWorkloadIdentityEnabled is true, then Azure workload identity is | |
// used instead of using a client secret. | |
FederatedTokenFile string | |
// TenantID is the Azure tenant ID. | |
TenantID string | |
// AzureWorkloadIdentityEnabled indicates whether the | |
// "AzureWorkloadIdentity" feature gate is enabled. | |
AzureWorkloadIdentityEnabled bool |
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, and thanks!
pkg/operator/operator.go
Outdated
// example of future featuregate read and usage to set a variable to pass to a controller | ||
AzureWorkloadIdentityEnabled := featureGates.Enabled(configv1.FeatureGateAzureWorkloadIdentity) |
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.
The comment can be removed (I missed that 3d26626 removed the _ = sets.New[configv1.FeatureGateName](enabled...).Has("AzureWorkloadIdentity")
line that the comment described). Uppercase AzureWorkloadIdentityEnabled
looks funny for a function-local variable.
// example of future featuregate read and usage to set a variable to pass to a controller | |
AzureWorkloadIdentityEnabled := featureGates.Enabled(configv1.FeatureGateAzureWorkloadIdentity) | |
azureWorkloadIdentityEnabled := featureGates.Enabled(configv1.FeatureGateAzureWorkloadIdentity) |
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Miciah 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 |
/retest-required |
/retest |
1 similar comment
/retest |
/label docs-approved |
/label qe-approved |
Adding px-approved per a conversation with cfields. /label px-approved |
Authenticate with an Azure Workload Identity (AZWI) serviceaccount token when client secret is absent from auth config.
Rebased to resolve merge conflicts in go.mod and related module files. |
/lgtm |
/retest |
/hold |
/hold cancel |
e2e-gcp-operator failed because |
@Miciah: Overrode contexts on behalf of Miciah: ci/prow/e2e-gcp-operator 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. |
@jstuever: all tests passed! Full PR test history. Your PR dashboard. 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. |
/label jira/valid-bug |
Authenticate with an Azure Workload Identity (AZWI) serviceaccount token when client secret is absent from auth config.
https://issues.redhat.com/browse/CCO-318