[英]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.