Skip to content

Ahmed Baha Eddine Alimi - B23-SD-01 [Lab12 + Bonus Task]#13

Merged
3llimi merged 3 commits intomasterfrom
lab12
Mar 16, 2026
Merged

Ahmed Baha Eddine Alimi - B23-SD-01 [Lab12 + Bonus Task]#13
3llimi merged 3 commits intomasterfrom
lab12

Conversation

@3llimi
Copy link
Copy Markdown
Owner

@3llimi 3llimi commented Mar 16, 2026

Lab 12 — ConfigMaps & Persistent Volumes

What was done:

  • Added file-based visits counter to Python app with thread-safe threading.Lock() to prevent race conditions; counter reads/writes to VISITS_FILE env var path (default /data/visits) with graceful fallback to 0 on missing or corrupted file
  • Added GET /visits endpoint returning current count and timestamp; updated GET / to include visits field and new endpoint in the endpoints list
  • Updated monitoring/docker-compose.yml to use bind mount ./data:/data instead of named volume — named volumes are owned by root on creation, causing PermissionError since container runs as non-root appuser; confirmed persistence across docker compose restart (counter continued from 3 → 4)
  • Created k8s/devops-python/files/config.json with app name, environment, feature flags, and settings; added templates/configmap.yaml with two ConfigMaps — file ConfigMap using .Files.Get mounted at /config/config.json, and env ConfigMap with 4 keys injected via envFrom.configMapRef; verified both inside pod
  • Created k8s/devops-python/templates/pvc.yaml with 100Mi ReadWriteOnce claim using default storage class; mounted at /data in deployment; confirmed PVC persistence — visits counter preserved at 4 after kubectl delete pod

Bonus:

  • Tested ConfigMap hot reload — directory mount auto-updates in ~60 seconds via kubelet sync period without pod restart; confirmed by editing ConfigMap via kubectl edit and observing environment: staging appear in mounted file after 60s
  • Documented subPath limitation: files mounted via subPath are copied once at pod creation and never auto-update because they bypass the symlink mechanism used for directory mounts
  • Implemented checksum annotation pattern in deployment template — checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} triggers rolling pod restart whenever ConfigMap content changes via helm upgrade, ensuring pods always reload with fresh configuration

@3llimi 3llimi merged commit f724d1f into master Mar 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant