K8s cluster - mosquitto

Why?

I’m studying electronics and MQTT is quite handy protocol for IoT devices (which I make from time to time).

k8s config

I also have a configmap generated from default config, so I’m not providing it here.

apiVersion: apps/v1
kind: Deployment
metadata:
    name: mosquitto
    namespace: mosquitto
    labels:
        app: mosquitto
spec:
    replicas: 1
    selector:
        matchLabels:
            app: mosquitto
    template:
        metadata:
            labels:
                app: mosquitto
        spec:
            containers:
              - name: mosquitto
                image: eclipse-mosquitto:latest
                imagePullPolicy: Always
                ports:
                  - name: mqtt
                    containerPort: 1883
                    protocol: TCP
                  - name: websocket
                    containerPort: 9001
                    protocol: TCP
                volumeMounts:
                  - mountPath: /mosquitto/config
                    name: config-pv
                  # - mountPath: /mosquitto/data
                  #   name: data-pv
            volumes:
              - name: config-pv
                configMap:
                    defaultMode: 420
                    name: mosquitto
---
apiVersion: v1
kind: Service
metadata:
    name: mosquitto
    namespace: mosquitto
    labels:
        app: mosquitto
spec:
    type: LoadBalancer
    selector:
        app: mosquitto
    ports:
      - name: mqtt
        port: 1883
        protocol: TCP
        targetPort: mqtt