DEBUG.WIKI
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
搬瓦工;先看线路,再选 VPS;CN2 GIA · 对应线路套餐;查看线路 →

解决 Consul Connect 报错 envoy bootstrap generation failed 引导配置失败修复

排查 Consul Service Mesh 中 Envoy 启动边车报错 error generating bootstrap: failed to retrieve agent token 或 connection refused,分析 Consul Agent 通信与 ACL Token。

问题现象

Consul Connect 的 Envoy 边车启动闪退,标准错误输出:

==> Error generating bootstrap: error fetching proxy config: Unexpected response code: 403 (Permission denied: ACL token not authorized)
==> Exiting...

触发根因

  1. 传递给 Envoy 引导生成命令的 CONSUL_HTTP_TOKEN 缺少针对该服务的 service:write 或 node:read ACL 策略特权;
  2. 边车尝试连接的 Consul 本地 Client Agent 未开启 Connect 代理支持(connect.enabled: true);
  3. Consul Agent 默认监听 127.0.0.1:8500,而边车容器处于独立网络命名空间无法直接回环访问。

解决步骤

为该微服务创建专用合规 ACL Token

生成带 service 写入权限的授权策略:

# service-policy.hcl
service "web-api" {
  policy = "write"
}
node_prefix "" {
  policy = "read"
}

创建 Token:

consul acl token create -description "Envoy bootstrap for web-api" -policy-name service-policy

在启动命令中提供合规 Token 与正确的 Agent 地址

启动 Envoy 边车代理:

consul connect envoy -sidecar-for web-api \
  -http-addr=http://10.0.1.10:8500 \
  -token="b12a-3c4d..." -- -l info

验证确认

观察 Envoy 启动输出:

Bootstrap JSON 秒级生成,Envoy 成功连通 Consul xDS gRPC 接口拉取动态路由。