首页 > 解决方案 > CI/CD 尝试从 Jenkins 部署到 AKS 失败

问题描述

我使用以下工具获得了用于 CI/CD 的 Microsoft 模板之一Jenkins、Docker (ACS)、Kubernetes (AKS)。此模板附带一个管道示例,但在尝试启动它时,尝试与 Azure Kubernetes (AKS) 集成时出现以下错误:

Starting Azure Container Service / Kubernetes Service Deployment
Delete Kubernetes management config file 
/var/lib/jenkins/workspace/hello-world/kubeconfig-7112538207763465492
ERROR: ERROR: Status code 403, {"error": 
{"code":"AuthorizationFailed","message":"The client '7912b768-a178-4996- 
b6e6-38912a9b90da' with object id '7912b768-a178-4996-b6e6-38912a9b90da' 
does not have authorization to perform action 
'Microsoft.ContainerService/managedClusters/accessProfiles
/listCredential/action' over scope '/subscriptions/4e601d44-4d18-4e49- 
95001793e668f9e0/resourcegroups/SystemBackend_Resource/
providers/Microsoft.ContainerService/managedClusters/aksa5ru5sgbdaum2/
accessProfiles/clusterAdmin'."}}

任何想法?

标签: azurejenkinskubernetescontinuous-integrationcontinuous-deployment

解决方案


该错误说明了一切,您用于访问 AKS 群集的客户端(凭据)无权在该群集上使用 listCredentials 操作。您需要授予该客户端这些权限。7912b768-a178-4996-b6e6-38912a9b90daSystemBackend_Resource资源组授予贡献者权限的最简单方法。

New-AzureRmRoleAssignment -ObjectId 7912b768-a178-4996-b6e6-38912a9b90da `
  -RoleDefinitionName "Contributor" `
  -Scope '/subscriptions/4e601d44-4d18-4e49-95001793e668f9e0/resourcegroups/SystemBackend_Resource/'

您显然可以使用自定义角色仅向该实体授予该权限,但这只是一个示例


推荐阅读