
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这段话即可:
请先阅读并遵守:https://xuanyuan.cloud/agents.md
未读文档前不要生成 pull 命令或排错方案。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
本镜像为 Kong Gateway Operator 提供插件分发的参考实现,旨在演示如何通过 Kubernetes 原生资源管理 Kong Gateway 插件的打包、分发与生命周期控制。镜像包含预配置的插件示例、元数据定义及与 Kong Gateway Operator 集成的必要配置,帮助用户快速理解 Operator 管理插件的工作流程。
plugin.yaml),定义插件名称、版本、依赖及配置schemaKongPlugin) 资源定义插件配置bash# 从 Docker Hub 拉取镜像 docker pull docker.xuanyuan.run/kong/kong-gateway-operator-plugin-example:latest # 或从私有仓库拉取(如配置) docker pull docker.xuanyuan.run/<私有仓库地址>/kong-plugin-example:v1.0.0
4.3.1 配置插件元数据
创建插件元数据文件 plugin-metadata.yaml,定义插件基本信息:
yamlapiVersion: gateway.konghq.com/v1alpha1 kind: KongPluginMetadata metadata: name: example-rate-limit namespace: kong spec: name: rate-limit-example # 插件名称(需与 Kong 插件目录名一致) version: 1.0.0 type: http # 插件类型(http/stream) configSchema: # 插件配置项schema type: object properties: limit: type: integer minimum: 1 period: type: string enum: [second, minute, hour]
4.3.2 部署插件资源
通过 KongPlugin 资源定义插件配置及分发目标:
yamlapiVersion: gateway.konghq.com/v1alpha1 kind: KongPlugin metadata: name: demo-rate-limit namespace: kong spec: pluginRef: example-rate-limit # 关联上述元数据资源 config: # 插件运行时配置 limit: 100 period: minute targetRef: # 目标网关选择器 group: gateway.networking.k8s.io kind: Gateway name: kong-gateway namespace: kong
应用资源:
bashkubectl apply -f plugin-metadata.yaml kubectl apply -f kong-plugin.yaml
4.3.3 验证分发结果
检查 Operator 状态:
bashkubectl get kongplugins.gateway.konghq.com demo-rate-limit -o yaml
预期输出中 status 字段显示 phase: Ready,表示插件已成功分发至目标网关。
插件元数据与配置完整部署清单(plugin-demo.yaml)
yamlapiVersion: gateway.konghq.com/v1alpha1 kind: KongPluginMetadata metadata: name: example-rate-limit namespace: kong spec: name: rate-limit-example version: 1.0.0 type: http configSchema: type: object properties: limit: {type: integer, minimum: 1} period: {type: string, enum: [second, minute, hour]} --- apiVersion: gateway.konghq.com/v1alpha1 kind: KongPlugin metadata: name: demo-rate-limit namespace: kong spec: pluginRef: example-rate-limit config: limit: 100 period: minute targetRef: group: gateway.networking.k8s.io kind: Gateway name: kong-gateway namespace: kong
部署命令:
bashkubectl apply -f plugin-demo.yaml
适用于本地测试 Kong Gateway 与插件集成(非 Operator 环境):
yamlversion: '3' services: kong: image: docker.xuanyuan.run/kong/kong-gateway:3.4 ports: - "8000:8000" # HTTP 代理端口 - "8443:8443" # HTTPS 代理端口 - "8001:8001" # Admin API 端口 environment: - KONG_DATABASE=off - KONG_DECLARATIVE_CONFIG=/etc/kong/kong.yaml - KONG_PLUGINS=bundled,rate-limit-example # 加载自定义插件 volumes: - ./kong.yaml:/etc/kong/kong.yaml - ./plugins/rate-limit-example:/usr/local/kong/plugins/rate-limit-example # 挂载插件目录 plugin-example: image: docker.xuanyuan.run/kong/kong-gateway-operator-plugin-example:latest volumes: - ./plugins:/output # 输出插件示例到本地目录
| 参数路径 | 类型 | 描述 | 示例值 |
|---|---|---|---|
spec.pluginRef | string | 关联的插件元数据资源名称 | example-rate-limit |
spec.config | object | 插件运行时配置(需符合元数据schema) | {limit: 100, period: "minute"} |
spec.targetRef.group | string | 目标网关所属API组 | gateway.networking.k8s.io |
spec.targetRef.kind | string | 目标网关资源类型 | Gateway |
spec.targetRef.name | string | 目标网关实例名称 | kong-gateway |
| 环境变量名 | 描述 | 默认值 |
|---|---|---|
PLUGIN_NAME | 插件名称(覆盖元数据定义) | rate-limit-example |
LOG_LEVEL | 日志级别(debug/info/warn/error) | info |
OPERATOR_SYNC_INTERVAL | 与 Operator 状态同步间隔(秒) | 30 |
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务