As políticas de segurança de contêineres para clusters ACK fornecem um conjunto rico de bibliotecas de regras integradas, incluindo `Compliance`, `Infra`, `K8s-general` e `PSP`, para proteger contêineres em um ambiente de produção. Chame a API `DescribePolicyGovernanceInCluster` para obter detalhes de governança de políticas de um cluster de destino, como estatísticas de políticas por severidade, logs de auditoria e eventos de interceptação e alerta.
Experimente agora
Testar
Autorização RAM
|
Ação |
Nível de acesso |
Tipo de recurso |
Chave de condição |
Ação dependente |
|
cs:DescribePolicyGovernanceInCluster |
get |
*Cluster
|
Nenhuma | Nenhuma |
Sintaxe da solicitação
GET /clusters/{cluster_id}/policygovernance HTTP/1.1
Parâmetros de caminho
|
Parâmetro |
Tipo |
Obrigatório |
Descrição |
Exemplo |
| cluster_id |
string |
Sim |
O ID do cluster. |
c8155823d057948c69a**** |
Parâmetros da solicitação
|
Parâmetro |
Tipo |
Obrigatório |
Descrição |
Exemplo |
Nenhum parâmetro necessário.
Elementos de resposta
|
Elemento |
Tipo |
Descrição |
Exemplo |
|
object |
O esquema de resposta. |
||
| on_state |
array<object> |
As estatísticas de políticas habilitadas no cluster, categorizadas por severidade. |
|
|
object |
|||
| enabled_count |
integer |
O número de tipos de políticas habilitados. |
3 |
| total |
integer |
O número total de tipos de políticas para esta severidade. |
8 |
| severity |
string |
O nível de severidade da política. |
high |
| admit_log |
object |
O log de auditoria para governança de políticas no cluster. |
|
| progress |
string |
O status da consulta. Valores válidos:
|
Complete |
| count |
integer |
O número total de logs retornados pela consulta atual. |
100 |
| logs |
array<object> |
As entradas de log para violações de políticas. |
|
|
object |
|||
| cluster_id |
string |
The cluster ID. |
hash code |
| constraint_action |
string |
The action taken by the policy, including alert (warn) and block (deny). Valid values:
|
deny |
| constraint_api_version |
string |
The API version of the policy. |
v1beta1 |
| constraint_category |
string |
The policy type. |
cis-k8s |
| constraint_group |
string |
The API group of the policy. |
constraints.gatekeeper.sh |
| constraint_kind |
string |
The policy name in policy management. |
ACKNamespacesDeleteProtection |
| constraint_name |
string |
The policy instance name. |
namespace-delete-protection-jpjwv |
| event_msg |
string |
The detailed information about the policy action. |
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 |
The type of event triggered by the policy, such as violation. |
violation |
| request_uid |
string |
The request ID. |
hash code |
| request_userinfo |
string |
The information about the user whose request violated the policy. |
account id |
| request_username |
string |
The name of the user whose request violated the policy. |
account user name |
| resource_kind |
string |
The type of resource that violated the policy. For example, if a request to operate on a Namespace is rejected, this field is set to Namespace. |
Namespace |
| resource_name |
string |
The name of the resource that violated the policy. |
test |
| time |
string |
The time when the policy violation occurred. |
2025-10-27T11:31:40Z |
| log_project |
string |
O projeto de log que armazena informações de aplicação de políticas. |
k8s-log-clusterid |
| log_store |
string |
O log store que armazena informações de aplicação de políticas. |
policyadmit-clusterid |
| Violation |
object |
Um resumo das violações de políticas, agrupadas por severidade. |
|
| totalViolations |
object |
Um resumo de todas as violações de políticas. |
|
| deny |
array<object> |
The summary of block records. |
|
|
object |
|||
| severity |
string |
The severity level. Valid values: low, medium, and high. |
medium |
| violations |
string |
The number of violations. |
2 |
| warn |
array<object> |
The summary of alert records. |
|
|
object |
|||
| severity |
string |
The summary of severity levels. |
high |
| violations |
integer |
The total number of violations. |
0 |
| violations |
object |
Um resumo das violações, agrupadas por nome de política. |
|
| deny |
array<object> |
The summary of block records. |
|
|
object |
|||
| policyDescription |
string |
The policy description. |
Prevent specific namespaces from being deleted. |
| policyName |
string |
The policy name. |
ACKNamespacesDeleteProtection |
| severity |
string |
The severity level. |
medium |
| violations |
integer |
The number of violations. |
1 |
| warn |
array<object> |
The summary of alert information. |
|
|
object |
|||
| policyDescription |
string |
The policy description. |
|
| policyName |
string |
The policy name. |
|
| severity |
string |
The severity level. |
|
| violations |
integer |
The number of violations. |
Exemplos
Resposta de sucesso
JSON formato
{
"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
}
]
}
}
}
Códigos de erro
Consulte Códigos de Erro para uma lista completa.
Notas de versão
Consulte Notas de Versão para uma lista completa.