简体   繁体   English

我必须在 kubernetes 上的蚊子经纪人中订阅/发布哪个 IP

[英]Which IP do I have to sub/pub in a mosquitto broker on kubernetes

I have deployed a mosquitto image in a pod in kubernetes with this dockerfile:我已经使用这个 dockerfile 在 kubernetes 的 pod 中部署了蚊子图像:

FROM eclipse-mosquitto:1.6.7

I downloaded the image an added it to my cluster, using this yaml:我使用此 yaml 下载了图像并将其添加到我的集群中:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mosquitto-demo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      bb: web
  template:
    metadata:
      labels:
        bb: web
    spec:
      containers:
      - name: bb-site
        image: mosquittotest:1.0
---
apiVersion: v1
kind: Service
metadata:
  name: mosquitto-entrypoint
  namespace: default
spec:
  type: NodePort
  selector:
    bb: web
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 30001

It is running correctly.它运行正常。 My question is: How can I know which IP is the one I should use t sub/pub, and wich port?我的问题是:我怎么知道哪个 IP 是我应该使用 t sub/pub 的那个,以及哪个端口? Do I just have to use the IP of the entrypoint service with the 8080 port?我是否只需将入口点服务的 IP 与 8080 端口一起使用? Im at a loss here.我在这里不知所措。

Do you get an IP-address on the Service?您是否在服务上获得 IP 地址?

Using ClusterIP使用集群 IP

To have an cluster interal IP, you should set type=ClusterIP on your service:要拥有一个集群内部 IP,您应该在您的服务上设置type=ClusterIP

spec:
  type: ClusterIP

Your clients route it requests to a DNS name for the service, depending on how your namespaces are setup.您的客户端将其请求路由到服务的 DNS 名称,具体取决于您的命名空间的设置方式。 See DNS for Services and Pods有关服务和 Pod,请参阅 DNS

Using NodePort使用节点端口

If you want to continue using type=NodePort, you can send request to the IP for any Node, but with the specific Node Port number.如果您想继续使用 type=NodePort,您可以向 IP 发送任何节点的请求,但使用特定的节点端口号。

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

相关问题 如何在 Docker 桌面 Kubernetes 集群上找到主 IP? - How do I find the master IP on Docker Desktop Kubernetes Cluster? 我有一个 python 脚本在 kubernetes pod 的容器内运行。如何停止与 pod 一起运行的脚本? - I have a python script running inside a container of kubernetes pod.How do i stop the script which runs along with the starting of the pod? 使用 Mosquitto 客户端测试 VerneMQ 代理 TLS - Test VerneMQ broker TLS with Mosquitto client 从不同的网络访问 Mosquitto Broker - Accessing the Mosquitto Broker from a different network 如何在 Kubernetes 中使用 postgres 运行 Pact Broker? - How can I run Pact Broker with postgres in Kubernetes? Nginx 守护进程 - 我如何 select 绑定到哪个 IP 地址? - Nginx Daemonset - How do I select which IP address to bind to? Kubernetes - 我的 2 个应用程序部署仅在一个“参数”中有所不同 - 我可以拥有将引用它们的服务吗? - Kubernetes - my 2 Apps Deployments are different only in one "args" - can I have the Service which will reference both of them? 无法订阅Docker Eclipse-Mosquitto Broker - Can't subscribe to Docker Eclipse-Mosquitto Broker Mosquitto代理不会在Raspberry重新启动时使用Docker重新启动 - Mosquitto broker won't restart with Docker on Raspberry reboot 将 dockerized Spring boot 应用程序连接到 MQTT Mosquitto 代理 - Connecting dockerized Spring boot app to MQTT Mosquitto broker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM