K8s Kyverno Troubleshooting 标志

K8s Kyverno Troubleshooting

组织
k8s-servant
k8s-kyverno-troubleshooting

当 Kyverno 在 Kubernetes 中阻止资源、修改资源或无法执行策略检查时使用:“admission webhook \"validate.kyverno.svc-fail\" denied the request”;“resource ... was blocked due to the following policies”;ValidatingPolicy 返回“Policy ... failed”;本应阻止请求的策略却只报告问题(Audit);PolicyReports 中存在失败项;策略未处于 Ready 状态;mutate 或 generate 规则不起作用;UpdateRequests 卡住;或 Kyverno Pod 宕机时出现“failed calling webhook”。涵盖 ClusterPolicy 和 Policy(kyverno.io),以及 CEL 策略(policies.kyverno.io)。通过 kubectl get、describe、events 和日志进行排查,并提出修复建议。先读取信息,未经询问不会进行任何更改。

Add to TypingMind

概览

发布者k8s-servant
代码仓库k8s-skills
技能名称k8s-kyverno-troubleshooting
星标数
36
复刻数
7
附带文件
3
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 3 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 k8s-servant 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 K8s Kyverno Troubleshooting AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/k8s-servant/k8s-skills/tree/main/skills/k8s-kyverno-troubleshooting
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/k8s-servant/k8s-skills.git /tmp/k8s-skills
mkdir -p .claude/skills
cp -r /tmp/k8s-skills/skills/k8s-kyverno-troubleshooting .claude/skills/k8s-kyverno-troubleshooting
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 K8s Kyverno Troubleshooting,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 K8s Kyverno Troubleshooting。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 K8s Kyverno Troubleshooting 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Kyverno troubleshooting

Find out why Kyverno denies, changes or does not police a resource, and propose a fix. Read first, ask before changing. Run the investigation commands freely. Run a command under an "Ask first" line only after the user approves that exact command; if your credentials do not allow it, give it to the user to run. Never run a "Proposed fix"; hand it to the user.

Kyverno runs as admission webhooks plus background controllers. Two policy families exist side by side:

  • ClusterPolicy and Policy (kyverno.io/v1): rules with validate, mutate, generate or verifyImages. Deprecated in Kyverno 1.19 and planned for removal in 1.20; the API server prints a deprecation warning for them.
  • CEL policies (policies.kyverno.io/v1): ValidatingPolicy, MutatingPolicy, GeneratingPolicy, DeletingPolicy, ImageValidatingPolicy, and their Namespaced* variants.

A policy is a cluster-wide guardrail someone chose on purpose. The usual fix is to make the resource comply, not to weaken the policy; changing or excepting a policy is a decision for its owners.

The commands use placeholders: my-namespace, my-app, my-policy and my-rule. Replace them with the real names. Never read Secrets (policies can reference them for image verification or context; read their names only).

When to use

  • Applying a manifest, a Helm install or a GitOps sync fails with a Kyverno denial.
  • A resource is admitted although a policy should have blocked it.
  • PolicyReports show FAIL results, or a policy is not Ready.
  • A mutate or generate rule does not change or create what it should.
  • Every create or update fails with failed calling webhook naming kyverno.

Hand-offs, by skill name. When the evidence points elsewhere, continue with that skill; if it is not installed, keep going with the steps here and tell the user which skill would help:

  • The Kyverno pods crash or stay Pending: k8s-workload-troubleshooting.
  • A different admission controller denies the request (Gatekeeper, a cloud policy add-on): k8s-gatekeeper-troubleshooting.

Investigate

Work through the steps in order. Stop when you have the cause and its evidence.

1. Read the denial the user got. It names the webhook, the policy and the rule: validate.kyverno.svc-fail (ClusterPolicy and Policy) or vpol.validate.kyverno.svc-fail (ValidatingPolicy). Rules that Kyverno generated for Deployments, StatefulSets, Jobs and similar from a Pod rule are named autogen-<rule> (autogen-cronjob-<rule> for CronJobs).

2. List the policies and their state.

bash
kubectl get clusterpolicies,policies -A
kubectl get validatingpolicies,mutatingpolicies,generatingpolicies,imagevalidatingpolicies
kubectl get namespacedvalidatingpolicies -A

3. Read the policy named in the denial: its match, its failure action, its rules.

bash
kubectl get clusterpolicy my-policy -o yaml
kubectl describe clusterpolicy my-policy
kubectl get validatingpolicy my-policy -o jsonpath='{.spec.validationActions}{"\n"}{.spec.matchConstraints}{"\n"}{.spec.validations}{"\n"}{.status}{"\n"}'

For ClusterPolicy and Policy, the failure action is validate.failureAction on each rule (Enforce blocks, Audit only reports), or the older spec.validationFailureAction. For a ValidatingPolicy it is spec.validationActions (Deny, Audit, Warn).

4. Read the policy reports for the resource: results of background scans and of admission in Audit mode.

bash
kubectl get policyreports -n my-namespace
kubectl get clusterpolicyreports
kubectl get policyreports -n my-namespace -o jsonpath='{range .items[*].results[?(@.result=="fail")]}{.policy}{" "}{.rule}{" "}{.message}{"\n"}{end}'
kubectl events -n my-namespace | grep -i policy

5. If Kyverno itself may be the problem, read its pods, its webhook configurations and its logs.

bash
kubectl get deployments,pods -n kyverno
kubectl get validatingwebhookconfigurations,mutatingwebhookconfigurations | grep -i kyverno
kubectl logs -n kyverno deployment/kyverno-admission-controller --tail=100
kubectl get configmap kyverno -n kyverno -o jsonpath='{.data.resourceFilters}{"\n"}'

6. Open the matching reference and follow its steps:

What you seeReference
A denial, was blocked due to the following policies, Policy ... failed, a policy that should block but only reports, PolicyReport failuresreferences/validation.md
Mutations that do not happen, generated resources missing, UpdateRequests, cleanup policiesreferences/mutate-and-generate.md
failed calling webhook naming kyverno, a policy not Ready, namespaces Kyverno ignores, controllers downreferences/webhooks-and-controllers.md

Read the results

What the common findings mean (Kyverno 1.19):

  • admission webhook "validate.kyverno.svc-fail" denied the request: resource <Kind>/<ns>/<name> was blocked due to the following policies, followed by <policy>: and <rule>: <message>: a ClusterPolicy or Policy rule in Enforce mode failed. The message after the rule name is the policy's own text plus the path that failed (failed at path /spec/template/metadata/labels/...).
  • admission webhook "vpol.validate.kyverno.svc-fail" denied the request: Policy <name> failed: <message>: a ValidatingPolicy with Deny failed.
  • An autogen- rule name: the policy was written for Pods; Kyverno applies it to the pod template of the controller you applied.
  • Admitted, and a fail result in a PolicyReport: the rule runs in Audit (or a ValidatingPolicy with Audit): Kyverno reports and lets it through.
  • No report and no denial at all: the policy does not match the resource (kinds, namespaces, selectors), the namespace is in the resourceFilters of the kyverno ConfigMap (by default kube-system, kube-public, kube-node-lease and kyverno), or the policy is not Ready.
  • failed calling webhook "validate.kyverno.svc-fail" (or another kyverno webhook): the API server cannot reach Kyverno, and the webhook fails closed. Nothing about the resource is wrong.

State the cause in one sentence, then the evidence you saw (the denial or report, the policy and rule, its failure action, its match), then the proposed fix.

Proposed fix

Show each fix to the user before running it: what it changes and how to undo it. Make the resource comply: change it in its source (manifest, Helm values, GitOps repository), so the next apply passes. Changing a policy's failure action or match, adding a PolicyException, and touching Kyverno's webhook configurations or ConfigMap change what is enforced for everyone: never run them yourself; hand them to the policy's owners as proposed fixes and say why. Write each undo with the values you found.

Bring back a Kyverno admission controller that was scaled to zero (write the undo with the replicas you found):

Ask first: the agent runs this only after the user approves it.

bash
kubectl scale deployment/kyverno-admission-controller -n kyverno --replicas=1
# Undo: kubectl scale deployment/kyverno-admission-controller -n kyverno --replicas=0

For a resource that must not comply (a real exception), the policy's owners add a PolicyException. Exceptions are turned off by default in Kyverno and must be enabled first (--enablePolicyException); see references/validation.md.

Sources

Checked against the Kyverno 1.19 documentation and source (v1.19.2):

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

K8s Kyverno Troubleshooting AI 技能有什么作用?

当 Kyverno 在 Kubernetes 中阻止资源、修改资源或无法执行策略检查时使用:“admission webhook \"validate.kyverno.svc-fail\" denied the request”;“resource ... was blocked due to the following policies”;ValidatingPolicy 返回“Policy ... failed”;本应阻止请求的策略却只报告问题(Audit);PolicyReports 中存在失败项;策略未处于 Ready 状态;mutate 或 generate 规则不起作用;UpdateRequests 卡住;或 Kyverno Pod 宕机时出现“failed calling webhook”。涵盖 ClusterPolicy 和 Policy(kyverno.io),以及 CEL 策略(policies.kyverno.io)。通过 kubectl get、describe、events 和日志进行排查,并提出修复建议。先读取信息,未经询问不会进行任何更改。

为什么在 TypingMind 中使用 K8s Kyverno Troubleshooting?

因为您只需安装一次,就能搭配任何模型使用。K8s Kyverno Troubleshooting 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 K8s Kyverno Troubleshooting?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/k8s-servant/k8s-skills/tree/main/skills/k8s-kyverno-troubleshooting。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 K8s Kyverno Troubleshooting?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

K8s Kyverno Troubleshooting 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 K8s Kyverno Troubleshooting 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

K8s Kyverno Troubleshooting AI 技能免费吗?

是的。k8s-servant 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇