Skip to content

explicit-logic/kubernetes-module-10.2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module 10 - Container Orchestration with Kubernetes

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

Part 1: Deploy Mosquitto without volumes

This section demonstrates the default Mosquitto configuration before attaching any volumes.

1. Deploy Mosquitto

kubectl apply -f mosquitto-without-volumes.yaml

2. Exec into the container

First, get the pod name:

kubectl get pods

Then open a shell (replace the pod name with your actual pod name):

kubectl exec -it mosquitto-8bbb9c957-dkrnj -- /bin/sh

3. Inspect the default config file

Once inside the container, you can view the default Mosquitto configuration:

Default mosquitto.conf

4. Clean up

kubectl delete -f mosquitto-without-volumes.yaml

Part 2: Deploy Mosquitto with ConfigMap and Secret Volumes

1. Create the ConfigMap from mosquitto.conf

kubectl apply -f config-file.yaml

2. Create the secret from secret.file

kubectl apply -f secret-file.yaml

3. 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-file

4. 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: true

5. Apply the updated Deployment

kubectl apply -f mosquitto.yaml

Result

The config and secret files are now mounted into the container at the specified paths:

Mounted config files

Demo

About

Deploy Mosquitto message broker with ConfigMap and Secret Volume Types

Topics

Resources

Stars

Watchers

Forks

Contributors