简体   繁体   English

我可以使用ingress-nginx来简化路由流量吗?

[英]can i use ingress-nginx to simple route traffic?

I really like the kubernetes Ingress schematics. 我非常喜欢kubernetes Ingress原理图。 I currently run ingress-nginx controllers to route traffic into my kubernetes pods. 我目前运行ingress-nginx控制器将流量路由到我的kubernetes pods。

I would like to use this to also route traffic to 'normal' machines: ie vm's or physical nodes that are not part of my kubernetes infrastructure. 我想用它来将流量路由到'普通'机器:即vm或不属于我的kubernetes基础设施的物理节点。 Is this possible? 这可能吗? How? 怎么样?

In Kubernetes you can define an externalName service in which you define a FQND to an external server. 在Kubernetes中,您可以定义一个externalName服务,在该服务中为外部服务器定义FQND。

kind: Service
apiVersion: v1
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName
  externalName: my.database.example.com

Then you can use my-service in your nginx rule. 然后你可以在你的nginx规则中使用my-service

You can create static service and corresponding endpoints for external services which are not k8s and then use k8s service in ingress to route traffic. 您可以为非k8s的外部服务创建静态服务和相应的端点,然后在入口中使用k8s服务来路由流量。 Also you see ingress doc to enable custom upstream check https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-nginx-upstream-checks 您还可以看到入口doc以启用自定义上游检查https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-nginx-upstream-checks

In below example just change port/IP according to your need 在下面的示例中,只需根据需要更改端口/ IP

apiVersion: v1
kind: Service
metadata:
  labels:
    product: external-service
  name: external-service
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
 ---
 apiVersion: v1
 kind: Endpoints
 metadata:
   labels:
     product: external-service
   name: external-service
 subsets:
 - addresses:
   - ip: x.x.x.x
   - ip: x.x.x.x
   - ip: x.x.x.x
   ports:
   - name: http
     port: 80
     protocol: TCP

I don't think it's possible, since ingress-nginx get pods info through watch namespace, service, endpoints, ingress resources, then redirect traffic to pods, without these resources specific to kubernetes, ingress-nginx has no way to find the ips that need loadbalance. 我不认为这是可能的,因为ingress-nginx通过监视命名空间,服务,端点,入口资源获取pod信息,然后将流量重定向到pods,而没有特定于kubernetes的这些资源,ingress-nginx无法找到ips,需要负载均衡。 And ingress-nginx doesn't has health-check method defined, it's up to the kubernetes builtin mechanic to check the health of the running pods. 并且ingress-nginx没有定义健康检查方法,这取决于kubernetes内置机制来检查正在运行的pod的健康状况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microk8s、MetalLB、ingress-nginx - 如何路由外部流量? - Microk8s, MetalLB, ingress-nginx - How to route external traffic? ingress-nginx 配置使用自定义变量 - ingress-nginx config use custom variables 如何在没有 LoadBalancer 支持的自定义 k8s 安装上通过 Helm 使用 ingress-nginx? - How can I use ingress-nginx via Helm on custom k8s install without LoadBalancer support? Kubernetes:Ingress-nginx 不适用于 /api 路由中的子路径 - Kubernetes: Ingress-nginx does not work well with subpaths in the /api route 如何验证我的 Ingress-nginx Controller 正在拦截进入我的 Minikube LB 服务(本地)的流量? - How do I verify that my Ingress-nginx Controller is intercepting the traffic going into my Minikube LB Services (local)? Kubernetes ingress-nginx - 如果没有配置TLS,如何禁用https监听? - Kubernetes ingress-nginx - How can I disable listening on https if no TLS configured? 无法在 Ubuntu 18.04 上使用 ingress-nginx 进行路由 - Unable to use ingress-nginx for routing on Ubuntu 18.04 ingress-nginx没有IP地址 - ingress-nginx No IP Address Kubernetes通过Nginx入口路由dasboard流量 - Kubernetes route dasboard traffic thru nginx ingress 使用 ingress-nginx 重定向所有内容 - redirect everything with ingress-nginx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM