简体   繁体   English

在 Nginx 上配置 TCP 端口 Azure Z30136395F018797812198317C 上的入口

[英]Configure TCP Port on Nginx Ingress on Azure Kubernetes Cluster (AKS)

I need to configure a TCP port on my AKS Cluster to allow RabbitMQ to work我需要在我的 AKS 集群上配置一个 TCP 端口以允许 RabbitMQ 工作

I have installed nginx-ingress with helm as follows:我已经使用 helm 安装了 nginx-ingress,如下所示:

kubectl create namespace ingress-basic

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

helm install nginx-ingress ingress-nginx/ingress-nginx \
    --namespace ingress-basic \
    --set controller.replicaCount=2 \
    --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set controller.admissionWebhooks.patch.nodeSelector."beta\.kubernetes\.io/os"=linux

I have setup an A record with our DNS provider to point to the public IP of the ingress controller.我已经使用我们的 DNS 提供程序设置了一个 A 记录,以指向入口 controller 的公共 IP。

I have created a TLS secret (to enable https)我创建了一个 TLS 密钥(启用 https)

I have created an ingress route with:我创建了一个入口路由:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: rabbit-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
  - hosts:
    - my.domain.com
    secretName: tls-secret
  rules:
    - http:
        paths:
          - backend:
              serviceName: rabbitmq-cluster
              servicePort: 15672
            path: /(.*)

I can navigate to my cluster via the domain name from outside and see the control panel (internally on 15672) with valid https.我可以从外部通过域名导航到我的集群,并使用有效的 https 查看控制面板(内部在 15672 上)。 So the ingress is up and running, and I can create queues etc... so rabbitmq is working correctly.所以入口启动并运行,我可以创建队列等......所以 rabbitmq 工作正常。

However, I can't get the TCP part to work to post to the queues from outside the cluster.但是,我无法让 TCP 部件从集群外部发布到队列。

I have edited the yaml of the what I believe is the configmap (azure - cluster - configuration - nginx-ingress-ingress-nginx-controller) for the controller (nginx-ingress-ingress-nginx-controller) via the azure portal interface and added this to the end I have edited the yaml of the what I believe is the configmap (azure - cluster - configuration - nginx-ingress-ingress-nginx-controller) for the controller (nginx-ingress-ingress-nginx-controller) via the azure portal interface and将此添加到末尾

data:
  '5672': 'default/rabbitmq-cluster:5672'

I have then edited they yaml for the service itself via the azure portal and added this to the end然后,我通过 azure 门户为服务本身编辑了 yaml 并将其添加到末尾

  - name: amqp
      protocol: TCP
      port: 5672

However, when I try to hit my domain using a test client the request just times out.但是,当我尝试使用测试客户端访问我的域时,请求就会超时。 (The client worked when I used a LoadBalancer and just hit the external IP of the cluster, so I know the client code should work) (当我使用 LoadBalancer 并且刚刚点击集群的外部 IP 时客户端工作,所以我知道客户端代码应该工作)

Is there another step that I should be doing?我应该做另一个步骤吗?

I believe the issue here was that helm was configuring so much of my own stuff that I wasn't able to customise too much.我认为这里的问题是 helm 配置了太多我自己的东西,以至于我无法自定义太多。

I uninstalled the ingress with helm and changed the ingress creation script to this:我用 helm 卸载了入口,并将入口创建脚本更改为:

helm install nginx-ingress ingress-nginx/ingress-nginx \
    --namespace ingress-basic \
    --set controller.replicaCount=2 \
    --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set controller.admissionWebhooks.patch.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set tcp.5672="default/rabbitmq-cluster:5672"

Which pre-configures the TCP port forwarding and I don't have to do anything else.其中预配置了 TCP 端口转发,我不需要做任何其他事情。 I don't know if it effected it, but this seemed to 'break' my SSL implementation, so I upgraded the ingress route creation script from v1beta to v1 and https was working again perfectly.我不知道它是否影响它,但这似乎“破坏”了我的 SSL 实现,所以我将入口路由创建脚本从 v1beta 升级到 v1,https 再次完美运行。

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rabbit-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
  - hosts:
      - my.domain.com
    secretName: tls-secret
  rules:
  - host: my.domain.com
    http:
      paths:
      - path: /(.*)
        pathType: Prefix
        backend:
          service:
            name: rabbitmq-cluster
            port:
              number: 15672

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM