GitOps Fundamentals Lab
Teaches GitOps reconciliation and health monitoring using only shell scripts, git, and cron, no Kubernetes required.
What this file does
Teaches GitOps reconciliation and health monitoring using only shell scripts, git, and cron, no Kubernetes required.
When to use it
- Learning GitOps concepts without a Kubernetes cluster
- Building a simple drift-detection demo for a team
- Prototyping a reconciliation loop before implementing in production
- Teaching declarative configuration and self-healing principles
Assumes this stack
GitOps Fundamentals Lab
This lab teaches core GitOps principles by simulating key workflows using only Linux command-line tools. Students will:
- Practice declarative configuration management
- Implement automated reconciliation
- Build self-healing systems
- Monitor state synchronization health
No Kubernetes or GitOps tools required!
Task 1: Git State Reconciliation
Objective: Simulate how GitOps operators continuously synchronize cluster state with Git
Why This Matters:
- Understand the core reconciliation loop in GitOps
- Learn why declarative configuration > imperative commands
- See how automation prevents configuration drift
Tools Used:
git | watch | diff | cp
-
Initialize repository:
mkdir gitops-lab && cd gitops-lab git init -
Create desired state:
echo "version: 1.0" > desired-state.txt git add . && git commit -m "Initial state" -
Simulate live cluster:
cp desired-state.txt current-state.txt -
Create reconciliation script:
#!/bin/bash # reconcile.sh DESIRED=$(cat desired-state.txt) CURRENT=$(cat current-state.txt) if [ "$DESIRED" != "$CURRENT" ]; then echo "$(date) - DRIFT DETECTED! Reconciling..." cp desired-state.txt current-state.txt fi -
Trigger manual drift:
echo "version: 2.0" > current-state.txt # Simulate manual cluster change -
Run reconciliation:
chmod +x reconcile.sh ./reconcile.sh # Should detect and fix drift -
Automate reconciliation:
watch -n 5 ./reconcile.sh # Runs every 5 seconds -
Documentation:
- Create a
submission7.mdfile. - Provide the output.
- Create a
Expected Output
Mon Jul 3 14:30:00 UTC 2023 - DRIFT DETECTED! Reconciling...
Task 2: GitOps Health Monitoring
Objective: Implement health checks for configuration synchronization
Why This Matters:
- Learn to validate system state consistency
- Detect configuration drift before it causes failures
- Build proactive monitoring for GitOps systems
Tools Used:
md5sum | cron | echo | date
-
Create health check script:
#!/bin/bash # healthcheck.sh DESIRED_MD5=$(md5sum desired-state.txt | awk '{print $1}') CURRENT_MD5=$(md5sum current-state.txt | awk '{print $1}') if [ "$DESIRED_MD5" != "$CURRENT_MD5" ]; then echo "$(date) - CRITICAL: State mismatch!" >> health.log else echo "$(date) - OK: States synchronized" >> health.log fi -
Make executable:
chmod +x healthcheck.sh -
Simulate healthy state:
./healthcheck.sh cat health.log# Should show "OK" -
Create drift:
echo "unapproved change" >> current-state.txt -
Run health check:
./healthcheck.sh cat health.log# Now shows "CRITICAL" -
Documentation:
- Provide the output in a
submission7.mdfile.
- Provide the output in a
Expected Output in health.log
Mon Jul 3 14:35:00 UTC 2023 - OK: States synchronized
Mon Jul 3 14:36:00 UTC 2023 - CRITICAL: State mismatch!
Lab Guidelines
- Use proper Markdown formatting and structure for the documentation files.
- Organize the files within the lab folder using appropriate naming conventions.
- Create a Pull Request to the main branch of the repository with your completed lab assignment.
-
Key Concepts Demonstrated:
Task GitOps Principle Real-World Equivalent 1 Continuous Reconciliation Argo CD/Flux sync loops 2 Health Monitoring Kubernetes operator status checks
"These simulations mirror how real GitOps operators work - just at human speed instead of computer speed!"
What's inside
2 tasks with 8 steps each, 2 shell scripts, 2 expected output examples, 1 comparison table.
Change this for your project
- Replace
desired-state.txtandcurrent-state.txtwith your own config file names - Replace
submission7.mdwith your lab's required output filename - Replace
inno-devops-labs/Sum25-intro-labswith your own repository URL
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Using
watch -n 5to simulate a continuous reconciliation loop - Using
md5sumfor lightweight state comparison instead of full file diff
Related Documents
MCP Integration Workflows and Orchestration Guide
Defines enterprise-grade integration patterns, orchestration strategies, and advanced workflows for MCP servers with code examples.
AI-Generated Short-Form Video Platform
Defines a modular SaaS pipeline that transforms uploaded MP4 videos into polished short-form clips using AI agents and human review.
Valet V1 — Architecture & Implementation Plan
Defines a hosted background coding agent platform with isolated sandboxed dev environments, multiplayer sessions, and YAML-driven workflows.
GitHub Topics & Skills Monitor
Provides a structured GitHub monitoring strategy with search queries, watchlist, and notification options for AI skills, agents, and MCP servers.