我创建了一个Ingress,Deployment和Service,如下所示:

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-first
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 8080
  selector:
    app: hello-kubernetes-first
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-first
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-first
  template:
    metadata:
      labels:
        app: hello-kubernetes-first
    spec:
      containers:
        - name: hello-kubernetes
          image: paulbouwer/hello-kubernetes:1.8
          ports:
            - containerPort: 8080
          env:
            - name: MESSAGE
              value: Hello from the first deployment!
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: istio
  name: helloworld-ingress
spec:
  rules:
    - host: "hw.service.databaker.io"
      http:
        paths:
          - path: /
            backend:
              serviceName: hello-kubernetes-first
              servicePort: 80
---

当我调用https://hw.service.databaker.io/时,它将阻止:

kubernetes - 为什么css和png无法访问?-LMLPHP

CSS和PNG。我究竟做错了什么?我正在使用Istio 1.52。

三个 Pane 之一的日志具有以下内容:
::ffff:127.0.0.1 - - [04/May/2020:10:25:06 +0000] "HEAD / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:33:33 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:34:19 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:34:20 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:34:21 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:34:22 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:36:24 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"
::ffff:127.0.0.1 - - [04/May/2020:10:36:25 +0000] "GET / HTTP/1.1" 200 680 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/81.0.4044.129 Chrome/81.0.4044.129 Safari/537.36"

最佳答案

它不可访问,因为您必须向istio显示它的路径。

正如@zero_coding在评论中提到的,一种方法是更改​​路径

http:
        paths:
          - path: /
            backend:
              serviceName: hello-kubernetes-first
              servicePort: 80
http:
        paths:
          - path: /*
            backend:
              serviceName: hello-kubernetes-first
              servicePort: 80

另外,我将在此处添加此Istio in practise教程,它很好地解释了解决该问题的第二种方法,即添加更多路径。
http:
  - match:
    - uri:
        exact: /
    - uri:
        exact: /callback
    - uri:
        prefix: /static
    - uri:
        regex: '^.*\.(ico|png|jpg)$'
    route:
    - destination:
        host: frontend
        port:
          number: 80

关于kubernetes - 为什么css和png无法访问?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61590027/

10-11 17:48