本文介绍了用于通配符URL映射的Kubernetes Ingress控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让我的每个用户都通过自定义网址访问服务,例如. abccompany.mycloudapp.com,每个服务都是kubernetes服务,我正在查看入口控制器,但我需要一种使用通配符宿主字段的方法,并以某种方式将值读入path:和service:fields;这是我所想到的示例入口控制器:

I need for each of my users to access a service at a custom url eg. abccompany.mycloudapp.com , each service being a kubernetes service I'm looking at ingress controllers but I need a way to use a wildcard host field and somehow read the value into the path: and service: fields ; here's a sample ingress controller of what I have in mind:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: test
spec:
 rules:
 - host: *.bar.com
   http:
     paths:
     - path: /{{ value of * in * .bar.com }}
       backend:
         serviceName: {{value of * in *.bar.com }}Svc
         servicePort: 80

推荐答案

如果使用库存控制器,您将能够打开主机名并转到其他后端服务.听起来好像您不想枚举所有子域->服务映射,在这种情况下,您可能需要编写自己的控制器,该控制器写出在相应的proxy_pass或重定向行中使用$ http_host的nginx配置.试一试( https://github.com/kubernetes/contrib/tree/如果您需要帮助,请在同一存储库中找到master/ingress/controllers )和文件错误.

If you use the stock controllers you will be able to switch on hostname and go to different backends services. It sounds like you don't want to enumerate all the subdomains -> service mappings, in which case you probably need to write your own controller that writes out an nginx config that uses $http_host in the appropriate proxy_pass or redirect lines. Give it a shot (https://github.com/kubernetes/contrib/tree/master/ingress/controllers) and file bugs in that same repo if you need help.

这篇关于用于通配符URL映射的Kubernetes Ingress控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:10