Istio RequestAuthentication 阻止 envoy sidecar 的 Ready 状态

Posted

技术标签:

【中文标题】Istio RequestAuthentication 阻止 envoy sidecar 的 Ready 状态【英文标题】:Istio RequestAuthentication blocks envoy sidecar's Ready status 【发布时间】:2021-07-06 04:44:32 【问题描述】:

您能帮我理解 RequestAuthentication 吗? 当我应用简单的 RequestAuthentication 并重新启动 Pod 时,envoy sidecar 的就绪状态为 false,并且日志抛出 warn Envoy proxy is NOT ready: config not received from Pilot (is Pilot running?): cds updates: 1 successful, 0 rejected; lds updates: 0 successful, 1 rejected 一旦我删除 RequestAuthentication 并重新创建 pod - 工作正常 Istio 1.8.3

apiVersion: 'security.istio.io/v1beta1'
kind: RequestAuthentication
metadata:
  name: jwt-validator
spec:
  selector:
    matchLabels:
      role: api
  jwtRules:
  - issuer: "https://mykeycloak.com/auth/realms/myrealm"

当代理处于 LDS 陈旧状态时 以下日志显示在 istiod 中

2021-04-10T17:30:53.326877Z    warn    ads    ADS:LDS: ACK ERROR sidecar~10.238.2.69~PODNAME.NS~NS.svc.cluster.local-60 Internal:Error adding/updating listener(s) vi ││ rtualInbound: Issuer 'MY_JWT_ISSUER_URL' in jwt_authn config has invalid local jwks: Jwks RSA [n] or [e] field is missing or has a parse error

已解决 这里的 Issuer 不仅仅是 JWT 中要匹配的字符串,而是必须从 istiod 访问的真实 URL,并且具有有效的 SSL 证书

【问题讨论】:

嗨@Yegor Lopatin,我看到你已经解决了这个问题。请考虑将其发布为答案并接受它,因此如果社区中的某个人遇到同样的问题,他可能会在这里找到答案。 【参考方案1】:

我放置这个答案是为了提高知名度。


正如@Yegor Lopatin 在编辑中提到的,通过修复发行者解决了这个问题:

这里的Issuer不仅仅是JWT中要匹配的字符串,而是必须可以从istiod访问的真实URL,并且具有有效的SSL证书

发行者必须是有效且可访问的链接。我以为它只是一个字符串,你在阅读 JWT 时比较一下

例如

jwtRules:
  - issuer: "testing@secure.istio.io"
    jwksUri: "https://raw.githubusercontent.com/istio/istio/release-1.5/security/tools/jwt/samples/jwks.json"

当您使用 istio 设置 JWT 时,您可能会参考以下教程:

https://www.istiobyexample.dev/jwt https://istio.io/latest/docs/tasks/security/authorization/authz-jwt/

【讨论】:

以上是关于Istio RequestAuthentication 阻止 envoy sidecar 的 Ready 状态的主要内容,如果未能解决你的问题,请参考以下文章

初识 Istio

idou老师教你学Istio 04:Istio性能及扩展性介绍

idou老师教你学Istio 20 : Istio全景监控与拓扑

让Istio比你想象中简单,Rancher新版本宣布支持Istio

istio-ingress-gateway

Istio 的 GitOps——像代码一样管理 Istio 配置