调用端点并返回404,并配置了VirtualService和Gateway

时间:2019-04-02 15:41:37

标签: proxy http-status-code-404 gateway istio

我正在使用Istio和Kubernetes在内部配置集群。我想为一个应用程序创建一个简单的流程,该应用程序是一个名为“ gogs”的存储库。我首先要访问Istio Ingressport 80(31380),然后转到端口8004(服务中绑定到3000)公开的服务。

我尝试了VirtualService,Gateway,ServiceEntry,DestinationRules的不同配置,但没有404的配置。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  creationTimestamp: "2019-04-02T08:18:27Z"
  generation: 24
  name: repository-gogs
  namespace: alm
  resourceVersion: "2077079"
  selfLink: /apis/networking.istio.io/v1alpha3/namespaces/alm/virtualservices/repository-gogs
  uid: e4254ec1-551f-11e9-a886-000d3ab0595e
spec:
  gateways:
  - repository-gogs
  hosts:
  - repository.kube.int
  http:
  - match:
    - port: 80
    route:
    - destination:
        host: repository-gogs
        port:
          number: 8004

---

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  annotations:
  creationTimestamp: "2019-04-02T08:18:27Z"
  generation: 7
  name: repository-gogs
  namespace: alm
  resourceVersion: "2060363"
  selfLink: /apis/networking.istio.io/v1alpha3/namespaces/alm/gateways/repository-gogs
  uid: e4213d6a-551f-11e9-a886-000d3ab0595e
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - repository.kube.int
    port:
      name: http
      number: 80
      protocol: HTTP

---

Name:         repository-gogs
Namespace:    alm
Labels:       <none>
Kind:         DestinationRule
Metadata:
  Creation Timestamp:  2019-04-02T10:47:59Z
  Generation:          1
  Resource Version:    2051550
  Self Link:           /apis/networking.istio.io/v1alpha3/namespaces/alm/destinationrules/repository-gogs
  UID:                 c812e074-5534-11e9-a886-000d3ab0595e
Spec:
  Host:  repository-gogs
  Traffic Policy:
    Connection Pool:
      Http:
        Http 1 Max Pending Requests:  1
        Max Requests Per Connection:  1
      Tcp:
        Max Connections:  1
    Outlier Detection:
      Base Ejection Time:    3m
      Consecutive Errors:    1
      Interval:              1s
      Max Ejection Percent:  100
Events:                      <none>

入口:

istio-system istio-ingressgateway负载均衡器10.109.51.165 80:31380 / TCP,443:31390 / TCP,31400:31400 / TCP,15011:31989 / TCP,8060:30857 / TCP,853:30890 / TCP 8d < / p>

应用程序端口:

alm信息库-群集ClusterIP 10.103.61.149 8004 / TCP,22 / TCP 4d23h

所有对象都在同一个命名空间中

我在/ etc / hosts中将repository.kube.int绑定到172.17.1.6

当我这样做时:

curl -v http://repository.kube.int:31380/

实际:


* About to connect() to repository.kube.int port 31380 (#0)
*   Trying 172.17.1.6...
* Connected to repository.kube.int (172.17.1.6) port 31380 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: repository.kube.int:31380
> Accept: */*
>
< HTTP/1.1 404 Not Found
< date: Tue, 02 Apr 2019 15:35:50 GMT
< server: envoy
< content-length: 0
<
* Connection #0 to host repository.kube.int left intact

如果我更改

- host:
    - repository.kube.int

 - host:
     - '*'

返回确定

* About to connect() to repository.kube.int port 31380 (#0)
*   Trying 172.17.1.6...
* Connected to repository.kube.int (172.17.1.6) port 31380 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: repository.kube.int:31380
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: text/html; charset=UTF-8
< set-cookie: lang=en-US; Path=/; Max-Age=2147483647
< set-cookie: i_like_gogs=c1968b7f9886cc0f; Path=/; HttpOnly
< set-cookie: _csrf=hacKNx2Ik5wxjJgWx1m7VRTY2go6MTU1NDIxOTUwNDM3ODI2MDQzMA%3D%3D; Path=/; Expires=Wed, 03 Apr 2019 15:38:24 GMT; HttpOnly
< date: Tue, 02 Apr 2019 15:38:24 GMT
< x-envoy-upstream-service-time: 3
< server: envoy
< transfer-encoding: chunked
<
<!DOCTYPE html>

我做错了什么?

0 个答案:

没有答案