Install the k8s cluster
1 | microk8s enable dns storage helm3 |
Install the Mqtt helm chart
1 | microk8s helm repo add truecharts https://charts.truecharts.org/ |
Check the status of the installed application.
1 | microk8s status |
Service yaml file
We need to expose the service to the outside world.
Thankfully microk8s has a built in loadbalancer called metallb
Replace Y with the MQTT port number. Default 1883
Replace Z with the MQTT API number Default 9001
1 | apiVersion: v1 |
More information here
https://medium.com/swlh/kubernetes-external-ip-service-type-5e5e9ad62fcd
Apply the service
1 | microk8s kubectl apply -f ./mqtt-service.yaml |
Confirm the service is active
1 | microk8s kubectl describe services mqtt-service |
Local test client
You can test the connection locally on the server with this simple CLI mqtt client
Test client
https://mqttx.app/cli
Firewall Rules
This assumes you are using ufw.
ufw is bascally a wrapper for IPTABLES. If you have ever used IPTABLES before you understand why ufw exists.
1 | sudo ufw default allow routed |
Test external Connections
Once again try to connect to port Y with https://mqttx.app/cli
References
https://kubernetes.io/docs/concepts/services-networking/service/