
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
k-rail是Kubernetes的工作负载策略执行工具,旨在帮助用户安全管理多租户集群,实现最小干扰和最大部署速度的策略实施。
注意:k-rail项目已被弃用,除关键安全漏洞外不再接收新功能或 bug 修复。建议迁移至活跃开发的工具,如https://github.com/open-policy-agent/gatekeeper%E3%80%82
bash# 添加Helm仓库 helm repo add k-rail https://cruise-automation.github.io/k-rail/ helm repo update # 创建命名空间 kubectl create namespace k-rail kubectl label namespace k-rail k-rail/ignore=true # 安装k-rail helm install k-rail k-rail/k-rail --namespace k-rail
bashhelm template --namespace k-rail charts/k-rail | kubectl apply -f -
应用非合规部署测试默认配置:
bashkubectl apply --namespace default -f examples/non-compliant-deployment.yaml
应用资源时直接显示违规信息:
bash$ kubectl apply -f examples/non-compliant-deployment.yaml Error from server (k-rail): error when creating "examples/non-compliant-deployment.yaml": admission webhook "k-rail.cruise-automation.github.com" denied the request: Deployment bad-deployment had violation: Host Bind Mounts: host bind mounts are forbidden ...
通过Kubernetes Events查看近期违规:
bashkubectl get events --namespace default
结构化JSON日志包含详细违规信息:
bashkubectl logs --namespace k-rail --selector name=k-rail | jq '.'
示例日志:
json{ "enforced": true, "kind": "Deployment", "namespace": "default", "policy": "pod_no_host_network", "resource": "evil-deployment", "time": "2019-10-23T19:54:24Z", "user": "dustin.decker@getcruise.com" }
yamlpolicy_config: mutate_empty_dir_size_limit: maximum_size_limit: "1Gi" default_size_limit: "512Mi"
yamlpolicy_config: mutate_image_pull_policy: IfNotPresent: - '^gcr.io/repo/image1.*' Always: - '^gcr.io/private-repo/secretimage.*'
yamlpolicy_config: policy_trusted_repository_regexes: - '^gcr.io/some-gcr-repo/.*' - '^k8s.gcr.io/.*'
yamlpolicy_config: policy_require_ingress_exemption_classes: - nginx-public
yamlpolicy_config: policy_require_service_loadbalancer_annotations: - annotations: - "cloud.google.com/load-balancer-type" allowed_values: - internal - external allow_missing: false
yamlpolicy_config: policy_require_virtualservice_gateways: allowed_gateways: - "istio-system/internal-gateway" - "mesh" allow_empty_gateways: true
yamlpolicy_config: policy_default_seccomp_policy: "runtime/default"
k-rail.crd.protect: enabled)report_only: true/false通过配置文件定义豁免规则:
yaml- cluster_name: paas-ci-us-west1 resource_name: "*" namespace: "cluster-conformance-testing" username: "cluster-ci@paas-ci.iam.gserviceaccount.com" group: "*" exempt_policies: - "pod_no_privileged_containers" - "pod_no_bind_mounts"
bashhelm uninstall k-rail --namespace k-rail
bashhelm template --namespace k-rail charts/k-rail | kubectl delete -f -
检查mTLS证书过期时间,确保Webhook正常通信
https://github.com/cruise-automation/k-rail/blob/master/LICENSE
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务