【问题标题】:Why is my ISTIO policy configuration not applied?为什么我的 ISTIO 策略配置没有应用?
【发布时间】:2019-07-18 15:37:46
【问题描述】:

我正在使用 Istio-1.0.6 来实现身份验证/授权。我正在尝试使用 Jason Web Tokens (JWT)。我遵循了文档中的大多数示例,但没有得到预期的结果。这是我的设置:

服务

kubectl describe services hello
Name:              hello
Namespace:         agud
Selector:          app=hello
Type:              ClusterIP
IP:                10.247.173.177
Port:              <unset>  8080/TCP
TargetPort:        8080/TCP
Endpoints:         172.16.0.193:8080
Session Affinity:  None

网关

kubectl describe gateway
Name:         hello-gateway
Namespace:    agud
Kind:         Gateway
Metadata:
  Cluster Name:
  Creation Timestamp:  2019-03-15T13:40:43Z
  Resource Version:    1374497
  Self Link:           
/apis/networking.istio.io/v1alpha3/namespaces/agud/gateways/hello-gateway
  UID:                 ee483065-4727-11e9-a712-fa163ee249a9
Spec:
  Selector:
    Istio:  ingressgateway
  Servers:
    Hosts:
      *
    Port:
      Name:      http
      Number:    80
      Protocol:  HTTP

虚拟服务

kubectl describe virtualservices
Name:         hello
Namespace:    agud
API Version:  networking.istio.io/v1alpha3
Kind:         VirtualService
Metadata:
  Cluster Name:
  Creation Timestamp:  2019-03-18T07:38:52Z
  Generation:          0
  Resource Version:    2329507
  Self Link:           
/apis/networking.istio.io/v1alpha3/namespaces/agud/virtualservices/hello
  UID:                 e099b560-4950-11e9-82a1-fa163ee249a9
Spec:
  Gateways:
    hello-gateway
  Hosts:
    *
  Http:
    Match:
      Uri:
        Exact:  /hello
      Uri:
        Exact:  /secured
    Route:
      Destination:
        Host:  hello.agud.svc.cluster.local
        Port:
          Number:  8080

政策

kubectl describe policies
Name:         jwt-hello
Namespace:    agud
API Version:  authentication.istio.io/v1alpha1
Kind:         Policy
Metadata:
  Cluster Name:
  Creation Timestamp:  2019-03-18T07:45:33Z
  Generation:          0
  Resource Version:    2331381
  Self Link:           
/apis/authentication.istio.io/v1alpha1/namespaces/agud/policies/jwt-hello
  UID:                 cf9ed2aa-4951-11e9-9f64-fa163e804eca
Spec:
  Origins:
    Jwt:
      Audiences:
        hello
      Issuer:         testing@secure.istio.io
      Jwks Uri:       https://raw.githubusercontent.com/istio/istio/release-1.0/security/tools/jwt/samples/jwks.json
  Principal Binding:  USE_ORIGIN
  Targets:
    Name:  hello.agud.svc.cluster.local

结果

我预计会收到 401 错误,但我收到了 200。我的配置有什么问题,如何解决?

curl $INGRESS_HOST/hello -s -o /dev/null -w "%{http_code}\n"
200

【问题讨论】:

  • 请通过提供 yaml 文件而不是 describe 命令来简化操作

标签: kubernetes istio


【解决方案1】:

你有:

Port:              <unset>  8080/TCP

对于Istio 路由和安全,您必须将端口名称设置为httphttp-&lt;something&gt;

我尝试使用 Istio 1.1。我得到的是 503 而不是 401

【讨论】:

  • 嗨@esnible,我添加了端口8080,但没有帮助。
  • 您的 Kubernetes 服务“hello”将有一个端口。在 Kubernetes 中,端口有一个名称字段,但它只是一个标签。这个名字对 Istio 很有意义。尝试 kubectl edit 你的 hello 服务并将端口命名为 http
  • 不幸的是,这也没有帮助。 kubectl describe service hello 名称:hello 命名空间:agud 标签: 注释: 选择器:app=hello 类型:ClusterIP IP:10.247.174.223 端口:http 8080/TCP TargetPort:8080/TCP Endpoints:172.16.0.163: 8080 会话关联性:无事件:
猜你喜欢
  • 2016-06-14
  • 2012-07-20
  • 2020-02-29
  • 2020-09-18
  • 1970-01-01
  • 2020-05-28
  • 1970-01-01
  • 2018-07-26
  • 1970-01-01
相关资源
最近更新 更多