用途:通过 kubectl-mcp-server 的 Kyverno 与 Gatekeeper 工具管理 Kubernetes 策略,适用于执行策略、检查违规和策略审计。触发场景包括用户提到 Kyverno、Gatekeeper、OPA、policy、compliance,或涉及 require labels、block privileged、validate、enforce 等操作。
主要能力:Kyverno 侧提供安装检测、集群策略与命名空间策略的列表和详情查询、策略报告查询;Gatekeeper 侧提供安装检测、约束与约束模板的列表和详情查询。优先级规则建议先检测策略引擎,再在 Enforce 前使用 Audit 模式,并检查策略报告中的违规。
使用方式:先运行 kyverno_detect_tool() 或 gatekeeper_detect_tool() 检测安装;再用 kyverno_clusterpolicies_list_tool()、kyverno_clusterpolicy_get_tool(name)、kyverno_clusterpolicyreports_list_tool()、gatekeeper_constraints_list_tool()、gatekeeper_constraint_get_tool(kind, name)、gatekeeper_constrainttemplate_get_tool(name) 等工具查询。策略可通过 kubectl_apply(manifest=...) 应用,例如 Kyverno 的 require-labels、require-limits,或 Gatekeeper 的 ConstraintTemplate 与约束。
前置条件:Kyverno 需安装 kubectl create -f https://github.com/kyverno/kyverno/releases/latest/download/install.yaml;Gatekeeper 需安装 kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper/master/deploy/gatekeeper.yaml。
限制:资料未提供具体版本兼容性、权限要求、性能影响或错误处理细节,暂未提供。