|
本文档采用自动化机器翻译技术翻译。 尽管我们力求提供准确的译文,但不对翻译内容的完整性、准确性或可靠性作出任何保证。 若出现任何内容不一致情况,请以原始 英文 版本为准,且原始英文版本为权威文本。 |
|
这是尚未发布的文档。 Admission Controller 1.34-dev. |
Kubernetes 功能
SUSE Security Admission Controller 上下文感知策略需要访问它们运行的 Kubernetes 集群中的资源。 为此,Admission Controller SDK 暴露使用 waPC 通信协议与主机系统交谈的函数,以请求有关集群的数据。
waPC 协议合同
在内部,SDK 依赖于策略主机环境暴露的这些函数:
-
list_resources_by_namespace:给定资源类型和名称空间,列出在其中定义的该类型的所有资源。 这不能用于列出集群范围的资源,如Namespace。 -
list_resources_all:给定资源类型,列出在整个集群中定义的该类型的所有资源。 这可以用于列出集群范围的资源,如Namespace。 -
get_resource:找到由给定资源类型、给定名称和可选命名空间标识符标识的确切资源。
此访客-主机通信是使用标准的 waPC 主机调用机制执行的。 任何实现 waPC 互通信机制的访客都能够从主机请求此信息。
在从访客到主机进行调用时,waPC 具有以下函数参数:
-
绑定 -
kubewarden -
名称空间 -
kubernetes -
操作 -
list_resources_all、list_resources_by_namespace或get_resource -
有效负载 - 输入有效负载 - 见下文
并返回:
-
有效负载 - 输出有效负载 - 见下文
根据合同或约定,策略可以通过以下方式调用主机以检索 Kubernetes 集群信息:
操作 - list_resources_all
输入:
# API Group version. Use `+v1+` for the `+core+` group and
# `+groupName/groupVersion+` for all other groups
"api_version": string,
# Resource kind
"kind": string,
# Label selector to filter the resources
"label_selector": string,
# Field selector to filter the resources
"field_selector": string,
# Field masks: A list of fields to include in the response.
#
# If strictly defined, the host will prune the Kubernetes resource to contain *only*
# the specified fields, reducing memory usage and serialization overhead.
"field_masks": [string]
操作 - list_resources_by_namespace
输入:
{
# API Group version. Use `+v1+` for the `+core+` group and
# `+groupName/groupVersion+` for all other groups
"api_version": string,
# Resource kind
"kind": string,
# Namespace where the requested resource lives in
"namespace": string,
# Label selector to filter the resources
"label_selector": string,
# Field selector to filter the resources
"field_selector": string,
# Field masks: A list of fields to include in the response.
#
# If strictly defined, the host will prune the Kubernetes resource to contain *only*
# the specified fields, reducing memory usage and serialization overhead.
"field_masks": [string]
}
输出
返回一个Kubernetes List,这是同一类型Kubernetes对象的集合。
|
当用于获取集群范围的资源(例如,名称空间)时,此API函数会返回错误。 处理集群范围资源时使用`list_resources_all`。 |
操作 - get_resource
输入:
{
# API Group version. Use `+v1+` for the `+core+` group
# and `+groupName/groupVersion+` for all other groups
"api_version": string,
# Singular PascalCase name of the resource
"kind": string,
# Namespace scoping the search
"namespace": string,
# The name of the resource
"name": string,
# Disable caching of results obtained from Kubernetes API Server
"disable_cache": bool,
# Field masks: A list of fields to include in the response.
#
# If strictly defined, the host will prune the Kubernetes resource to contain *only*
# the specified fields, reducing memory usage and serialization overhead.
"field_masks": [string]
}