多个端口的 Traefik 入口
Traefik ingress for multiple ports
我已经使用 rabbitmq rabbitmq cluster operator 在 k3s 集群中部署了 rabbitmq 集群。结果,它创建了一个如下所示的 ClusterIP 服务:
Name: rabbitmq
Namespace: rabbits
Labels: app.kubernetes.io/component=rabbitmq
app.kubernetes.io/name=rabbitmq
app.kubernetes.io/part-of=rabbitmq
Annotations: <none>
Selector: app.kubernetes.io/name=rabbitmq
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.48.11
IPs: 10.43.48.11
Port: amqp 5672/TCP
TargetPort: 5672/TCP
Endpoints: 10.42.2.55:5672,10.42.2.56:5672
Port: management 15672/TCP
TargetPort: 15672/TCP
Endpoints: 10.42.2.55:15672,10.42.2.56:15672
Port: mqtt 1883/TCP
TargetPort: 1883/TCP
Endpoints: 10.42.2.55:1883,10.42.2.56:1883
Port: web-mqtt 15675/TCP
TargetPort: 15675/TCP
Endpoints: 10.42.2.55:15675,10.42.2.56:15675
Port: stomp 61613/TCP
TargetPort: 61613/TCP
Endpoints: 10.42.2.55:61613,10.42.2.56:61613
Port: web-stomp 15674/TCP
TargetPort: 15674/TCP
Endpoints: 10.42.2.55:15674,10.42.2.56:15674
Port: prometheus 15692/TCP
TargetPort: 15692/TCP
Endpoints: 10.42.2.55:15692,10.42.2.56:15692
Session Affinity: None
Events: <none>
我想为管理门户打开端口 15672,为 kubernetes 集群之外的应用程序打开端口 5672。我尝试了以下但没有奏效:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: rabbitmq
servicePort: 15672
- path : /
backend:
serviceName: rabbitmq
servicePort: 5672
任何人都可以帮助我,我做错了什么?
提前致谢。
你不能让两条路径都指向同一个位置。此外,您应该为 Ingress 设置 FQDN。
尝试使用两个具有不同名称的 Ingresses - 这在大多数情况下都有效:
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress-one
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: rabbitmq
servicePort: 15672
host: host1.example.com
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress-two
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path : /
backend:
serviceName: rabbitmq
servicePort: 5672
host: host2.example.com
或者在单个 Ingress 上使用两条路径 - 可能涉及一些额外的路径重写:
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /one
backend:
serviceName: rabbitmq
servicePort: 15672
- path : /two
backend:
serviceName: rabbitmq
servicePort: 5672
host: host1.example.com
我已经使用 rabbitmq rabbitmq cluster operator 在 k3s 集群中部署了 rabbitmq 集群。结果,它创建了一个如下所示的 ClusterIP 服务:
Name: rabbitmq
Namespace: rabbits
Labels: app.kubernetes.io/component=rabbitmq
app.kubernetes.io/name=rabbitmq
app.kubernetes.io/part-of=rabbitmq
Annotations: <none>
Selector: app.kubernetes.io/name=rabbitmq
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.48.11
IPs: 10.43.48.11
Port: amqp 5672/TCP
TargetPort: 5672/TCP
Endpoints: 10.42.2.55:5672,10.42.2.56:5672
Port: management 15672/TCP
TargetPort: 15672/TCP
Endpoints: 10.42.2.55:15672,10.42.2.56:15672
Port: mqtt 1883/TCP
TargetPort: 1883/TCP
Endpoints: 10.42.2.55:1883,10.42.2.56:1883
Port: web-mqtt 15675/TCP
TargetPort: 15675/TCP
Endpoints: 10.42.2.55:15675,10.42.2.56:15675
Port: stomp 61613/TCP
TargetPort: 61613/TCP
Endpoints: 10.42.2.55:61613,10.42.2.56:61613
Port: web-stomp 15674/TCP
TargetPort: 15674/TCP
Endpoints: 10.42.2.55:15674,10.42.2.56:15674
Port: prometheus 15692/TCP
TargetPort: 15692/TCP
Endpoints: 10.42.2.55:15692,10.42.2.56:15692
Session Affinity: None
Events: <none>
我想为管理门户打开端口 15672,为 kubernetes 集群之外的应用程序打开端口 5672。我尝试了以下但没有奏效:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: rabbitmq
servicePort: 15672
- path : /
backend:
serviceName: rabbitmq
servicePort: 5672
任何人都可以帮助我,我做错了什么?
提前致谢。
你不能让两条路径都指向同一个位置。此外,您应该为 Ingress 设置 FQDN。
尝试使用两个具有不同名称的 Ingresses - 这在大多数情况下都有效:
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress-one
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: rabbitmq
servicePort: 15672
host: host1.example.com
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress-two
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path : /
backend:
serviceName: rabbitmq
servicePort: 5672
host: host2.example.com
或者在单个 Ingress 上使用两条路径 - 可能涉及一些额外的路径重写:
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: rabbitmq-admin-ingress
annotations:
kubernetes.io/ingress.class: "traefik"
spec:
rules:
- http:
paths:
- path: /one
backend:
serviceName: rabbitmq
servicePort: 15672
- path : /two
backend:
serviceName: rabbitmq
servicePort: 5672
host: host1.example.com