This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.
https://www.techworld-with-nana.com/devops-bootcamp
Demo Project: Deploy Mosquitto message broker with ConfigMap and Secret Volume Types
Technologies used: Kubernetes, Docker, Mosquitto
Project Description:
- Define configuration and passwords for Mosquitto message broker with ConfigMap and Secret Volume types
This section demonstrates the default Mosquitto configuration before attaching any volumes.
1. Deploy Mosquitto
kubectl apply -f mosquitto-without-volumes.yaml2. Exec into the container
First, get the pod name:
kubectl get podsThen open a shell (replace the pod name with your actual pod name):
kubectl exec -it mosquitto-8bbb9c957-dkrnj -- /bin/sh3. Inspect the default config file
Once inside the container, you can view the default Mosquitto configuration:
4. Clean up
kubectl delete -f mosquitto-without-volumes.yaml1. Create the ConfigMap from mosquitto.conf
kubectl apply -f config-file.yaml2. Create the secret from secret.file
kubectl apply -f secret-file.yaml3. Add volume definitions to the Deployment
In mosquitto.yaml, add the following under spec.template.spec:
volumes:
- name: mosquitto-config
configMap:
name: mosquitto-config-file
- name: mosquitto-secret
secret:
secretName: mosquitto-secret-file4. Mount the volumes into the container
In mosquitto.yaml, add the following under spec.template.spec.containers[*]:
volumeMounts:
- name: mosquitto-config
mountPath: /mosquitto/config
readOnly: true
- name: mosquitto-secret
mountPath: /mosquitto/secret
readOnly: true5. Apply the updated Deployment
kubectl apply -f mosquitto.yamlThe config and secret files are now mounted into the container at the specified paths:


