GKE Ingress不尊重重写规则

时间:2017-08-24 18:26:01

标签: kubernetes google-kubernetes-engine

在Google容器引擎上运行群集。

期望它尊重重写规则。运行调试echo server,表明它不遵守kubernetes ingress docs中记录的http重写规则。

在minikube上本地工作就好了。 realpath参数仍然附加了调试,尽管重写是在匹配后剥离。预计/foo/bar/ vs /debug/foo/bar

附加

网址+回复

  

http://homes.stanzheng.com/debug/foo/bar   



CLIENT VALUES:
client_address=10.12.2.1
command=GET
real path=/debug/foo/bar
query=nil
request_version=1.1
request_uri=http://homes.stanzheng.com:8080/debug/foo/bar

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
accept-encoding=gzip, deflate
accept-language=en-US,en;q=0.8
connection=Keep-Alive
cookie=__cfduid=dfd6a6d8c2a6b361a3d72e3fc493295441494876880; _ga=GA1.2.5098880.1494876881
host=homes.stanzheng.com
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36
via=1.1 google
x-cloud-trace-context=1586885dcac2d537189444861a8a462c/1232314719683944914
x-forwarded-for=204.154.44.39, 35.190.78.5
x-forwarded-proto=http
BODY:
-no body in request-






apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rewrite
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: minikube.homes
    http:
      paths:
      - path: /debug/*
        backend:
          serviceName: echoserver
          servicePort: 8080




2 个答案:

答案 0 :(得分:2)

Google Container Engine Ingress不支持

rewrite-target。有关功能的比较,请参阅此页面:

https://github.com/kubernetes/ingress/blob/master/docs/annotations.md

答案 1 :(得分:0)

您可以使用Nginx入口控制器,如本博客中所述:

http://rahmonov.me/posts/nginx-ingress-controller/

按照这些步骤操作后,您需要将以下注释添加到您的入口yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rewrite
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: minikube.homes
    http:
      paths:
      - path: /debug/*
        backend:
          serviceName: echoserver
          servicePort: 8080