首页 > 解决方案 > HAProxy 动态 Kubernetes 前端模式匹配

问题描述

HAProxy 中是否可以匹配通过数据平面 consul 集成动态创建的后端?

在这种情况下,我想动态匹配

frontend hap
  mode http
  bind 127.0.0.1:80
  bind 1.1.1.1:80
  # URL Pattern should be K8S_Namespace/K8S_Service
  acl PATH_srvc path_beg -i /dev/another-nginx-service-nodeport
  # What is desired is to use the backend with wildcards for namespace and service
  # use backend *-K8S_Service-K8S_Namespace
  use_backend consul-backend-1.1.1.1-80-another-nginx-service-nodeport-dev if PATH_srvc

backend consul-backend-1.1.1.1-80-another-nginx-service-nodeport-dev

我想做的只是基于命名空间进行匹配,在这种情况下命名空间:dev 和服务名称:another-nginx-service-nodeport。

服务的 consul-backend-ip-port 部分不感兴趣。我是 HAProxy 的新手,但我无法在文档中找到类似的东西......我找到了一些提示,但在这种情况下它需要使用地图,而我没有......

use_backend be_%[path,map_beg(/etc/hapee-1.8/paths.map)]

这可能是一个远景我的目标是使用 HAProxy 作为代理到 K8S 集群上的一系列后端,利用 Consul HAProxy 集成。

标签: haproxy

解决方案


推荐阅读