Skip to content
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

grant devops msi cluster admin permission during cluster creation #967

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions dev-infrastructure/modules/aks-cluster-base.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,31 @@ param userOsDiskSizeGB int

param acrPullResourceGroups array = []

@description('MSI that will take actions on the AKS cluster during service deployment time')
param aroDevopsMsiId string

@description('Perform cryptographic operations using keys. Only works for key vaults that use the Azure role-based access control permission model.')
var keyVaultCryptoUserId = subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions',
'12338af0-0e69-4776-bea7-57ae8d297424'
)

// Azure Kubernetes Service Cluster Admin Role
// https://www.azadvertizer.net/azrolesadvertizer/0ab0b1a8-8aac-4efd-b8c2-3ee1fb270be8.html
var aksClusterAdminRoleId = subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions/',
'0ab0b1a8-8aac-4efd-b8c2-3ee1fb270be8'
)

// Azure Kubernetes Service RBAC Cluster Admin Role
// https://www.azadvertizer.net/azrolesadvertizer/b1ff04bb-8a4e-4dc4-8eb5-8693973ce19b.html
var aksClusterAdminRBACRoleId = subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions/',
'b1ff04bb-8a4e-4dc4-8eb5-8693973ce19b'
)

// Network Contributor Role
// https://www.azadvertizer.net/azrolesadvertizer/4d97b98b-1d4f-4787-a291-c67834d212e7.html
var networkContributorRoleId = subscriptionResourceId(
'Microsoft.Authorization/roleDefinitions/',
'4d97b98b-1d4f-4787-a291-c67834d212e7'
Expand Down Expand Up @@ -454,6 +469,18 @@ resource uami_fedcred 'Microsoft.ManagedIdentity/userAssignedIdentities/federate
}
]

// grant aroDevopsMsi the aksClusterAdmin role on the aksCluster so it can
// deploy services to the cluster
resource aroDevopsMSIClusterAdmin 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(aksCluster.id, aroDevopsMsiId, aksClusterAdminRBACRoleId)
scope: aksCluster
properties: {
principalId: reference(aroDevopsMsiId, '2023-01-31').principalId
principalType: 'ServicePrincipal'
roleDefinitionId: aksClusterAdminRBACRoleId
}
}

// Outputs
output userAssignedIdentities array = [
for i in range(0, length(workloadIdentities)): {
Expand Down
1 change: 1 addition & 0 deletions dev-infrastructure/templates/mgmt-cluster.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ module mgmtCluster '../modules/aks-cluster-base.bicep' = {
systemAgentVMSize: systemAgentVMSize
systemOsDiskSizeGB: aksSystemOsDiskSizeGB
userOsDiskSizeGB: aksUserOsDiskSizeGB
aroDevopsMsiId: aroDevopsMsiId
}
}

Expand Down
2 changes: 1 addition & 1 deletion dev-infrastructure/templates/svc-cluster.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ module svcCluster '../modules/aks-cluster-base.bicep' = {
})
aksKeyVaultName: aksKeyVaultName
acrPullResourceGroups: acrPullResourceGroups
aroDevopsMsiId: aroDevopsMsiId
}
}

Expand Down Expand Up @@ -313,7 +314,6 @@ module cs '../modules/cluster-service.bicep' = {
}
dependsOn: [
maestroServer
svcCluster
geoberle marked this conversation as resolved.
Show resolved Hide resolved
]
}

Expand Down
Loading