Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Pull Request

## Goal
<!-- Clearly describe what this PR accomplishes -->

## Changes
<!-- List the main modifications in this PR -->
-
-
-

## Testing
<!-- Describe how you verified these changes work correctly -->
-
-
-

## Checklist
- [ ] Clear, descriptive PR title
- [ ] Documentation/README updated (if needed)
- [ ] No secrets or large temporary files committed
3 changes: 3 additions & 0 deletions gitops-lab/current-state.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: 1.0
app: myapp
replicas: 3
3 changes: 3 additions & 0 deletions gitops-lab/desired-state.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: 1.0
app: myapp
replicas: 3
15 changes: 15 additions & 0 deletions gitops-lab/health.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Wed 25 Mar 2026 11:55:20 AM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 11:55:40 AM MSK - ❌ CRITICAL: State mismatch detected!
Desired MD5: a15a1a4f965ecd8f9e23a33a6b543155
Current MD5: 48168ff3ab5ffc0214e81c7e2ee356f5
Wed 25 Mar 2026 11:59:36 AM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:06 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:09 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:12 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:15 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:18 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:21 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:24 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:27 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:30 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:33 PM MSK - ✅ OK: States synchronized
13 changes: 13 additions & 0 deletions gitops-lab/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# healthcheck.sh - Monitor GitOps sync health

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 detected!" | tee -a health.log
echo " Desired MD5: $DESIRED_MD5" | tee -a health.log
echo " Current MD5: $CURRENT_MD5" | tee -a health.log
else
echo "$(date) - ✅ OK: States synchronized" | tee -a health.log
fi
10 changes: 10 additions & 0 deletions gitops-lab/monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# monitor.sh - Combined reconciliation and health monitoring

echo "Starting GitOps monitoring..."
for i in {1..10}; do
echo "\n--- Check #$i ---"
./healthcheck.sh
./reconcile.sh
sleep 3
done
14 changes: 14 additions & 0 deletions gitops-lab/reconcile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# reconcile.sh - GitOps reconciliation loop

DESIRED=$(cat desired-state.txt)
CURRENT=$(cat current-state.txt)

if [ "$DESIRED" != "$CURRENT" ]; then
echo "$(date) - ⚠️ DRIFT DETECTED!"
echo "Reconciling current state with desired state..."
cp desired-state.txt current-state.txt
echo "$(date) - ✅ Reconciliation complete"
else
echo "$(date) - ✅ States synchronized"
fi
128 changes: 128 additions & 0 deletions labs/submission7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Lab 7 — GitOps Fundamentals

## Task 1 — Git State Reconciliation

### Setup Desired State Configuration

Initial desired-state.txt and current-state.txt contents:

```
version: 1.0
app: myapp
replicas: 3
```

```
version: 1.0
app: myapp
replicas: 3
```

### Drift Detection and Reconciliation

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro$ ./reconcile.sh
Wed 25 Mar 2026 11:40:08 AM MSK - ⚠️ DRIFT DETECTED!
Reconciling current state with desired state...
Wed 25 Mar 2026 11:40:08 AM MSK - ✅ Reconciliation complete
```

Synchronized state after reconciliation:

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro$ diff desired-state.txt current-state.txt
thallars@ASUS-TUF:~/Documents/DevOps-Intro$ cat current-state.txt
version: 1.0
app: myapp
replicas: 3
```

### Automated Continuous Reconciliation

```bash
Every 5.0s: ./reconcile.sh ASUS-TUF: Wed Mar 25 11:43:02 2026

Wed 25 Mar 2026 11:43:02 AM MSK - ⚠️ DRIFT DETECTED!
Reconciling current state with desired state...
Wed 25 Mar 2026 11:43:02 AM MSK - ✅ Reconciliation complete
```

### Analysis: Explain the GitOps reconciliation loop. How does this prevent configuration drift?

The GitOps reconciliation loop continuously compares the live system state against the desired state defined in Git; if drift is detected, an automated agent immediately applies the Git-specified configuration to revert any manual changes or inconsistencies.

### Reflection: What advantages does declarative configuration have over imperative commands in production?

Declarative configuration provides a single source of truth, enabling version control, automated rollbacks, and consistency across environments, whereas imperative commands are error-prone, unrepeatable, and obscure the desired end state.

## Task 2 — GitOps Health Monitoring

### Health Check Script

```bash
#!/bin/bash
# healthcheck.sh - Monitor GitOps sync health

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 detected!" | tee -a health.log
echo " Desired MD5: $DESIRED_MD5" | tee -a health.log
echo " Current MD5: $CURRENT_MD5" | tee -a health.log
else
echo "$(date) - ✅ OK: States synchronized" | tee -a health.log
fi
```

### Test Health Monitoring

Output showing "OK" status when states match:

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro/gitops-lab$ ./healthcheck.sh
Wed 25 Mar 2026 11:55:20 AM MSK - ✅ OK: States synchronized
```

Output showing "CRITICAL" status when drift is detected:

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro/gitops-lab$ ./healthcheck.sh
Wed 25 Mar 2026 11:55:40 AM MSK - ❌ CRITICAL: State mismatch detected!
Desired MD5: a15a1a4f965ecd8f9e23a33a6b543155
Current MD5: 48168ff3ab5ffc0214e81c7e2ee356f5
```

Complete health.log file showing multiple checks:

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro/gitops-lab$ cat health.log
Wed 25 Mar 2026 11:55:20 AM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 11:55:40 AM MSK - ❌ CRITICAL: State mismatch detected!
Desired MD5: a15a1a4f965ecd8f9e23a33a6b543155
Current MD5: 48168ff3ab5ffc0214e81c7e2ee356f5
Wed 25 Mar 2026 11:59:36 AM MSK - ✅ OK: States synchronized
```

### Continuous Health Monitoring

```bash
thallars@ASUS-TUF:~/Documents/DevOps-Intro/gitops-lab$ cat health.log
Wed 25 Mar 2026 11:55:20 AM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 11:55:40 AM MSK - ❌ CRITICAL: State mismatch detected!
Desired MD5: a15a1a4f965ecd8f9e23a33a6b543155
Current MD5: 48168ff3ab5ffc0214e81c7e2ee356f5
Wed 25 Mar 2026 11:59:36 AM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:06 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:09 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:12 PM MSK - ✅ OK: States synchronized
Wed 25 Mar 2026 12:02:15 PM MSK - ✅ OK: States synchronized
```

### Analysis: How do checksums (MD5) help detect configuration changes?

Checksums (MD5) generate a unique fingerprint of a configuration file's content; any unauthorized or accidental change alters the fingerprint, allowing the system to immediately detect and flag the drift.

### Comparison: How does this relate to GitOps tools like ArgoCD's "Sync Status"?

ArgoCD's "Sync Status" uses similar hashing logic—it compares the live resource's hash against the desired state's hash from Git—to determine if the cluster is "Synced" (matching) or "OutOfSync" (drifted), automating the detection process that a manual MD5 check would serve.