ACK集群容器安全策略供了种类丰富的内置规则库,包括Compliance、Infra、K8s-general和PSP,旨在确保容器在生产环境中的安全运行。您可以调用DescribePolicyGovernanceInCluster接口,查询目标集群策略治理的详细信息,例如集群当前启用的不同等级策略计数统计、策略治理审计日志、拦截和告警情况等。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
cs:DescribePolicyGovernanceInCluster |
get |
*Cluster
|
无 | 无 |
请求语法
GET /clusters/{cluster_id}/policygovernance HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| cluster_id |
string |
是 |
目标集群 ID |
c8155823d057948c69a**** |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
当前API无需请求参数
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| on_state |
array<object> |
当前集群中开启的不同等级策略计数统计。 |
|
|
object |
|||
| enabled_count |
integer |
当前开启的策略种类计数。 |
3 |
| total |
integer |
该等级下策略种类总数。 |
8 |
| severity |
string |
策略治理等级。 |
high |
| admit_log |
object |
集群当前策略治理审计日志。 |
|
| progress |
string |
查询结果的状态,取值:
|
Complete |
| count |
integer |
当前查询到的日志总数。 |
100 |
| logs |
array<object> |
违反策略的日志信息。 |
|
|
object |
|||
| cluster_id |
string |
集群 ID。 |
hash code |
| constraint_action |
string |
策略作用动作,包括告警(warn)和拦截(deny)
|
deny |
| constraint_api_version |
string |
策略的 API 版本。 |
v1beta1 |
| constraint_category |
string |
策略类型。 |
cis-k8s |
| constraint_group |
string |
策略的 API 组。 |
constraints.gatekeeper.sh |
| constraint_kind |
string |
对应策略管理中的策略名称。 |
ACKNamespacesDeleteProtection |
| constraint_name |
string |
策略实例名称。 |
namespace-delete-protection-jpjwv |
| event_msg |
string |
策略作用的详细信息。 |
Admission webhook \"validation.gatekeeper.sh\" denied request, Resource Namespace: , Constraint: namespace-delete-protection-jpjwv, Message: not allow to delete protection namespace test. |
| event_type |
string |
策略触发事件的类型,例如 violation。 |
violation |
| request_uid |
string |
请求 ID。 |
hash code |
| request_userinfo |
string |
违反策略的请求用户信息。 |
account id |
| request_username |
string |
违反策略的请求用户名称。 |
account user name |
| resource_kind |
string |
违反策略的资源类型,例如操作 Namespace 的请求被驳回,此项的内容为:Namespace。 |
Namespace |
| resource_name |
string |
违反策略的资源名称。 |
test |
| time |
string |
策略违反时间。 |
2025-10-27T11:31:40Z |
| log_project |
string |
存储策略作用信息的日志项目。 |
k8s-log-clusterid |
| log_store |
string |
存储策略作用信息的日志仓库。 |
policyadmit-clusterid |
| Violation |
object |
按严重程度汇总的违反策略信息。 |
|
| totalViolations |
object |
汇总信息。 |
|
| deny |
array<object> |
拦截记录汇总。 |
|
|
object |
|||
| severity |
string |
严重程度。包括:low,medium,high。 |
medium |
| violations |
string |
违反次数。 |
2 |
| warn |
array<object> |
告警记录汇总。 |
|
|
object |
|||
| severity |
string |
严重程度汇总。 |
high |
| violations |
integer |
违反次数汇总。 |
0 |
| violations |
object |
按策略名称汇总的违反记录。 |
|
| deny |
array<object> |
拦截记录汇总。 |
|
|
object |
|||
| policyDescription |
string |
策略描述。 |
Prevent specific namespaces from being deleted. |
| policyName |
string |
策略名称。 |
ACKNamespacesDeleteProtection |
| severity |
string |
严重程度。 |
medium |
| violations |
integer |
违反次数。 |
1 |
| warn |
array<object> |
告警信息汇总。 |
|
|
object |
|||
| policyDescription |
string |
策略描述。 |
|
| policyName |
string |
策略名称。 |
|
| severity |
string |
严重程度。 |
|
| violations |
integer |
违反次数。 |
示例
正常返回示例
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
}
]
}
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。