Skip to content

Instantly share code, notes, and snippets.

@richardjkendall
Last active February 22, 2021 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardjkendall/3c1fe32f448bddf18b47dffcb66aa972 to your computer and use it in GitHub Desktop.
Save richardjkendall/3c1fe32f448bddf18b47dffcb66aa972 to your computer and use it in GitHub Desktop.
Simple passwordless MQTT broker on kube (pv/pvc for reader...)
Code to deploy eclipse mosquitto in a simple, open fashion on Kube.
You'll need to sort out the PV/PVC.
kubectl apply -f configmap.yml
kubectl apply -f deployment.yml
kubectl apply -f service.yml
apiVersion: v1
kind: ConfigMap
metadata:
name: mosquitto-config
data:
mosquitto.conf: |-
listener 1883
allow_anonymous true
persistence true
persistence_location /mosquitto/data/
apiVersion: apps/v1
kind: Deployment
metadata:
name: mqtt
spec:
selector:
matchLabels:
app: mqtt
replicas: 1
template:
metadata:
labels:
app: mqtt
spec:
containers:
- name: mqtt
image: eclipse-mosquitto
ports:
- containerPort: 1883
volumeMounts:
- mountPath: /mosquitto/data
name: data
- name: mosquitto-config
mountPath: /mosquitto/config/mosquitto.conf
subPath: mosquitto.conf
volumes:
- name: data
persistentVolumeClaim:
claimName: mqtt-vol-claim
- name: mosquitto-config
configMap:
name: mosquitto-config
apiVersion: v1
kind: Service
metadata:
name: mqtt-svc
labels:
app: mqtt
spec:
ports:
- port: 1883
targetPort: 1883
protocol: TCP
selector:
app: mqtt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment