The authorization system of Container Compute Service (ACS) includes Resource Access Management (RAM) authorization for underlying compute resources and Role-Based Access Control (RBAC) authorization for ACS-type Container Service for Kubernetes (ACK) clusters. Different user roles require different permissions at both layers. This topic describes authorization best practices for enterprise resource managers, Kubernetes cluster administrators, cluster and application O&M engineers, application developers, and permission administrators.
ACS yetkilendirme sistemi
İki katmanın birlikte çalışma şekli
ACS kümeleri, bir tür Serverless Container Service for Kubernetes (ACK) kümesidir. Tüm küme yönetimi çağrıları ACK API'lerini kullandığından hem cloud düzeyinde (RAM) hem de küme düzeyinde (RBAC) izinlerin yapılandırılması gerekir.
| Katman | Kapsam | Kontrol Eder | Şu Yolla Verilir |
|---|---|---|---|
| RAM yetkilendirmesi | Cloud kaynakları (kontrol düzlemi) | Küme yaşam döngüsü, RBAC yönetimi, izleme, günlükler ve olaylar | RAM sistem ilkeleri veya özel ilkeler |
| RBAC yetkilendirmesi | Kubernetes kaynakları (veri düzlemi) | İş yükleri, ağ, depolama, ad alanları, ConfigMap'ler ve Secret'lar | ACS konsolunda önceden tanımlanmış veya özel ClusterRole'ler |
RBAC izinlerini vermeden önce eksiksiz RAM yetkilendirmesi yapın.
RAM yetkilendirmesinin kapsadığı alanlar
RAM yetkilendirmesi, küme işletim ve bakım işlemleri için izinler verir:
Kümeleri oluşturma, görüntüleme ve silme
RBAC yetkilendirmesini yönetme
Kümeleri izleme ve günlükleri ile olayları yönetme
RBAC yetkilendirmesinin kapsadığı alanlar
RBAC yetkilendirmesi, Kubernetes kaynakları üzerinde ad alanı düzeyinde veya küme genelinde izinler verir:
İş yükü kaynakları: Deployment, StatefulSet, Job, CronJob, pod, ReplicaSet ve HorizontalPodAutoscaler (HPA)
Ağ kaynakları: Service, Ingress ve NetworkPolicy
Depolama kaynakları: kalıcı birim (PV), kalıcı birim talebi (PVC) ve StorageClass
Diğer kaynaklar: Namespace, ConfigMap ve Secret
Varsayılan sistem ilkeleri
ACS aşağıdaki varsayılan sistem ilkelerini sağlar. İzinleri hızlıca vermek için bu ilkeleri RAM kullanıcılarına veya RAM rollerine ekleyebilirsiniz.
Varsayılan sistem ilkeleri geniş izinler verir; bu izinler ACK ve ACS'nin tüm OpenAPI işlemleri için okuma veya yazma erişimini içerebilir. Bu ilkeleri dikkatli bir şekilde verin.
Varsayılan sistem ilkesi | Açıklama |
AliyunAccFullAccess | ACS'yi yönetme izinleri. |
AliyunAccReadOnlyAccess | ACS üzerinde salt okunur izinler. |
AliyunCSFullAccess | ACK'yi yönetme izinleri. Önemli ACS tipi kümeler dahil olmak üzere tüm ACK kümeleri üzerinde okuma ve yazma izinleri verir. Bu izinleri dikkatli bir şekilde verin. |
AliyunCSReadOnlyAccess | ACK üzerinde salt okunur izinler. Önemli ACS tipi kümeler dahil olmak üzere tüm ACK kümeleri üzerinde okuma izinleri verir. Bu izinleri dikkatli bir şekilde verin. |
AliyunAccFullAccess ilkesi
{
"Statement": [
{
"Effect": "Allow",
"Action": "acc:*",
"Resource": "*"
}
],
"Version": "1"
}
AliyunAccReadOnlyAccess ilkesi
{
"Version": "1",
"Statement": [
{
"Action": [
"acc:Describe*",
"acc:CheckServiceRole"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
AliyunCSFullAccess ilkesi
{
"Version": "1",
"Statement": [
{
"Action": "cs:*",
"Resource": "*",
"Effect": "Allow"
},
{
"Action": "ram:PassRole",
"Resource": "*",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"acs:Service": "cs.aliyuncs.com"
}
}
}
]
}
AliyunCSReadOnlyAccess ilkesi
{
"Version": "1",
"Statement": [
{
"Action": [
"cs:CheckServiceRole",
"cs:Get*",
"cs:List*",
"cs:Describe*"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Yetkilendirme en iyi uygulamaları
Bir RAM kullanıcısının veya RAM rolünün küme ve uygulama işletim ve bakımı için izinlere ihtiyacı varsa hem RAM hem de RBAC izinleri vermeniz gerekir. Önce RAM izinlerini, ardından RBAC izinlerini verin. Aşağıdaki bölümlerde üç yaygın senaryo için yetkilendirme prosedürleri açıklanmaktadır:
Kullanıcı kümeler ve uygulamalar için bir işletim ve bakım mühendisiyse bkz. Senaryo 1: Kümeler ve uygulamalar için işletim ve bakım mühendisi.
Kullanıcı küme içi uygulamalar için bir geliştiriciyse bkz. Senaryo 2: Küme içi uygulamalar için geliştirici.
Kullanıcı küme içi uygulamalar için bir izin yöneticisiyse bkz. Senaryo 3: Küme içi uygulamalar için izin yöneticisi.
Senaryo 1: Kümeler ve uygulamalar için işletim ve bakım mühendisi
Bu senaryo, ACS kümelerini ve bunların içindeki uygulamaları yöneten ve bakımını yapan kullanıcılar içindir. Yetkilendirme süreci hem RAM hem de RBAC izinlerinin verilmesini içerir.
-
RAM yetkilendirmesi
ACK, RAM için iki sistem ilkesi sağlar: AliyunCSFullAccess ve AliyunCSReadOnlyAccess.
AliyunCSFullAccess, ACK'nin tüm OpenAPI işlemleri için okuma ve yazma izinleri verir.
-
AliyunCSReadOnlyAccess, ACK'nin tüm OpenAPI işlemleri için salt okunur izinler verir.
ÖnemliBu iki sistem ilkesi, ACS tipi kümeler dahil olmak üzere tüm ACK kümeleri üzerinde izinler verir. Bu izinleri dikkatli bir şekilde verin.
Log on to the RAM console and attach one of the system policies as needed. For more information, see Manage permissions for a RAM user and Manage permissions for a RAM role.
If you require fine-grained access control, you can create a custom policy. For more information, see Grant RAM permissions to a RAM user or RAM role.
The following code is a sample RAM authorization policy for this scenario.
{ "Statement": [ { "Effect": "Allow", "Action": [ "acc:DescribeCommodityStatus", "acc:CheckServiceRole", "acc:DescribeCloudProducts", "acc:DescribeRegions", "acc:DescribeZones", "acc:GetInstancePrice", "acc:RecommendZones", "acc:DescribeGpuModelSeries" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "bssapi:GetPayAsYouGoPrice", "bssapi:QueryAccountBalance" ], "Resource": "*" }, { "Action": [ "ecs:DescribePrice", "ecs:DescribeAccountAttributes" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "ram:GetRole", "ram:CreateRole" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "cs:CreateCluster", "cs:DescribeAddons", "cs:DescribeUserQuota", "cs:DescribeTasks", "cs:ListClusterAddonInstances" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "cs:GetClusters", "cs:DescribeClustersV1", "cs:DescribeClusterUserKubeconfig", "cs:DescribeClusterResources", "cs:DescribeUserQuota", "cs:DescribeClusterLogs", "cs:ModifyCluster", "cs:UpgradeCluster", "cs:GetUpgradeStatus", "cs:ResumeUpgradeCluster", "cs:PauseClusterUpgrade", "cs:CancelClusterUpgrade", "cs:InstallClusterAddons", "cs:UpgradeClusterAddons", "cs:DescribeClusterAddonsUpgradeStatus", "cs:UnInstallClusterAddons", "cs:DeleteCluster", "cs:DescribeClusterDetail", "cs:GetClusterAuditProject", "cs:DescribeClusterAddonsVersion", "cs:DescribeClusterTasks", "cs:DescribeClusterEvents", "cs:DescribeEvents", "cs:ListClusterReportSummary", "cs:GetClusterBasicInfo", "cs:ListReportTaskRule", "cs:CreateReportTaskRule", "cs:CheckControlPlaneLogEnable", "cs:CreateClusterCheck" ], "Effect": "Allow", "Resource": "acs:cs:*:*:cluster/<yourclusterID>" }, { "Action": [ "cs:CheckServiceRole", "cs:DescribeKubernetesVersionMetadata" ], "Effect": "Allow", "Resource": "acs:cs:*:*:cluster/*" }, { "Action": [ "log:ListProject", "log:DescribeService", "log:GetSlsService" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "vpc:ListEnhanhcedNatGatewayAvailableZones", "vpc:DescribeEipAddresses", "vpc:DescribeVSwitches", "vpc:DescribeVpcs" ], "Effect": "Allow", "Resource": "*" } ], "Version": "1" }In the example above, replace
<yourclusterID>with the actual ACS cluster ID. For more information about the ACK OpenAPI, see [[Product Change] Notice on ACK OpenAPI Authentication Optimization](t2103012.dita#task_2103012) and API overview.
-
RBAC yetkilendirmesi
RAM izinlerini verdikten sonra RAM kullanıcısına veya RAM rolüne küme için RBAC izinleri de vermeniz gerekir. ACK, küme düzeyinde dört önceden tanımlanmış rol sağlar.
Rol
Küme içi RBAC izinleri
Administrator
Tüm ad alanlarında tüm kaynaklar üzerinde okuma ve yazma izinleri.
O&M Engineer
Tüm ad alanlarında konsolda görünen Kubernetes kaynakları üzerinde okuma ve yazma izinleri; küme düğümleri, kalıcı birimler (PV'ler), ad alanları ve kotalar üzerinde salt okunur izinler.
Developer
Tüm veya seçili ad alanlarında konsolda görünen Kubernetes kaynakları üzerinde okuma ve yazma izinleri.
Restricted User
Tüm veya seçili ad alanlarında konsolda görünen Kubernetes kaynakları üzerinde salt okunur izinler.In the Container Compute Service console, click Authorizations in the left-side navigation pane. On the RAM Users or RAM Roles tab, find the target identity and click Modify Permissions.
In the dialog box that appears, click +Add Permissions. Set the permission for the target cluster and its namespaces to O&M Engineer, and then click Submit.
Önceden tanımlanmış rolü atadıktan sonra ACS, yetkili kullanıcının veya rolün kimliğine karşılık gelen bir ClusterRoleBinding örneğini kümede otomatik olarak oluşturur. Aşağıdaki kod, önceden tanımlanmış O&M Engineer rolü için RBAC izinlerini göstermektedir.
If you require fine-grained RBAC permissions, you can create a custom ClusterRole instance by referring to the official Kubernetes RBAC documentation. Then, on the Authorizations page of the Container Compute Service console, select Custom and select the name of the custom ClusterRole from the drop-down list. For more information, see Create a custom RBAC authorization policy.
Senaryo 2: Küme içi uygulamalar için geliştirici
Bu senaryo, yalnızca bir ACS kümesindeki Kubernetes kaynaklarını yöneten (RBAC yetkilendirmesi kullanarak) ve diğer cloud kaynaklarına erişim gerektirmeyen kullanıcılar için geçerlidir.
Before you grant RBAC permissions, the user or role must have, at a minimum, read-only RAM permissions for the target cluster. Setting the Resource to * grants the specified Action permissions on all ACK clusters. Do not use a wildcard (*) for the resource unless you fully understand the scope and impact.
-
RAM yetkilendirmesi
You need to create a custom policy in the RAM console and attach the policy to the target RAM user or RAM role. For more information, see Grant RAM permissions to a RAM user or RAM role. The custom policy is as follows:
{ "Statement": [ { "Effect": "Allow", "Action": [ "acc:DescribeCommodityStatus", "acc:CheckServiceRole", "acc:DescribeCloudProducts", "acc:DescribeRegions", "acc:DescribeZones", "acc:GetInstancePrice", "acc:RecommendZones" ], "Resource": "*" }, { "Effect": "Allow", "Action": "bssapi:GetPayAsYouGoPrice", "Resource": "*" }, { "Action": [ "cs:Get*", "cs:List*", "cs:Check*", "cs:Describe*" ], "Effect": "Allow", "Resource": [ "acs:cs:*:*:cluster/<yourclusterID>" ] }, { "Action": [ "vpc:ListEnhanhcedNatGatewayAvailableZones", "vpc:DescribeEipAddresses" ], "Effect": "Allow", "Resource": "*" } ], "Version": "1" }In the example above, replace
<yourclusterID>with your actual ACS cluster ID.NotIf you only need to grant a user read-only permissions on a specific ACS cluster, use this sample policy and specify the cluster's ARN. Do not assign the
AliyunCSReadOnlyAccesssystem policy. This policy grants read-only permissions on all ACK clusters and is too permissive for this use case. -
RBAC yetkilendirmesi
In the Container Compute Service console, click Authorizations in the left-side navigation pane. On the RAM Users or RAM Roles tab, find the target identity and click Modify Permissions.
In the dialog box that appears, click +Add Permissions. Set the permission for the target cluster and its namespaces to Developer, and then click Submit.
Önceden tanımlanmış rolü atadıktan sonra ACS, yetkili kullanıcının veya rolün kimliğine karşılık gelen bir ClusterRoleBinding örneğini kümede otomatik olarak oluşturur. Aşağıdaki örnek kod, önceden tanımlanmış Developer rolü için RBAC izinlerini sağlar.
Senaryo 3: Küme içi uygulamalar için izin yöneticisi
The authorizing user or role is required to manage the RBAC permissions of other RAM users or RAM roles. By default, a RAM user or RAM role does not have the permission to grant RBAC permissions to other RAM users or RAM roles. When the authorizing user or role accesses the authorization management page in the Container Service console, if the UI displays the message The current RAM user does not have authorization management permissions. Please contact the Alibaba Cloud account or a permission administrator for authorization., this indicates that the authorizing user or role lacks the necessary RAM authorization or the RBAC administrator authorization for the cluster.
-
RAM yetkilendirmesi
Kullanıcının veya rolün gerekli RAM izinlerine sahip olduğundan emin olun. İlke şu izinleri içermelidir:
Diğer RAM kullanıcılarını veya RAM rollerini listeleme.
Belirtilen RAM kullanıcılarına veya RAM rollerine RAM ilkeleri atama.
Belirtilen RAM kullanıcılarının veya RAM rollerinin Kubernetes RBAC izin yapılandırmalarını görüntüleme.
Kubernetes RBAC yetkilendirmesi gerçekleştirme.
In the RAM console, grant the corresponding RAM permissions to the specified RAM user or RAM role. For more information, see Grant RAM permissions to a RAM user or RAM role. The following sample code provides a custom RAM policy.
{ "Statement": [ { "Effect": "Allow", "Action": [ "acc:DescribeCommodityStatus", "acc:CheckServiceRole", "acc:DescribeCloudProducts", "acc:DescribeRegions", "acc:DescribeZones", "acc:GetInstancePrice", "acc:RecommendZones" ], "Resource": "*" }, { "Effect": "Allow", "Action": "bssapi:GetPayAsYouGoPrice", "Resource": "*" }, { "Action": [ "ram:Get*", "ram:List*", "cs:GetUserPermissions", "cs:GetSubUsers", "cs:GrantPermission", "cs:CheckServiceRole" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "ram:AttachPolicyToUser", "ram:AttachPolicyToRole" ], "Effect": "Allow", "Resource": [ "acs:ram:*:*:policy/xxxx", "acs:*:*:*:user/*" ] }, { "Action": [ "vpc:ListEnhanhcedNatGatewayAvailableZones", "vpc:DescribeEipAddresses" ], "Effect": "Allow", "Resource": "*" } ], "Version": "1" } -
RBAC yetkilendirmesi
In the Container Compute Service console, click Authorizations in the left-side navigation pane. On the RAM Users or RAM Roles tab, find the target identity and click Modify Permissions.
-
In the dialog box that appears, click +Add Permissions. Set the permission for the target cluster and its namespaces to Administrator or the cluster-admin custom role, and then click Submit.
NotAn Alibaba Cloud account and the cluster creator are bound to the cluster-admin role by default and have access to all Kubernetes resource objects in the cluster.
After you complete the RAM and RBAC authorization for a target, the target can manage RBAC authorization for other RAM users or RAM roles within a specified permission scope. For more information, see Grant RAM permissions to a RAM user or RAM role.
Yetkilendirme eylemleri
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For a description of the authorization Actions for ACK, see Authorization information.
Before writing authorization rules, ensure you understand the authorization Actions for ACK and follow the principle of least privilege. For more information, see Authorization information.
If you do not specify a target cluster ID and instead set the resource scope to a wildcard (*), permissions are granted to all ACK clusters, which may be broader than intended. Grant these permissions with caution.