Add passwordfile

This commit is contained in:
Ruben Hensen
2025-03-09 22:59:13 +01:00
parent 53334d2f08
commit 35b0c87c39
+66 -46
View File
@@ -45,22 +45,6 @@ spec:
requests: requests:
storage: 1Gi storage: 1Gi
--- ---
# ConfigMap for Mosquitto configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: mosquitto-config
data:
mosquitto.conf: |
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883
listener 8883
# If you need SSL/TLS for the MQTT broker, add appropriate configuration here
# certfile /mosquitto/config/cert.pem
# keyfile /mosquitto/config/key.pem
---
# Deployment for OwnTracks Recorder # Deployment for OwnTracks Recorder
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -116,63 +100,99 @@ spec:
targetPort: 8083 targetPort: 8083
type: ClusterIP type: ClusterIP
--- ---
# Deployment for Mosquitto # ExternalSecret to fetch MQTT password file from Vault
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: mqtt-password-file
namespace: mqtt
spec:
refreshInterval: "15m"
secretStoreRef:
name: vault-backend
kind: ClusterSecretStore
target:
name: mqtt-password-secret
creationPolicy: Owner
data:
- secretKey: password_file
remoteRef:
key: kv/mqtt
property: secret
---
# ConfigMap for MQTT configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: mqtt-config
namespace: mqtt
data:
mosquitto.conf: |
listener 1883
allow_anonymous false
password_file /mosquitto/config/password_file
# Add other MQTT configuration options here
---
# MQTT Deployment
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: mosquitto name: mqtt
namespace: mqtt
labels:
app: mqtt
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app: mosquitto app: mqtt
template: template:
metadata: metadata:
labels: labels:
app: mosquitto app: mqtt
spec: spec:
containers: containers:
- name: mosquitto - name: mqtt
image: eclipse-mosquitto:latest image: eclipse-mosquitto:latest
ports: ports:
- containerPort: 1883 - containerPort: 1883
name: mqtt name: mqtt
- containerPort: 8883 - containerPort: 9001
name: mqtts name: websocket
volumeMounts: volumeMounts:
- name: data - name: config
mountPath: /mosquitto/data mountPath: /mosquitto/config/mosquitto.conf
- name: logs subPath: mosquitto.conf
mountPath: /mosquitto/log - name: password-file
- name: config-volume mountPath: /mosquitto/config/password_file
mountPath: /mosquitto/config subPath: password_file
volumes: volumes:
- name: data - name: config
persistentVolumeClaim:
claimName: mosquitto-data-pvc
- name: logs
persistentVolumeClaim:
claimName: mosquitto-logs-pvc
- name: config-volume
configMap: configMap:
name: mosquitto-config name: mqtt-config
- name: password-file
secret:
secretName: mqtt-password-secret
--- ---
# Service for Mosquitto # MQTT Service
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: mosquitto name: mqtt
namespace: mqtt
spec: spec:
selector: selector:
app: mosquitto app: mqtt
ports: ports:
- name: mqtt - port: 1883
port: 1883
targetPort: 1883 targetPort: 1883
- name: mqtts name: mqtt
port: 8883 - port: 9001
targetPort: 8883 targetPort: 9001
type: ClusterIP name: websocket
--- ---
# External access with Ingress for OwnTracks Recorder # External access with Ingress for OwnTracks Recorder
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1