-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Added support for azure workload identity #5390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,12 +97,14 @@ type Config struct { | |
|
||
// Settings for a service principal. | ||
|
||
AADClientID string `json:"aadClientId" yaml:"aadClientId"` | ||
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"` | ||
AADClientCertPath string `json:"aadClientCertPath" yaml:"aadClientCertPath"` | ||
AADClientCertPassword string `json:"aadClientCertPassword" yaml:"aadClientCertPassword"` | ||
UseManagedIdentityExtension bool `json:"useManagedIdentityExtension" yaml:"useManagedIdentityExtension"` | ||
UserAssignedIdentityID string `json:"userAssignedIdentityID" yaml:"userAssignedIdentityID"` | ||
AADClientID string `json:"aadClientId" yaml:"aadClientId"` | ||
AADClientSecret string `json:"aadClientSecret" yaml:"aadClientSecret"` | ||
AADClientCertPath string `json:"aadClientCertPath" yaml:"aadClientCertPath"` | ||
AADClientCertPassword string `json:"aadClientCertPassword" yaml:"aadClientCertPassword"` | ||
AADFederatedTokenFile string `json:"aadFederatedTokenFile" yaml:"aadFederatedTokenFile"` | ||
UseManagedIdentityExtension bool `json:"useManagedIdentityExtension" yaml:"useManagedIdentityExtension"` | ||
UseWorkloadIdentityExtension bool `json:"useWorkloadIdentityExtension" yaml:"useWorkloadIdentityExtension"` | ||
UserAssignedIdentityID string `json:"userAssignedIdentityID" yaml:"userAssignedIdentityID"` | ||
|
||
// Configs only for standard vmType (agent pools). | ||
Deployment string `json:"deployment" yaml:"deployment"` | ||
|
@@ -155,7 +157,14 @@ func BuildAzureConfig(configReader io.Reader) (*Config, error) { | |
cfg.Location = os.Getenv("LOCATION") | ||
cfg.ResourceGroup = os.Getenv("ARM_RESOURCE_GROUP") | ||
cfg.TenantID = os.Getenv("ARM_TENANT_ID") | ||
if tenantId := os.Getenv("AZURE_TENANT_ID"); tenantId != "" { | ||
cfg.TenantID = tenantId | ||
} | ||
cfg.AADClientID = os.Getenv("ARM_CLIENT_ID") | ||
if clientId := os.Getenv("AZURE_CLIENT_ID"); clientId != "" { | ||
cfg.AADClientID = clientId | ||
} | ||
Comment on lines
+160
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This lets one override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why doing an override here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These override are here because of the project https://github.com/Azure/azure-workload-identity,
To have better interoperability I added these aliases. I can remove them though and add them in a new PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for sharing the contexts, it makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @feiskyer thank you for the feedback! |
||
cfg.AADFederatedTokenFile = os.Getenv("AZURE_FEDERATED_TOKEN_FILE") | ||
cfg.AADClientSecret = os.Getenv("ARM_CLIENT_SECRET") | ||
cfg.VMType = strings.ToLower(os.Getenv("ARM_VM_TYPE")) | ||
cfg.AADClientCertPath = os.Getenv("ARM_CLIENT_CERT_PATH") | ||
|
@@ -178,6 +187,18 @@ func BuildAzureConfig(configReader io.Reader) (*Config, error) { | |
} | ||
} | ||
|
||
useWorkloadIdentityExtensionFromEnv := os.Getenv("ARM_USE_WORKLOAD_IDENTITY_EXTENSION") | ||
if len(useWorkloadIdentityExtensionFromEnv) > 0 { | ||
cfg.UseWorkloadIdentityExtension, err = strconv.ParseBool(useWorkloadIdentityExtensionFromEnv) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
if cfg.UseManagedIdentityExtension && cfg.UseWorkloadIdentityExtension { | ||
return nil, errors.New("you can not combine both managed identity and workload identity as an authentication mechanism") | ||
} | ||
|
||
userAssignedIdentityIDFromEnv := os.Getenv("ARM_USER_ASSIGNED_IDENTITY_ID") | ||
if userAssignedIdentityIDFromEnv != "" { | ||
cfg.UserAssignedIdentityID = userAssignedIdentityIDFromEnv | ||
|
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.
+1 to mention here WorkloadIdentity couldn't be used together with other author approaches.
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 how
AADFederatedTokenFile
could be set in the helm chart?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 added documentation to the readme