DescribePolicyGovernanceInCluster - 获取集群策略治理详情

ACK集群容器安全策略供了种类丰富的内置规则库,包括Compliance、Infra、K8s-generalPSP,旨在确保容器在生产环境中的安全运行。您可以调用DescribePolicyGovernanceInCluster接口,查询目标集群策略治理的详细信息,例如集群当前启用的不同等级策略计数统计、策略治理审计日志、拦截和告警情况等。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用前面加 * 表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
cs:DescribePolicyGovernanceInClusterget
*Cluster
acs:cs:{#regionId}:{#accountId}:cluster/{#ClusterId}

请求语法

GET /clusters/{cluster_id}/policygovernance HTTP/1.1

请求参数

名称类型必填描述示例值
cluster_idstring

目标集群 ID

c8155823d057948c69a****

返回参数

名称类型描述示例值
object

Schema of Response

on_statearray<object>

当前集群中开启的不同等级策略计数统计。

on_stateobject
enabled_countinteger

当前开启的策略种类计数。

3
totalinteger

该等级下策略种类总数。

8
severitystring

策略治理等级。

high
admit_logobject

集群当前策略治理审计日志。

progressstring

查询结果的状态,取值:

  • Complete:查询已经完成,返回结果为完整结果。
  • Incomplete:查询已经完成,返回结果为不完整结果,需要重复请求以获得完整结果。
Complete
countlong

当前查询到的日志总数。

100
logsarray<object>

违反策略的日志信息。

logsobject
cluster_idstring

集群 ID。

hash code
constraint_actionstring

策略作用动作,包括告警(warn)和拦截(deny)

  • warn: 仅对违反策略的行为进行告警,但是不会实际拦截请求。
  • deny:拦截违反策略的请求。
deny
constraint_api_versionstring

策略的 API 版本。

v1beta1
constraint_categorystring

策略类型。

cis-k8s
constraint_groupstring

策略的 API 组。

constraints.gatekeeper.sh
constraint_kindstring

对应策略管理中的策略名称。

ACKNamespacesDeleteProtection
constraint_namestring

策略实例名称。

namespace-delete-protection-jpjwv
event_msgstring

策略作用的详细信息。

Admission webhook \"validation.gatekeeper.sh\" denied request, Resource Namespace: , Constraint: namespace-delete-protection-jpjwv, Message: not allow to delete protection namespace test.
event_typestring

策略触发事件的类型,例如 violation。

violation
request_uidstring

请求 ID。

hash code
request_userinfostring

违反策略的请求用户信息。

account id
request_usernamestring

违反策略的请求用户名称。

account user name
resource_kindstring

违反策略的资源类型,例如操作 Namespace 的请求被驳回,此项的内容为:Namespace。

Namespace
resource_namestring

违反策略的资源名称。

test
timestring

策略违反时间。

2025-10-27T11:31:40Z
log_projectstring

存储策略作用信息的日志项目。

k8s-log-clusterid
log_storestring

存储策略作用信息的日志仓库。

policyadmit-clusterid
Violationobject

按严重程度汇总的违反策略信息。

totalViolationsobject

汇总信息。

denyarray<object>

拦截记录汇总。

denyobject
severitystring

严重程度。包括:low,medium,high。

medium
violationsstring

违反次数。

2
warnarray<object>

告警记录汇总。

warnobject
severitystring

严重程度汇总。

high
violationslong

违反次数汇总。

0
violationsobject

按策略名称汇总的违反记录。

denyarray<object>

拦截记录汇总。

denyobject
policyDescriptionstring

策略描述。

Prevent specific namespaces from being deleted.
policyNamestring

策略名称。

ACKNamespacesDeleteProtection
severitystring

严重程度。

medium
violationslong

违反次数。

1
warnarray<object>

告警信息汇总。

warnobject
policyDescriptionstring

策略描述。

policyNamestring

策略名称。

severitystring

严重程度。

violationslong

违反次数。

示例

正常返回示例

JSON格式

{
  "on_state": [
    {
      "enabled_count": 3,
      "total": 8,
      "severity": "high"
    }
  ],
  "admit_log": {
    "progress": "Complete",
    "count": 100,
    "logs": [
      {
        "cluster_id": "hash code",
        "constraint_action": "deny",
        "constraint_api_version": "v1beta1",
        "constraint_category": "cis-k8s",
        "constraint_group": "constraints.gatekeeper.sh",
        "constraint_kind": "ACKNamespacesDeleteProtection",
        "constraint_name": "namespace-delete-protection-jpjwv",
        "event_msg": "Admission webhook \\\"validation.gatekeeper.sh\\\" denied request, Resource Namespace: , Constraint: namespace-delete-protection-jpjwv, Message: not allow to delete protection namespace test.",
        "event_type": "violation",
        "request_uid": "hash code",
        "request_userinfo": "account id",
        "request_username": "account user name\n",
        "resource_kind": "Namespace",
        "resource_name": "test",
        "time": "2025-10-27T11:31:40Z"
      }
    ],
    "log_project": "k8s-log-clusterid",
    "log_store": "policyadmit-clusterid"
  },
  "Violation": {
    "totalViolations": {
      "deny": [
        {
          "severity": "medium",
          "violations": 2
        }
      ],
      "warn": [
        {
          "severity": "high",
          "violations": 0
        }
      ]
    },
    "violations": {
      "deny": [
        {
          "policyDescription": "Prevent specific namespaces from being deleted.",
          "policyName": "ACKNamespacesDeleteProtection",
          "severity": "medium",
          "violations": 1
        }
      ],
      "warn": [
        {
          "policyDescription": "",
          "policyName": "",
          "severity": "",
          "violations": 0
        }
      ]
    }
  }
}

错误码

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
2025-10-30OpenAPI 返回结构发生变更查看变更详情