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