Files
netmaker-helm/templates/mq.yaml
2023-08-07 18:58:49 +05:30

145 lines
3.7 KiB
YAML

{{- $fullName := include "netmaker.fullname" . -}}
{{- $claimName := printf "%s-%s" $fullName "shared-data-pvc" }}
{{- if .Values.mq.existingClaim }}
{{- $claimName = .Values.mq.existingClaimName -}}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: {{ include "netmaker.fullname" . }}-mqtt
app.kubernetes.io/name: {{ include "netmaker.fullname" . }}-mqtt
name: {{ include "netmaker.fullname" . }}-mqtt
spec:
selector:
matchLabels:
app: {{ include "netmaker.fullname" . }}-mqtt
replicas: {{ .Values.mq.replicas }}
strategy:
type: Recreate
template:
metadata:
labels:
app: {{ include "netmaker.fullname" . }}-mqtt
spec:
containers:
- name: mosquitto
envFrom:
- configMapRef:
name: {{ include "netmaker.fullname" . }}-env
image: eclipse-mosquitto:2.0.11-openssl
command: ["/mosquitto/config/wait.sh"]
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 8883
timeoutSeconds: 1
ports:
- containerPort: 1883
name: mqtt
protocol: TCP
- containerPort: 8883
name: mqtt2
protocol: TCP
readinessProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 8883
timeoutSeconds: 1
resources: {}
startupProbe:
failureThreshold: 30
periodSeconds: 5
successThreshold: 1
tcpSocket:
port: 8883
timeoutSeconds: 1
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /mosquitto/config/mosquitto.conf
name: mosquitto-config
subPath: mosquitto.conf
- mountPath: /mosquitto/config/wait.sh
name: wait-script
subPath: wait.sh
volumes:
- configMap:
name: {{ include "netmaker.fullname" . }}-mqtt-config
name: mosquitto-config
- configMap:
name: {{ include "netmaker.fullname" . }}-mqtt-wait
defaultMode: 0744
name: wait-script
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "netmaker.fullname" . }}-mqtt
spec:
ports:
- name: mqtt
port: 1883
protocol: TCP
targetPort: mqtt
- name: mqtt2
port: 8883
protocol: TCP
targetPort: mqtt2
selector:
app: {{ include "netmaker.fullname" . }}-mqtt
sessionAffinity: None
---
apiVersion: v1
data:
mosquitto.conf: |
per_listener_settings false
listener 8883
protocol websockets
allow_anonymous false
listener 1883
protocol websockets
allow_anonymous false
password_file /mosquitto/password.txt
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: {{ include "netmaker.fullname" . }}-mqtt
app.kubernetes.io/name: {{ include "netmaker.fullname" . }}-mqtt
name: {{ include "netmaker.fullname" . }}-mqtt-config
---
apiVersion: v1
data:
wait.sh: |
#!/bin/ash
encrypt_password() {
echo "${MQ_USERNAME}:${MQ_PASSWORD}" > /mosquitto/password.txt
mosquitto_passwd -U /mosquitto/password.txt
}
main(){
encrypt_password
echo "Starting MQ..."
# Run the main container command.
/docker-entrypoint.sh
/usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf
}
main "${@}"
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/instance: {{ include "netmaker.fullname" . }}-mqtt
app.kubernetes.io/name: {{ include "netmaker.fullname" . }}-mqtt
name: {{ include "netmaker.fullname" . }}-mqtt-wait