多端口Traefik入口



我已经使用rabbitmq-rabbitmq-cluster操作符在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。

尝试使用两个不同名称的Ingress,这在大多数情况下都有效:

---
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

或者在一个入口上使用两条路径-可能涉及一些额外的路径重写:

---
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

相关内容

  • 没有找到相关文章

最新更新