I have the following Mosquitto setup on my minikube:
Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mosquitto
namespace: mosquitto
spec:
replicas: 1
selector:
matchLabels:
name: mosquitto
template:
metadata:
labels:
name: mosquitto
spec:
containers:
- name: mosquitto
image: eclipse-mosquitto:2.0.12
ports:
- containerPort: 1883
volumeMounts:
- name: mosquitto-config
mountPath: /mosquitto/config/mosquitto.conf
subPath: mosquitto.conf
volumes:
- name: mosquitto-config
configMap:
name: mosquitto-configmap
ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: mosquitto-configmap
namespace: mosquitto
data:
mosquitto.conf: |-
listener 1883
allow_anonymous true
Service:
apiVersion: v1
kind: Service
metadata:
name: mosquitto-service
spec:
type: NodePort
selector:
name: mosquitto
ports:
- protocol: TCP
port: 1883
targetPort: 1883
nodePort: 30007
Now I'd like to access my deployment from my LAN. Testing with MQTT-Explorer from my host Windows machine. Using mqtt://localhost:30007 doesn't work. The setup is known to be working with port-forwarding, tho.
$ k port-forward mosquitto-66d69df7c9-zrvgt 1111:1883
Forwarding from 127.0.0.1:1111 -> 1883
Forwarding from [::1]:1111 -> 1883
Handling connection for 1111
I think I'm misunderstanding the service part. In the end the service should be reachable from within my LAN either with :
Bonus question: How can I route the service to something like mqtt.local? Kubernetes Ingress doesn't work for me either, guessing because it's used for HTTP only