获取策略定义 - ShowPolicyDefinition
功能介绍
获取策略定义
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限,具体权限要求请参见权限和授权项。
URI
GET /v1/policydefinitions/{policydefinitionid}
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| policydefinitionid | 是 | String | 策略定义id |
请求参数
无
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| kind | String | API类型,固定值“ConstraintTemplate” |
| apiVersion | String | API版本 |
| metadata | ObjectMeta object | 约束模板元数据 |
| spec | Object | 约束模板的详细属性 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| uid | String | 资源ID |
| name | String | 资源名称 |
| generateName | String | 当未提供name时,服务器使用的前缀来生成唯一名称 |
| namespace | String | 命名空间 |
| labels | Map<String,String> | 标签 |
| annotations | Map<String,String> | 注解 |
| creationTimestamp | String | 创建时间 |
| updateTimestamp | String | 更新时间 |
| resourceVersion | String | 资源内部版本 |
| generation | Integer | 资源期望状态的代数 |
| managedFields | Array of ManagedFieldsEntry objects | 记录哪些字段由哪些工作流管理 |
| ownerReferences | Array of OwnerReference objects | 用于定义对象间所有权关系,管理对象的依赖关系和垃圾回收机制,支持控制器对资源的管理 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| manager | String | 管理者的名称 |
| operation | String | 记录导致此条目创建的操作类型,只能是 Apply 或 Update 两种操作类型 |
| apiVersion | String | 该管理者定义字段时所依据的资源 API 版本 |
| time | String | 此管理条目被创建或最后一次更新的时间戳 |
| fieldsType | String | 固定为 "FieldsV1",标记字段结构格式 |
| fieldsV1 | Object | 用于存储实际被管理的字段信息 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| apiVersion | String | 标识引用对象的API版本 |
| kind | String | 引用对象的类型 |
| name | String | 引用对象的名称 |
| uid | String | 引用对象的uid |
| controller | Boolean | 如果为true,表示该引用指向管理该资源的控制器 |
| blockOwnerDeletion | Boolean | 当为true且拥有者有名为"foregroundDeletion"的finalizer 时,会阻止拥有者被删除,直到这个引用被移除 |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| - | String | - |
状态码:404
| 参数 | 参数类型 | 描述 |
|---|---|---|
| - | String | - |
状态码:500
| 参数 | 参数类型 | 描述 |
|---|---|---|
| - | String | - |
请求示例
无
响应示例
状态码:200
策略定义详细信息
{
"kind" : "ConstraintTemplate",
"apiVersion" : "templates.gatekeeper.sh/v1beta1",
"metadata" : {
"name" : "k8spspvolumetypes",
"uid" : "f1519ae2-adf8-11ed-9f9c-0255ac100186",
"creationTimestamp" : "2023-02-16 12:53:43.050938 +0000 UTC",
"updateTimestamp" : "2025-11-05 03:29:41.797896 +0000 UTC",
"annotations" : {
"description-chinese" : "限制Pod使用指定的Volume挂载类型",
"name-chinese" : "K8sPSPVolumeTypes",
"tag-chinese" : "容器/应用安全策略"
}
},
"spec" : {
"type" : "security",
"tag" : "k1",
"officialTag" : "Container/ApplicationSecurityPolicies",
"level" : "3",
"targetKind" : "Pod",
"official" : true,
"description" : "Restricts mountable volume types to those specified by the user. Corresponds to the `volumes` field in a PodSecurityPolicy.",
"constraintTemplate" : {
"kind" : "ConstraintTemplate",
"apiVersion" : "templates.gatekeeper.sh/v1",
"metadata" : {
"name" : "k8spspvolumetypes",
"creationTimestamp" : null,
"annotations" : {
"description" : "Restricts mountable volume types to those specified by the user. Corresponds to the `volumes` field in a PodSecurityPolicy.",
"description-chinese" : "限制Pod使用指定的Volume挂载类型",
"level" : "3",
"metadata.gatekeeper.sh/title" : "Volume Types",
"metadata.gatekeeper.sh/version" : "1.0.0",
"name-chinese" : "K8sPSPVolumeTypes",
"tag" : "Container/ApplicationSecurityPolicies",
"tag-chinese" : "容器/应用安全策略",
"targetKind" : "Pod",
"type" : "security"
}
}
}
}
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | 策略定义详细信息 |
| 400 | 客户端请求错误,服务器无法执行请求 |
| 404 | 资源不存在 |
| 500 | 服务器内部错误 |
错误码
请参见错误码。